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_LandCoverColoringOp.h"
21 #include "HYDROGUI_Module.h"
22 #include "HYDROGUI_OCCDisplayer.h"
23 #include "HYDROGUI_Operations.h"
24 #include "HYDROGUI_Tool.h"
25 #include "HYDROGUI_UpdateFlags.h"
27 #include <HYDROData_Iterator.h>
28 #include <HYDROData_Bathymetry.h>
29 #include <HYDROData_StricklerTable.h>
31 #include <LightApp_Application.h>
33 #include <OCCViewer_ViewModel.h>
34 #include <OCCViewer_ViewManager.h>
37 HYDROGUI_LandCoverColoringOp::HYDROGUI_LandCoverColoringOp( HYDROGUI_Module* theModule, int theId )
38 : HYDROGUI_Operation( theModule ),
44 case LandCoverScalarMapModeOnId: aName = tr( "LC_SCALARMAP_COLORING_ON" ); break;
45 case LandCoverScalarMapModeOffId: aName = tr( "LC_SCALARMAP_COLORING_OFF" ); break;
51 HYDROGUI_LandCoverColoringOp::~HYDROGUI_LandCoverColoringOp()
55 void HYDROGUI_LandCoverColoringOp::startOperation()
57 HYDROGUI_Operation::startOperation();
59 HYDROGUI_Module* aModule = module();
61 LightApp_Application* anApp = module()->getApp();
62 OCCViewer_ViewManager* aViewManager =
63 dynamic_cast<OCCViewer_ViewManager*>( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
65 size_t aViewId = (size_t)aViewManager->getViewModel();
67 Handle(HYDROData_StricklerTable) aTable;
69 if ( myId == LandCoverScalarMapModeOnId ) {
70 aTable = Handle(HYDROData_StricklerTable)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
71 if ( !aTable.IsNull() ) {
72 aModule->setLandCoverColoringTable( aViewId, aTable );
74 } else if ( myId == LandCoverScalarMapModeOffId ) {
75 aModule->setLandCoversScalarMapModeOff( aViewId );
79 HYDROData_Iterator anIterator( doc(), KIND_BATHYMETRY );
80 for( ; anIterator.More(); anIterator.Next() ) {
81 Handle(HYDROData_Bathymetry) aBath =
82 Handle(HYDROData_Bathymetry)::DownCast( anIterator.Current() );
83 if ( !aBath.IsNull() && aModule->isObjectVisible( aViewId, aBath ) ) {
84 aModule->setObjectVisible( aViewId, aBath, false );
88 aModule->getOCCDisplayer()->SetToUpdateColorScale();
89 aModule->update( UF_OCCViewer );