X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ZLevelsOp.cxx;h=3f7c1eaf732e55ca72ae2f5dbaee49911b2edf11;hb=81c9f5cdf82909d0aebd2c491c50fa7516cc80b7;hp=61f318b9c8c8c29eda6e208350db507de0e5ad08;hpb=d31e2e7449fe14654198b48e2fe2c1e24f973009;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx index 61f318b9..3f7c1eaf 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx @@ -27,6 +27,7 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" +#include "HYDROGUI_ListSelector.h" #include @@ -35,56 +36,103 @@ #include +/** + Constructor. + @param theModule the module +*/ HYDROGUI_ZLevelsOp::HYDROGUI_ZLevelsOp( HYDROGUI_Module* theModule ) : HYDROGUI_Operation( theModule ), - myZLevelsDlg( NULL ) + myDlg( NULL ) { setName( tr( "SET_Z_LEVELS" ) ); } +/** + Destructor. +*/ HYDROGUI_ZLevelsOp::~HYDROGUI_ZLevelsOp() { } +/** +*/ void HYDROGUI_ZLevelsOp::startOperation() { HYDROGUI_Operation::startOperation(); - HYDROGUI_ZLevelsModel::Object2VisibleList anObject2VisibleList; + // Prepare the list of objects + HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList; - // Get the document + // get the document Handle(HYDROData_Document) aDoc = doc(); if( !aDoc.IsNull() ) { - // Get active OCC view id + // get active OCC view id size_t anActiveOCCViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() ); - // Get objects list + // get objects list HYDROData_SequenceOfObjects aSeqOfObjects = aDoc->GetObjectsLayerOrder( Standard_True ); HYDROData_SequenceOfObjects::Iterator anIter( aSeqOfObjects ); for ( ; anIter.More(); anIter.Next() ) { Handle(HYDROData_Entity) anObject = anIter.Value(); if ( !anObject.IsNull() ) { bool isVisible = module()->isObjectVisible( anActiveOCCViewId, anObject ); - anObject2VisibleList << HYDROGUI_ZLevelsModel::Object2Visible( anObject, isVisible ); + anObject2VisibleList << HYDROGUI_ListModel::Object2Visible( anObject, isVisible ); } } } // Show the dialog - myZLevelsDlg = new HYDROGUI_ZLevelsDlg( module()->getApp()->desktop() ); - myZLevelsDlg->setModal( true ); - myZLevelsDlg->setObjects( anObject2VisibleList ); - - //TODO: reimplement - connect( myZLevelsDlg, SIGNAL( accepted() ), this, SLOT( commit() ) ); - connect( myZLevelsDlg, SIGNAL( rejected() ), this, SLOT( abort() ) ); + if ( !myDlg ) { + myDlg = new HYDROGUI_ZLevelsDlg( module()->getApp()->desktop(), module() ); + connect( myDlg, SIGNAL( applyOrder() ), this, SLOT( onApply() ) ); + connect( myDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) ); + } + myDlg->setObjects( anObject2VisibleList ); - myZLevelsDlg->exec(); + myDlg->exec(); } +/** +*/ bool HYDROGUI_ZLevelsOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { - // TODO - return false; + bool aRes = false; + + if ( myDlg ) { + Handle(HYDROData_Document) aDoc = doc(); + if( !aDoc.IsNull() ) { + HYDROGUI_ListModel::ObjectList anObjects = myDlg->getObjects(); + HYDROData_SequenceOfObjects anOrderedObjects; + foreach ( const Handle(HYDROData_Entity) anObject, anObjects ) { + anOrderedObjects.Append( anObject ); + } + + aDoc->SetObjectsLayerOrder( anOrderedObjects ); + + theUpdateFlags = UF_Model | UF_OCCViewer; + aRes = true; + } + } + + return aRes; +} + +/** +*/ +bool HYDROGUI_ZLevelsOp::isGranted() const +{ + return true; } + +/** +*/ +void HYDROGUI_ZLevelsOp::processCancel() +{ + // Delete the dialog + if ( myDlg ) { + delete myDlg; + myDlg = 0; + } +} \ No newline at end of file