Salome HOME
latests developments debug and porting Python3
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ZoneSetColorOp.cxx
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_ZoneSetColorOp.h"
20
21 #include "HYDROGUI_Module.h"
22 #include <QColorDialog>
23 #include <LightApp_Application.h>
24 #include <SUIT_Desktop.h>
25 #include <LightApp_UpdateFlags.h>
26 #include <HYDROGUI_UpdateFlags.h>
27 #include <HYDROGUI_Tool2.h>
28 #include <QApplication>
29
30 HYDROGUI_ZoneSetColorOp::HYDROGUI_ZoneSetColorOp( HYDROGUI_Module* theModule )
31   : HYDROGUI_Operation( theModule )
32 {
33   setName( tr( "ZONE_SET_COLOR" ) );
34 }
35
36 HYDROGUI_ZoneSetColorOp::~HYDROGUI_ZoneSetColorOp()
37 {
38 }
39
40 void HYDROGUI_ZoneSetColorOp::startOperation()
41 {
42   HYDROGUI_Operation::startOperation();
43   myZone = Handle(HYDROData_Zone)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
44   if( !myZone.IsNull() )
45     onApply();
46   else
47     onCancel();
48 }
49
50 bool HYDROGUI_ZoneSetColorOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
51   QStringList& theBrowseObjectsEntries )
52 {
53   theUpdateFlags = 0;
54   if(myZone)
55   {
56     QColor aZoneColor = myZone->GetColor(QColor(1,1,1));
57     QApplication::restoreOverrideCursor();
58     QColor aNewColor = QColorDialog::getColor( aZoneColor );
59     myZone->SetColor(aNewColor);         
60     theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
61     return true;
62   }
63   return false;
64 }
65
66