1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_ZLevelsOp.h"
21 #include "HYDROGUI_ZLevelsDlg.h"
22 #include "HYDROGUI_DataModel.h"
23 #include "HYDROGUI_Module.h"
24 #include "HYDROGUI_Tool2.h"
25 #include "HYDROGUI_UpdateFlags.h"
26 #include "HYDROGUI_ListSelector.h"
28 #include <HYDROData_Entity.h>
30 #include <LightApp_Application.h>
31 #include <LightApp_UpdateFlags.h>
33 #include <SUIT_Desktop.h>
37 @param theModule the module
39 HYDROGUI_ZLevelsOp::HYDROGUI_ZLevelsOp( HYDROGUI_Module* theModule )
40 : HYDROGUI_Operation( theModule ),
43 setName( tr( "SET_Z_LEVELS" ) );
49 HYDROGUI_ZLevelsOp::~HYDROGUI_ZLevelsOp()
55 void HYDROGUI_ZLevelsOp::startOperation()
57 HYDROGUI_Operation::startOperation();
59 // Prepare the list of objects
60 HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList;
63 Handle(HYDROData_Document) aDoc = doc();
64 if( !aDoc.IsNull() ) {
65 // get active OCC view id
66 size_t anActiveOCCViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() );
69 HYDROData_SequenceOfObjects aSeqOfObjects = aDoc->GetObjectsLayerOrder( Standard_True );
70 HYDROData_SequenceOfObjects::Iterator anIter( aSeqOfObjects );
71 for ( ; anIter.More(); anIter.Next() ) {
72 Handle(HYDROData_Entity) anObject = anIter.Value();
73 if ( !anObject.IsNull() ) {
74 bool isVisible = module()->isObjectVisible( anActiveOCCViewId, anObject );
75 anObject2VisibleList << HYDROGUI_ListModel::Object2Visible( anObject, isVisible );
82 myDlg = new HYDROGUI_ZLevelsDlg( module()->getApp()->desktop(), module() );
83 connect( myDlg, SIGNAL( applyOrderAndClose() ), this, SLOT( onApplyAndClose() ) );
84 connect( myDlg, SIGNAL( applyOrder() ), this, SLOT( onApply() ) );
85 connect( myDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
87 myDlg->setObjects( anObject2VisibleList );
94 bool HYDROGUI_ZLevelsOp::processApply( int& theUpdateFlags,
96 QStringList& theBrowseObjectsEntries )
101 Handle(HYDROData_Document) aDoc = doc();
102 if( !aDoc.IsNull() ) {
103 HYDROGUI_ListModel::ObjectList anObjects = myDlg->getObjects();
104 HYDROData_SequenceOfObjects anOrderedObjects;
105 foreach ( const Handle(HYDROData_Entity) anObject, anObjects ) {
106 anOrderedObjects.Append( anObject );
109 aDoc->SetObjectsLayerOrder( anOrderedObjects );
111 theUpdateFlags = UF_Model | UF_OCCViewer;
121 bool HYDROGUI_ZLevelsOp::isGranted() const
128 void HYDROGUI_ZLevelsOp::processCancel()
137 void HYDROGUI_ZLevelsOp::onApplyAndClose()
139 HYDROGUI_Operation::onApplyAndClose();