public void Detach() { m_diagramClass = null; m_parentNodeClass = null; m_targetNodeClass = null; m_targetLinkClass = null; }
private TranslateTree GetSavedAlgo() { TranslateTree myAlgo = FindOurAlgo(); if (myAlgo == null) { return(null); } ISchematicDiagramClassName diagramClassName = myAlgo.SchematicDiagramClassName; IName pName = diagramClassName as IName; if (pName == null) { return(null); } object unk = pName.Open(); ISchematicDiagramClass diagramClass = unk as ISchematicDiagramClass; if (diagramClass == null) { return(null); } // get the default algorithms for this diagram class IEnumSchematicAlgorithm enumAlgorithms = diagramClass.SchematicAlgorithms; if (enumAlgorithms == null) { return(null); } TranslateTree savedAlgo = null; enumAlgorithms.Reset(); ISchematicAlgorithm algorithm; while ((algorithm = enumAlgorithms.Next()) != null) { savedAlgo = algorithm as TranslateTree; if (savedAlgo != null) { break; } } return(savedAlgo); }
public void Alter(ISchematicDiagramClass schematicDiagramClass, ESRI.ArcGIS.esriSystem.IPropertySet propertySet) { m_diagramClass = schematicDiagramClass; try { m_description = propertySet.GetProperty("DESCRIPTION").ToString(); } catch { } try { m_reducedNodeClassName = propertySet.GetProperty("REDUCEDNODECLASS").ToString(); } catch { } try { m_superspanLinkClassName = propertySet.GetProperty("SUPERSPANLINKCLASS").ToString(); } catch { } try { m_lengthAttributeName = propertySet.GetProperty("LENGTHATTRIBUTENAME").ToString(); } catch { } try { m_keepVertices = (bool)propertySet.GetProperty("KEEPVERTICES"); } catch { } try { m_linkAttribute = (bool)propertySet.GetProperty("LINKATTRIBUTE"); } catch { } try { m_linkAttributeName = propertySet.GetProperty("LINKATTRIBUTENAME").ToString(); } catch { } }
public void Alter(ISchematicDiagramClass schematicDiagramClass, ESRI.ArcGIS.esriSystem.IPropertySet propertySet) { m_diagramClass = schematicDiagramClass; try { m_description = propertySet.GetProperty("DESCRIPTION").ToString(); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "property DESCRIPTION"); } try { m_parentNodeClassName = propertySet.GetProperty("PARENTNODECLASS").ToString(); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "property PARENTNODECLASS"); } try { m_targetNodeClassName = propertySet.GetProperty("TARGETNODECLASS").ToString(); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "property TARGETNODECLASS"); } try { m_targetLinkClassName = propertySet.GetProperty("TARGETLINKCLASS").ToString(); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "property TARGETLINKCLASS"); } try { m_distance = (double)propertySet.GetProperty("DISTANCE"); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "property DISTANCE"); } }
public void Alter(ISchematicDiagramClass schematicDiagramClass, ESRI.ArcGIS.esriSystem.IPropertySet propertySet) { m_diagramClass = schematicDiagramClass; try { m_description = propertySet.GetProperty("DESCRIPTION").ToString(); } catch { } try { m_reductionLinkName = propertySet.GetProperty("REDUCTIONLINKNAME").ToString(); } catch { } try { m_usePort = (bool)propertySet.GetProperty("USEPORT"); } catch { } }
public void Apply(ISchematicInMemoryDiagram inMemoryDiagram, ESRI.ArcGIS.esriSystem.ITrackCancel cancelTracker) { if (m_reductionLinkName == "") { return; } IEnumSchematicInMemoryFeature enumSchematicElement; ISchematicInMemoryFeature schemElement; ISchematicDiagramClass diagramClass = null; ISchematicElementClass elementClass; IEnumSchematicElementClass enumElementClass; Microsoft.VisualBasic.Collection allreadyUsed = new Microsoft.VisualBasic.Collection(); try { diagramClass = inMemoryDiagram.SchematicDiagramClass; } catch { } if (diagramClass == null) { return; } enumElementClass = diagramClass.AssociatedSchematicElementClasses; enumElementClass.Reset(); elementClass = enumElementClass.Next(); while (elementClass != null) { if (elementClass.Name == m_reductionLinkName) { break; } elementClass = enumElementClass.Next(); } if (elementClass == null) { return; } // Get all link from selected class enumSchematicElement = inMemoryDiagram.GetSchematicInMemoryFeaturesByClass(elementClass); enumSchematicElement.Reset(); ISchematicInMemoryFeatureLink link = null; ISchematicInMemoryFeatureNode fromNode = null; ISchematicInMemoryFeatureNode toNode = null; int iFromPort = 0; int iToPort = 0; ISchematicInMemoryFeature newElem = null; IEnumSchematicInMemoryFeatureLink enumIncidentLinks; ISchematicInMemoryFeatureLinkerEdit schemLinker = (ISchematicInMemoryFeatureLinkerEdit)(new SchematicLinkerClass()); bool bReduction = false; schemElement = enumSchematicElement.Next(); while (schemElement != null) { try { string elemName = allreadyUsed[schemElement.Name].ToString(); // if found, this link is allready used schemElement = enumSchematicElement.Next(); continue; } catch { // Add link to collection allreadyUsed.Add(schemElement.Name, schemElement.Name, null, null); } // Get from node and to node link = (ISchematicInMemoryFeatureLink)schemElement; fromNode = link.FromNode; toNode = link.ToNode; if (m_usePort) { iFromPort = link.FromPort; iToPort = link.ToPort; } // Get all links from this node enumIncidentLinks = fromNode.GetIncidentLinks(esriSchematicEndPointType.esriSchematicOriginOrExtremityNode); enumIncidentLinks.Reset(); newElem = enumIncidentLinks.Next(); while (newElem != null) { bReduction = false; if (newElem == schemElement) { // the new link is the same link we works on newElem = enumIncidentLinks.Next(); continue; } link = (ISchematicInMemoryFeatureLink)newElem; // 1st case of comparison if (fromNode == link.FromNode && toNode == link.ToNode) { if (m_usePort) { bReduction = (iFromPort == link.FromPort && iToPort == link.ToPort); } else { bReduction = true; } } // 2nd case of comparison else if (fromNode == link.ToNode && toNode == link.FromNode) { if (m_usePort) { bReduction = (iFromPort == link.ToPort && iToPort == link.FromPort); } else { bReduction = true; } } if (bReduction) { try { schemLinker.ReportAssociations(newElem, schemElement); // Reports asssociation to first link allreadyUsed.Add(newElem.Name, newElem.Name, null, null); // Add link to collection newElem.Displayed = false; // this link is not visible } catch { } } newElem = enumIncidentLinks.Next(); } schemElement.Displayed = true; schemElement = enumSchematicElement.Next(); } }
public void Detach() { m_diagramClass = null; }
public void Apply(ISchematicInMemoryDiagram inMemoryDiagram, ESRI.ArcGIS.esriSystem.ITrackCancel cancelTracker) { if (m_reducedNodeClassName == "" || inMemoryDiagram == null) { return; } // initialize the schematic rules helper ISchematicRulesHelper rulesHelper = new SchematicRulesHelperClass(); rulesHelper.InitHelper(inMemoryDiagram); rulesHelper.KeepVertices = m_keepVertices; //////////////////////// // get the feature classes processed by the rule ISchematicDiagramClass diagramClass = null; try { diagramClass = inMemoryDiagram.SchematicDiagramClass; } catch { } if (diagramClass == null) { return; } ISchematicDataset schematicDataset = null; try { schematicDataset = diagramClass.SchematicDataset; } catch { } ISchematicElementClassContainer elementclassContainer = (ISchematicElementClassContainer)schematicDataset; if (elementclassContainer == null) { return; } ISchematicElementClass elementClassReducedNode = null; elementClassReducedNode = elementclassContainer.GetSchematicElementClass(m_reducedNodeClassName); ISchematicElementClass elementClassSuperspan = null; elementClassSuperspan = elementclassContainer.GetSchematicElementClass(m_superspanLinkClassName); if (elementClassSuperspan == null || elementClassReducedNode == null) { return; } ISchematicInMemoryFeatureClassContainer featureClassContainer = (ISchematicInMemoryFeatureClassContainer)inMemoryDiagram; if (featureClassContainer == null) { return; } ISchematicInMemoryFeatureClass superspanLinkClass = featureClassContainer.GetSchematicInMemoryFeatureClass(elementClassSuperspan); // ///////////////////////// // fetch the superspan spatial reference IGeoDataset geoDataset = (IGeoDataset)superspanLinkClass; ISpatialReference spatialRef = null; if (geoDataset != null) { spatialRef = geoDataset.SpatialReference; } if (spatialRef == null) { return; } // Retrieve the schematic in memory feature nodes to reduce System.Collections.Generic.Dictionary <string, ISchematicInMemoryFeature> colSchfeatureNode = new Dictionary <string, ISchematicInMemoryFeature>(); // get all feature of parent node class IEnumSchematicInMemoryFeature enumSchematicInMemoryFeature = inMemoryDiagram.GetSchematicInMemoryFeaturesByClass(elementClassReducedNode); // retain only the nodes of degree two RetainNodesDegreeTwo(enumSchematicInMemoryFeature, colSchfeatureNode, rulesHelper); // there would be inserted a SQL query to also filter by attributes IProgressor msgProgressor = null; if (cancelTracker != null) { msgProgressor = cancelTracker.Progressor; IStepProgressor stepProgressor = (IStepProgressor)msgProgressor; if (stepProgressor != null) { stepProgressor.MinRange = 0; stepProgressor.MaxRange = colSchfeatureNode.Count; stepProgressor.StepValue = 1; stepProgressor.Position = 0; stepProgressor.Message = m_description; cancelTracker.Reset(); cancelTracker.Progressor = msgProgressor; stepProgressor.Show(); } } ISchematicInMemoryFeature schFeatureToReduce; foreach (KeyValuePair <string, ISchematicInMemoryFeature> kvp in colSchfeatureNode) { if (cancelTracker != null) { if (cancelTracker.Continue() == false) { break; } } schFeatureToReduce = colSchfeatureNode[kvp.Key]; if (schFeatureToReduce != null) { ReduceNode(rulesHelper, superspanLinkClass, spatialRef, schFeatureToReduce); } } // release memory colSchfeatureNode.Clear(); colSchfeatureNode = null; rulesHelper = null; }
public void Detach() { m_diagramClass = null; m_parentNodeClass = null; m_targetNodeClass = null; m_targetLinkClass = null; }
public void Alter(ISchematicDiagramClass schematicDiagramClass, ESRI.ArcGIS.esriSystem.IPropertySet propertySet) { m_diagramClass = schematicDiagramClass; try { m_description = propertySet.GetProperty("DESCRIPTION").ToString(); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "property DESCRIPTION"); } try { m_parentNodeClassName = propertySet.GetProperty("PARENTNODECLASS").ToString(); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "property PARENTNODECLASS"); } try { m_targetNodeClassName = propertySet.GetProperty("TARGETNODECLASS").ToString(); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "property TARGETNODECLASS"); } try { m_targetLinkClassName = propertySet.GetProperty("TARGETLINKCLASS").ToString(); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "property TARGETLINKCLASS"); } try { m_distance = (double)propertySet.GetProperty("DISTANCE"); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "property DISTANCE"); } }
public void Apply(ISchematicInMemoryDiagram inMemoryDiagram, ESRI.ArcGIS.esriSystem.ITrackCancel cancelTracker) { ISchematicRulesHelper rulesHelper = new SchematicRulesHelperClass(); System.Collections.Generic.Dictionary <string, ISchematicInMemoryFeature> colSchfeatureNode = new Dictionary <string, ISchematicInMemoryFeature>(); rulesHelper.InitHelper(inMemoryDiagram); rulesHelper.KeepVertices = true; ISchematicDiagramClass diagramClass = null; ISchematicElementClass elementClass; ISchematicElementClass elementClassParentNode = null; IEnumSchematicElementClass enumSchEltCls; try { diagramClass = inMemoryDiagram.SchematicDiagramClass; } catch { } if (diagramClass == null) { return; } enumSchEltCls = diagramClass.AssociatedSchematicElementClasses; if (enumSchEltCls.Count == 0) { return; } enumSchEltCls.Reset(); elementClass = enumSchEltCls.Next(); while (elementClass != null) { if (elementClass.Name == m_parentNodeClassName) { elementClassParentNode = elementClass; m_parentNodeClass = GetSchematicInMemoryFeatureClass(inMemoryDiagram, elementClass); } if (elementClass.Name == m_targetNodeClassName) { m_targetNodeClass = GetSchematicInMemoryFeatureClass(inMemoryDiagram, elementClass); } if (elementClass.Name == m_targetLinkClassName) { m_targetLinkClass = GetSchematicInMemoryFeatureClass(inMemoryDiagram, elementClass); } elementClass = enumSchEltCls.Next(); } if (m_parentNodeClass == null || m_targetNodeClass == null || m_targetLinkClass == null) { return; } IEnumSchematicInMemoryFeature enumSchematicInMemoryFeature; // list nodes degree two // get all feature of parent node class enumSchematicInMemoryFeature = inMemoryDiagram.GetSchematicInMemoryFeaturesByClass(elementClassParentNode); enumSchematicInMemoryFeature.Reset(); // add the node into collection if it contains only 2 links displayed. AddNodesDegreeTwo(enumSchematicInMemoryFeature, colSchfeatureNode, rulesHelper); ISchematicInMemoryFeature schFeatureParent; foreach (KeyValuePair <string, ISchematicInMemoryFeature> kvp in colSchfeatureNode) { schFeatureParent = colSchfeatureNode[kvp.Key]; if (schFeatureParent == null) { continue; } // get 2 links connected of eache feature node IEnumSchematicInMemoryFeature enumLinks = rulesHelper.GetDisplayedIncidentLinks((ISchematicInMemoryFeatureNode)schFeatureParent, esriSchematicEndPointType.esriSchematicOriginOrExtremityNode); // enumLinks surely not null and it contain 2 links displayed double angle1, angle2, angleBisector; bool first = true; angle1 = angle2 = angleBisector = 0; IPoint pointParent = null; ISchematicInMemoryFeatureNodeGeometry geoParent; geoParent = (ISchematicInMemoryFeatureNodeGeometry)schFeatureParent; pointParent = geoParent.InitialPosition; IPoint pointSon = null; bool enableCalculate = true; ISchematicInMemoryFeature schInMemoryFeature = enumLinks.Next(); ISchematicInMemoryFeatureLink schInMemoryLink = (ISchematicInMemoryFeatureLink)schInMemoryFeature; while (schInMemoryLink != null) { ISchematicInMemoryFeatureNodeGeometry nodeGeo; // get angle of 2 links connected if (schInMemoryLink.FromNode.Name == schFeatureParent.Name) { nodeGeo = (ISchematicInMemoryFeatureNodeGeometry)schInMemoryLink.ToNode; } else { nodeGeo = (ISchematicInMemoryFeatureNodeGeometry)schInMemoryLink.FromNode; } if (nodeGeo == null) { enableCalculate = false; break; } pointSon = nodeGeo.InitialPosition; if (first) { angle1 = CalculateAngle(pointParent, pointSon); first = false; } else { angle2 = CalculateAngle(pointParent, pointSon); } schInMemoryFeature = enumLinks.Next(); schInMemoryLink = (ISchematicInMemoryFeatureLink)schInMemoryFeature; } // caculate angle bisector if (enableCalculate) { angleBisector = CalculateAngleBisector(angle1, angle2); } else { continue; } // construct a geometry for the new node node // now call alterNode to create a new schematic feature // construct a correct name string uniqueNodeName, featureCreateName; featureCreateName = schFeatureParent.Name + Separator + extensionName; esriSchematicElementType elementType = esriSchematicElementType.esriSchematicNodeType; uniqueNodeName = GetUniqueName(inMemoryDiagram, elementType, featureCreateName); IWorkspace workspace = null; try { workspace = inMemoryDiagram.SchematicDiagramClass.SchematicDataset.SchematicWorkspace.Workspace; } catch { } int datasourceID = -1; if (workspace != null) { datasourceID = rulesHelper.FindDataSourceID(workspace, false); } if (datasourceID == -1) { datasourceID = m_diagramClass.SchematicDataset.DefaultSchematicDataSource.ID; } ISchematicInMemoryFeature schFeatureNodeCreate = null; IPoint pointBisector = null; pointBisector = GetCoordPointBisector(pointParent, angleBisector, m_distance); try { schFeatureNodeCreate = rulesHelper.AlterNode(m_targetNodeClass, uniqueNodeName, null, (IGeometry)pointBisector, datasourceID, 0); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "Impossible to create a feature Node"); } // now construct a unique link name string linkName = schFeatureParent.Name + Separator + uniqueNodeName; string uniqueLinkName; elementType = esriSchematicElementType.esriSchematicLinkType; uniqueLinkName = GetUniqueName(inMemoryDiagram, elementType, linkName); // construct a link ISchematicInMemoryFeature schFeatureLinkCreate = null; try { schFeatureLinkCreate = rulesHelper.AlterLink(m_targetLinkClass, uniqueLinkName, null, null, datasourceID, 0, schFeatureParent.Name, uniqueNodeName, esriFlowDirection.esriFDWithFlow, 0, 0); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "Impossible to create a feature link"); } } if (colSchfeatureNode.Count > 0) { colSchfeatureNode.Clear(); } colSchfeatureNode = null; rulesHelper = null; }
public void Detach() { m_diagramClass = null; }
public void Alter(ISchematicDiagramClass schematicDiagramClass, ESRI.ArcGIS.esriSystem.IPropertySet propertySet) { m_diagramClass = schematicDiagramClass; try { m_description = propertySet.GetProperty("DESCRIPTION").ToString(); } catch { } try { m_reducedNodeClassName = propertySet.GetProperty("REDUCEDNODECLASS").ToString(); } catch { } try { m_superspanLinkClassName = propertySet.GetProperty("SUPERSPANLINKCLASS").ToString(); } catch { } try { m_lengthAttributeName = propertySet.GetProperty("LENGTHATTRIBUTENAME").ToString(); } catch { } try { m_keepVertices = (bool)propertySet.GetProperty("KEEPVERTICES"); } catch { } try { m_linkAttribute = (bool)propertySet.GetProperty("LINKATTRIBUTE"); } catch { } try { m_linkAttributeName = propertySet.GetProperty("LINKATTRIBUTENAME").ToString(); } catch { } }