X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ZLevelsOp.cxx;h=e2b52b87e7cabf3550fa6daa06f25748a4a1f220;hb=3524c916e16d5c5c545c0ddbda4b570139612afe;hp=7d12d15a7a0885f8e3ad4d4df800eb7ec1cadb2a;hpb=a4583c5dce2b21c67fb215131ff02243ca4811f1;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx index 7d12d15a..e2b52b87 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,6 +27,7 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" +#include "HYDROGUI_ListSelector.h" #include @@ -35,28 +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(); - // TODO - abort(); + // Prepare the list of objects + HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList; + + // get the document + Handle(HYDROData_Document) aDoc = doc(); + if( !aDoc.IsNull() ) { + // get active OCC view id + size_t anActiveOCCViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() ); + + // 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_ListModel::Object2Visible( anObject, isVisible ); + } + } + } + + // Show the dialog + 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 ); + + 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