void UpdateSelection () { // Get the tools window CToolsLogic *toolWnd = dynamic_cast<CToolsLogic*>(getMainFrame ()->m_wndSplitter.GetPane(0,1)); // Selection is changed ? bool selectionChanged = false; // For each modified primitive CWorldEditorDoc *doc = getDocument (); std::list<NLLIGO::IPrimitive*>::iterator ite = ModifiedPrimitive.begin (); while (ite != ModifiedPrimitive.end ()) { CDatabaseLocatorPointer locator; doc->getLocator (locator, *ite); IPrimitiveEditor *primitiveEditor = getPrimitiveEditor (*ite); // Selection ? if (primitiveEditor->_Channels & _SelectionSelectState) { // Update the selection UpdatePrimitiveSelection (primitiveEditor, locator, selectionChanged); // Validate primitiveEditor->_Channels &= ~_SelectionSelectState; } // Next primitive to update ite++; } /*// Change dialog selection ? if (selectionChanged) { PropertyDialog.changeSelection (Selection); }*/ }
void UpdatePrimitives () { // Get the tools window CMainFrame *mainWnd = getMainFrame (); if (mainWnd) { CToolsLogic *toolWnd = dynamic_cast<CToolsLogic*>(getMainFrame ()->m_wndSplitter.GetPane(0,1)); // Sort the list static vector<CDatabaseLocatorPointer> toSort; toSort.clear (); CWorldEditorDoc *doc = getDocument (); std::list<NLLIGO::IPrimitive*>::iterator ite = ModifiedPrimitive.begin (); while (ite != ModifiedPrimitive.end ()) { CDatabaseLocatorPointer locator; doc->getLocator (locator, *ite); toSort.push_back (locator); ite++; } sort (toSort.begin (), toSort.end ()); // For each modified primitive sint i; sint count = (sint)toSort.size (); for (i=count-1; i>=0; i--) { CDatabaseLocatorPointer locator; doc->getLocator (locator, toSort[i].Primitive); IPrimitiveEditor *primitiveEditor = getPrimitiveEditor (const_cast<IPrimitive*>(toSort[i].Primitive)); // Logic tree structure modified ? if (primitiveEditor->_Channels & LogicTreeStruct) { // Remove from the tree primitiveEditor->removeFromLogicTree (); } } // Selection is changed ? bool selectionChanged = false; // For each modified primitive for (i=0; i<count; i++) { const IPrimitive *primitive = toSort[i].Primitive; CDatabaseLocatorPointer locator; doc->getLocator (locator, primitive); IPrimitiveEditor *primitiveEditor = getPrimitiveEditor (const_cast<IPrimitive*>(primitive)); // Quad grid ? if (primitiveEditor->_Channels & QuadTree) { // Remove from the container primitiveEditor->removeFromQuadGrid (); // Num points uint pointCount = (primitive)->getNumVector (); if (pointCount > 0) { // Point pointer const CPrimVector *points = (primitive)->getPrimVector (); // BBox CAABBox bbox; bbox.setCenter (points[0]); // Extend the bbox uint j; for (j=1; j<pointCount; j++) { bbox.extend (points[j]); } // Insert in the quadtree primitiveEditor->_QuadIterator = PrimitiveQuadGrid.insert (bbox.getMin (), bbox.getMax (), const_cast<IPrimitive*> (primitive)); // Get the linked primitives const IPrimitive* linkedPrimitive = theApp.Config.getLinkedPrimitive (*primitive); // Is this primitive linked with another one ? if (linkedPrimitive) { IPrimitiveEditor *primitiveEditorLinked = getPrimitiveEditor (const_cast<IPrimitive*>(linkedPrimitive)); if (linkedPrimitive->getNumVector () > 0) { bbox.setCenter (points[0]); bbox.extend (linkedPrimitive->getPrimVector ()[0]); // Insert in the quadtree primitiveEditor->_QuadIteratorLink = PrimitiveQuadGrid.insert (bbox.getMin (), bbox.getMax (), CQuadGridEntry (const_cast<IPrimitive*> (primitive), const_cast<IPrimitive*> (linkedPrimitive))); } } } // Validate primitiveEditor->_Channels &= ~QuadTree; } // Logic tree structure ? if (primitiveEditor->_Channels & LogicTreeStruct) { // Add the primitive AddPrimitivesLogicTree (locator, primitiveEditor, toolWnd); // The flag is validated by AddPrimitivesLogicTree } // Logic tree parameters ? if (primitiveEditor->_Channels & LogicTreeParam) { // Update tree item parameters if (toolWnd) toolWnd->updatePrimitive (primitiveEditor->_TreeItem, locator); // Validate primitiveEditor->_Channels &= ~LogicTreeParam; } // Selection ? if (primitiveEditor->_Channels & _SelectionSelectState) { // Update the selection UpdatePrimitiveSelection (primitiveEditor, locator, selectionChanged); // Validate primitiveEditor->_Channels &= ~_SelectionSelectState; } // Remove from the modified list nlassert (primitiveEditor->_Channels == 0); ModifiedPrimitive.erase (primitiveEditor->_ModifiedIterator); primitiveEditor->_ModifiedIterator = ModifiedPrimitive.end (); } /*// Change dialog selection ? if (selectionChanged) { if ( pDlg ) pDlg->changeSelection (Selection); } */ nlassert (ModifiedPrimitive.size ()==0); } }