From: isn Date: Wed, 1 Aug 2018 16:32:35 +0000 (+0300) Subject: refs #1807 X-Git-Tag: HYDRO_V2_0_0~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=976271e3d77e0accd720ed4dbcd877b94c04e35d;p=modules%2Fhydro.git refs #1807 lot 9 reorder level > 1 --- diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 95862a4d..63d4252c 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -59,6 +59,7 @@ #include #include #include +#include #include @@ -305,11 +306,19 @@ void HYDROGUI_DataModel::update( const int theStudyId ) // VISUAL STATES LightApp_DataObject* aVisualStateRootObj = createObject( aNewRootObj, tr( partitionName( KIND_VISUAL_STATE ).toLatin1() ) ); + int aNoStricklerTableObj = 0; + HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN ); - for( ; anIterator.More(); anIterator.Next() ) { + std::vector ents; + + for( ; anIterator.More(); anIterator.Next() ) + ents.push_back(anIterator.Current()); + + for (int i = 0; i< ents.size();i++) + { LightApp_DataObject* obj = 0; - Handle(HYDROData_Entity) anObj = anIterator.Current(); + Handle(HYDROData_Entity) anObj = ents[i]; if ( !anObj.IsNull() ) { @@ -479,8 +488,79 @@ void HYDROGUI_DataModel::update( const int theStudyId ) // anObjectBrowser->openLevels(); //} - HYDROGUI_DataModelSync aSync( aNewRootObj ); SUIT_DataObject* aRoot = root(); + + if (aRoot) + { + std::map entry2ObjNewRoot; + SUIT_DataObjectIterator::DetourType dt = SUIT_DataObjectIterator::DepthLeft; + for ( SUIT_DataObjectIterator it( aNewRootObj, dt ); it.current(); ++it ) + { + LightApp_DataObject* aCurObjN = dynamic_cast(it.current()); + if (aCurObjN) + entry2ObjNewRoot[aCurObjN->entry().toStdString()] = it.current(); + } + + for ( SUIT_DataObjectIterator it( aRoot, dt ); it.current(); ++it ) + { + LightApp_DataObject* aCurObjO = dynamic_cast(it.current()); + if (aCurObjO && aCurObjO->childCount() > 0) + { + std::string entry = aCurObjO->entry().toStdString(); + SUIT_DataObject* newNode = entry2ObjNewRoot[entry]; + if (newNode && aCurObjO->childCount() > 0) + { + DataObjectList newchildren; + newNode->children(newchildren); + //new root - remove children + std::map newNode2Entries; + for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it ) + { + SUIT_DataObject* cc = *it; + LightApp_DataObject* obj = dynamic_cast(cc); + newNode2Entries[obj->entry().toStdString()] = cc; + newNode->removeChild(cc); + } + // + std::set objtemp; + + DataObjectList oldchildren; + aCurObjO->children(oldchildren); + for ( DataObjectList::const_iterator it = oldchildren.begin(); it != oldchildren.end(); ++it ) + { + SUIT_DataObject* old_ch = *it; + std::string entr = dynamic_cast(old_ch)->entry().toStdString(); + if (newNode2Entries.count(entr) > 0) + { + SUIT_DataObject* obj = newNode2Entries[entr]; + newNode->appendChild(obj); + objtemp.insert(obj); + } + } + // + for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it ) + { + SUIT_DataObject* ch = *it; + if (objtemp.count(ch) == 0) + newNode->appendChild(ch); + } + { //IF DEBUG + //add. check + DataObjectList newchildren2; + newNode->children(newchildren2); + std::set entries2, entries1; + for ( DataObjectList::const_iterator it = newchildren2.begin(); it != newchildren2.end(); ++it ) + entries2.insert((dynamic_cast(*it))->entry().toStdString()); + for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it ) + entries1.insert((dynamic_cast(*it))->entry().toStdString()); + assert(entries1 == entries2); + } + } + } + } + } + + HYDROGUI_DataModelSync aSync( aNewRootObj ); bool isNewDoc = aRoot==0; if( isNewDoc ) aRoot = createRootModuleObject( aStudyRoot ); diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 54d2a851..d51503a4 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -1992,6 +1992,67 @@ void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) ); } +bool HYDROGUI_Module::isDraggable( const SUIT_DataObject* what ) const +{ + return true; +} + +bool HYDROGUI_Module::isDropAccepted( const SUIT_DataObject* where ) const +{ + + return true; +} + +void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* where, + const int row, Qt::DropAction action ) +{ + if ( action != Qt::CopyAction && action != Qt::MoveAction ) + return; + + if (row == -1) + return; + + if (where->level() < 2 ) + return; + + DataObjectList::ConstIterator it = what.constBegin(); + for (;it != what.constEnd();++it) + { + if ((*it)->parent() != where) + return; + } + + it = what.constBegin(); + + int i=0; + for (;it != what.constEnd();++it) + { + SUIT_DataObject* objWhat = *it; + + DataObjectList objInSect = where->children(); + + //std::list t1 = where->children().toStdList(); //debug + int ind = objInSect.indexOf(objWhat); + if (ind != -1) + { + HYDROGUI_DataModel* aModel = getDataModel(); + int pos = -1; + if (ind >= row) + { + pos = row + i; + i++; + } + else + pos = row - 1; + where->moveChildPos(objWhat, pos); + //std::list t2 = where->children().toStdList(); //debug + } + } + + getApp()->updateObjectBrowser(true); + +} + Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const { Handle(HYDROData_StricklerTable) aTable; diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index 00c87819..116a351d 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef WIN32 #pragma warning ( default: 4251 ) @@ -224,6 +225,13 @@ public: void clearCache(); + bool isDraggable( const SUIT_DataObject* what ) const; + + bool isDropAccepted( const SUIT_DataObject* where ) const; + + void dropObjects( const DataObjectList& what, SUIT_DataObject* where, + const int row, Qt::DropAction action ); + /** * Returns Strickler table used for Land Cover scalar map coloring in the given view. * @param theViewId the view id