From ebdaac3f4f8a629e801ffba65afce2920e191b24 Mon Sep 17 00:00:00 2001 From: Jos Groot Lipman Date: Tue, 6 Sep 2011 10:21:18 +0000 Subject: [PATCH] v2.60 Layer cleaning, Contouritems, Layeritems svn path=/Slnkdwf/trunk/; revision=12509 --- SlnkDWFCom/SLNKDWFVersion.h | 2 +- SlnkDWFCom/WhipFile.cpp | 111 ++++++++++++++++++++++++------------ SlnkDWFImpl/Whip2DCImpl.cpp | 28 ++++++--- SlnkDWFImpl/Whip2DCState.h | 1 + 4 files changed, 98 insertions(+), 44 deletions(-) diff --git a/SlnkDWFCom/SLNKDWFVersion.h b/SlnkDWFCom/SLNKDWFVersion.h index 0e39050..f18a473 100644 --- a/SlnkDWFCom/SLNKDWFVersion.h +++ b/SlnkDWFCom/SLNKDWFVersion.h @@ -1,6 +1,6 @@ // Zorg dat versies alfabetisch altijd op elkaar volgen! #define SLNK_MAJOR_VERSION 2 -#define SLNK_MINOR_VERSION 51 +#define SLNK_MINOR_VERSION 60 #define SLNK_BUILD_VERSION 0 // Define resource strings diff --git a/SlnkDWFCom/WhipFile.cpp b/SlnkDWFCom/WhipFile.cpp index eb49128..077595c 100644 --- a/SlnkDWFCom/WhipFile.cpp +++ b/SlnkDWFCom/WhipFile.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * File : WhipFile.cpp (c) 2005-2010, SG|Facilitor + * File : WhipFile.cpp (c) 2005-2011, SG|Facilitor * * Author : J. Groot Lipman * Project : SLNKDWF @@ -300,18 +300,31 @@ void CWhipFile::processLabels() WT_Result CWhipFile::my_process_layer (WT_Layer & layer, WT_File & file) { file.rendition().layer() = layer; - if (layer.layer_name().length()>0) // Anders zittie alleen maar in de weg - { // Dat doet de default_process 'fout' + WT_Layer *ll; + + CWhipFileState *m_State = (CWhipFileState *)file.heuristics().user_data(); + CString layer_name(layer.layer_name().ascii()); + + if (layer_name != "") // Anders zittie alleen maar in de weg + { // Dat doet de default_process 'fout' + // Overbodige lagen negeren we: + if (layer_name == m_State->m_activeLayerName) + return WT_Result::Success; + file.layer_list().add_layer(layer); + ll = &layer; + } + else + { + WT_Integer32 layer_num = layer.layer_num(); + ll = file.layer_list().find_layer_from_index(layer_num); } - WT_Integer32 layer_num = layer.layer_num(); - WT_Layer *ll = file.layer_list().find_layer_from_index(layer_num); - if (ll&& ll->layer_name().ascii()) + if (ll) { - CWhipFileState *m_State = (CWhipFileState *)file.heuristics().user_data(); - m_State->labelLayerActive = m_State->labelMatch(ll->layer_name().ascii()); - m_State->contLayerActive = m_State->contMatch(ll->layer_name().ascii()); + m_State->m_activeLayerName = ll->layer_name().ascii(); + m_State->labelLayerActive = m_State->labelMatch(m_State->m_activeLayerName); + m_State->contLayerActive = m_State->contMatch(m_State->m_activeLayerName); } return WT_Result::Success; @@ -486,7 +499,8 @@ WT_Result CWhipFile::my_process_text (WT_Text & text, WT_File & file) if (!m_State->labelLayerActive) return WT_Result::Success; // Wrong layer - m_State->m_SLNKLabels.Add(text); + if (text.string().is_ascii() && strlen(text.string().ascii()) > 0) + m_State->m_SLNKLabels.Add(text); return WT_Result::Success; } @@ -496,12 +510,20 @@ WT_Result CWhipFile::my_process_text (WT_Text & text, WT_File & file) // zodat die (als ze ingekleurd worden) altijd onderaan liggen HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, double scale) { + CmyTimer tm("Serializing plan"); + WT_Result result; BOOL firstDrawable = true; BOOL CurrentLayerOn = TRUE; // Skip contourlagen + // Deze drie waren niet geclear'd door de close na het lezen van de contouren + my_plan_file.layer_list().remove_all(); + my_plan_file.object_node_list().remove_all(); + my_plan_file.dash_pattern_list().remove_all(); + my_plan_file.set_layer_action(my_process_layer); // Override default processing // Do the actual reading. + CString last_layer; while ((result = my_plan_file.process_next_object()) == WT_Result::Success) { @@ -534,7 +556,7 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do case WT_Object::URL_ID: // Strippen omdat ze in de weg kunnen zitten met onze eigen URL's case WT_Object::Object_Node_ID: // kunnen we ook niets mee. Had RWSN#20095 in 1101EM0108_01.dwf break; - case WT_Object::Layer_ID: + case WT_Object::Layer_ID: { // Sla de oorspronkelijke contour lagen over // En ook de lagen die we niet willen CurrentLayerOn = TRUE; @@ -549,17 +571,21 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do break; } } - WT_Layer *ll = my_plan_file.layer_list().find_layer_from_index(layer_num); + // Noot: gooi de originele contour-lagen er altijd uit - if (ll&& - ll->layer_name().ascii()&& - (m_State.labelMatch(ll->layer_name().ascii()) || - m_State.contMatch(ll->layer_name().ascii()) || - !m_State.layerMatch(ll->layer_name().ascii())) + if ((m_State.labelMatch(m_State.m_activeLayerName) || + m_State.contMatch(m_State.m_activeLayerName) || + !m_State.layerMatch(m_State.m_activeLayerName)) ) CurrentLayerOn = FALSE; // Layer object hoeft ook niet meer geserialized else - layer->serialize(my_file); + { + if (m_State.m_activeLayerName != last_layer) // cleaning, scheelt fors bij RIJSWIJKHB-02.dwf + { + layer->serialize(my_file); + last_layer = m_State.m_activeLayerName; + } + } break; } default: @@ -585,6 +611,9 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do break; } } + + myDoTRACE("\nWritten %d/%d layers", my_plan_file.layer_list().count(), my_file.layer_list().count()); + // if (result == WT_Result::End_Of_DWF_Opcode_Found) // dwfresult = DwfResult::Success; @@ -867,10 +896,7 @@ STDMETHODIMP CWhipFile::Generate(myWT_File &my_file) my_file.heuristics().set_transform(WT_Transform (lshift, 1.0, 1.0, 0)); my_file.heuristics().set_apply_transform(true); - { - CmyTimer tm("Serializing plan"); - SerializePlan(m_W2DFile, my_file, scale); // Heeft eventueel een GenerateContouren in zich! - } + SerializePlan(m_W2DFile, my_file, scale); // Heeft eventueel een GenerateContouren in zich! #ifdef _DEBUG cmt.set("Plan is serialized"); cmt.serialize(my_file); @@ -1123,18 +1149,7 @@ STDMETHODIMP CWhipFile::get_Contour(BSTR IdentLabel, ISLNKContour** pVal) CSLNKContourImpl *contour= m_State.m_SLNKContouren[i]; if (contour->m_contLabel.length()>0 && contour->m_contLabel.equals(IdentLabel)) { - CComObject *theContour; - HRESULT hr = CComObject::CreateInstance(&theContour); - if(FAILED(hr)) return hr; - - theContour->AddRef(); - hr = theContour->QueryInterface(IID_ISLNKContour, (void **)pVal); - theContour->SetParent(this); - theContour->Release(); - if(FAILED(hr)) return hr; - theContour->SetImpl(contour); // Heel belangrijk: zet de implementatie waar we een interface op bieden - - return S_OK; // Wel gevonden + return get_ContourItem((ULONG) i, pVal); } } return S_OK; // Niet gevonden. Automatisch NULL? @@ -1192,4 +1207,30 @@ STDMETHODIMP CWhipFile::get_FindInContour(DOUBLE dwgX, DOUBLE dwgY, BSTR* pVal) } } return S_OK; -} \ No newline at end of file +} + +STDMETHODIMP CWhipFile::get_ContourCount(LONG* pVal) +{ + *pVal = (LONG)m_State.m_SLNKContouren.GetCount(); + + return S_OK; +} + +STDMETHODIMP CWhipFile::get_ContourItem(ULONG i, ISLNKContour** pVal) +{ + if (i < 0 || i >= m_State.m_SLNKContouren.GetCount()) + return E_INVALIDARG; + CComObject *theContour; + HRESULT hr = CComObject::CreateInstance(&theContour); + if(FAILED(hr)) return hr; + + theContour->AddRef(); + hr = theContour->QueryInterface(IID_ISLNKContour, (void **)pVal); + theContour->SetParent(this); + theContour->Release(); + if(FAILED(hr)) return hr; + + theContour->SetImpl(m_State.m_SLNKContouren[i]); // Heel belangrijk: zet de implementatie waar we een interface op bieden + + return S_OK; // Wel gevonden +} diff --git a/SlnkDWFImpl/Whip2DCImpl.cpp b/SlnkDWFImpl/Whip2DCImpl.cpp index 42432f5..6fcda22 100644 --- a/SlnkDWFImpl/Whip2DCImpl.cpp +++ b/SlnkDWFImpl/Whip2DCImpl.cpp @@ -756,22 +756,34 @@ WT_Result CWhip2DCImpl::my_process_linePattern (WT_Line_Pattern & linePattern, W WT_Result CWhip2DCImpl::my_process_layer (WT_Layer & layer, WT_File & file) { CWhip2DCState *m_State = (CWhip2DCState *)file.heuristics().user_data(); + CString layer_name(layer.layer_name().ascii()); file.rendition().layer() = layer; - if (layer.layer_name().length()>0) // Anders zittie alleen maar in de weg + WT_Layer *ll; + + if (layer_name != "") // Anders zittie alleen maar in de weg { // Dat doet de default_process 'fout' + // Overbodige lagen negeren we: + if (layer_name == m_State->m_activeLayerName) + return WT_Result::Success; + file.layer_list().add_layer(layer); + ll = &layer; m_State->m_Layernames.Add(layer.layer_name().ascii()); } - - WT_Integer32 layer_num = layer.layer_num(); - WT_Layer *ll = file.layer_list().find_layer_from_index(layer_num); - - if (ll&&ll->layer_name().ascii()) + else { + WT_Integer32 layer_num = layer.layer_num(); + ll = file.layer_list().find_layer_from_index(layer_num); + } + + if (ll) + { + m_State->m_activeLayerName = ll->layer_name().ascii(); + //myTRACE("\n my_output_file.desired_rendition().layer() = layer %s;", layer.layer_name().ascii()); CAtlREMatchContext<> mcUrl; - if ( m_State->reLayers.Match(ll->layer_name().ascii(), &mcUrl)) + if ( m_State->reLayers.Match(m_State->m_activeLayerName, &mcUrl)) { //myTRACE(".. does match!"); m_State->bLayerVisible = TRUE; @@ -783,7 +795,7 @@ WT_Result CWhip2DCImpl::my_process_layer (WT_Layer & layer, WT_File & file) } // myTRACE("\nLayer %s .. does not match", ll->layer_name().ascii()); - m_State->bIsSymbolLayer = (ll->layer_name() == "SLNK Symbols"); + m_State->bIsSymbolLayer = (m_State->m_activeLayerName == "SLNK Symbols"); //myDoTRACE("\nLayer %s %d", ll->layer_name().ascii(), m_State->bIsSymbolLayer); } else diff --git a/SlnkDWFImpl/Whip2DCState.h b/SlnkDWFImpl/Whip2DCState.h index b5b4a9f..a574298 100644 --- a/SlnkDWFImpl/Whip2DCState.h +++ b/SlnkDWFImpl/Whip2DCState.h @@ -52,6 +52,7 @@ public: CAtlRegExp<> reLayers; // Welke layers moeten aan BOOL bLayerVisible; // Current Layer visible? BOOL bIsSymbolLayer; + CString m_activeLayerName; CAtlArray m_Layernames; CAtlArray m_FoundTexts;