#include <SUIT_Study.h>
#include <SUIT_Tools.h>
#include <SUIT_TreeSync.h>
+#include <SUIT_DataObjectIterator.h>
#include <HYDROData_Document.h>
// 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<Handle(HYDROData_Entity)> 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() )
{
// anObjectBrowser->openLevels();
//}
- HYDROGUI_DataModelSync aSync( aNewRootObj );
SUIT_DataObject* aRoot = root();
+
+ if (aRoot)
+ {
+ std::map<std::string, SUIT_DataObject*> entry2ObjNewRoot;
+ SUIT_DataObjectIterator::DetourType dt = SUIT_DataObjectIterator::DepthLeft;
+ for ( SUIT_DataObjectIterator it( aNewRootObj, dt ); it.current(); ++it )
+ {
+ LightApp_DataObject* aCurObjN = dynamic_cast<LightApp_DataObject*>(it.current());
+ if (aCurObjN)
+ entry2ObjNewRoot[aCurObjN->entry().toStdString()] = it.current();
+ }
+
+ for ( SUIT_DataObjectIterator it( aRoot, dt ); it.current(); ++it )
+ {
+ LightApp_DataObject* aCurObjO = dynamic_cast<LightApp_DataObject*>(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<std::string, SUIT_DataObject*> newNode2Entries;
+ for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it )
+ {
+ SUIT_DataObject* cc = *it;
+ LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(cc);
+ newNode2Entries[obj->entry().toStdString()] = cc;
+ newNode->removeChild(cc);
+ }
+ //
+ std::set<SUIT_DataObject*> 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<LightApp_DataObject*>(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<std::string> entries2, entries1;
+ for ( DataObjectList::const_iterator it = newchildren2.begin(); it != newchildren2.end(); ++it )
+ entries2.insert((dynamic_cast<LightApp_DataObject*>(*it))->entry().toStdString());
+ for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it )
+ entries1.insert((dynamic_cast<LightApp_DataObject*>(*it))->entry().toStdString());
+ assert(entries1 == entries2);
+ }
+ }
+ }
+ }
+ }
+
+ HYDROGUI_DataModelSync aSync( aNewRootObj );
bool isNewDoc = aRoot==0;
if( isNewDoc )
aRoot = createRootModuleObject( aStudyRoot );
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<SUIT_DataObject*> 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<SUIT_DataObject*> t2 = where->children().toStdList(); //debug
+ }
+ }
+
+ getApp()->updateObjectBrowser(true);
+
+}
+
Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
{
Handle(HYDROData_StricklerTable) aTable;