Salome HOME
refs #1813 ... lot 14 combined commit : parts : 1 - 16
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_SetBoundaryTypePolygonOp.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_SetBoundaryTypePolygonOp.h"
20
21 #include "HYDROGUI_DataModel.h"
22 #include "HYDROGUI_Module.h"
23
24 #include <HYDROData_Object.h>
25 #include <HYDROData_BCPolygon.h>
26
27 #include <LightApp_Application.h>
28 #include <LightApp_UpdateFlags.h>
29
30 #include <SUIT_Desktop.h>
31 #include <HYDROGUI_Tool2.h>
32 #include <HYDROGUI_SetBoundaryTypePolygonDlg.h>
33 #include <SUIT_MessageBox.h>
34 #include <HYDROGUI_UpdateFlags.h>
35
36 HYDROGUI_SetBoundaryTypePolygonOp::HYDROGUI_SetBoundaryTypePolygonOp( HYDROGUI_Module* theModule )
37 : HYDROGUI_Operation( theModule ),
38   mySetBTDlg( 0 )
39 {
40   setName( tr( "SET_BOUNDARY_TYPE_POLYGON" ) );
41 }
42
43 HYDROGUI_SetBoundaryTypePolygonOp::~HYDROGUI_SetBoundaryTypePolygonOp()
44 {
45 }
46
47 void HYDROGUI_SetBoundaryTypePolygonOp::startOperation()
48 {
49   HYDROGUI_Operation::startOperation();
50
51   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects(module());
52   myBCP = Handle(HYDROData_BCPolygon)::DownCast(aSeq(1)); 
53
54   int bType = myBCP->GetBoundaryType();
55
56   mySetBTDlg = new HYDROGUI_SetBoundaryTypePolygonDlg( module()->getApp()->desktop(), bType );
57   mySetBTDlg->setModal( true );
58   mySetBTDlg->setWindowTitle(getName());
59
60   // Connect the dialog to operation slots
61   connect( mySetBTDlg, SIGNAL( accepted() ), this, SLOT( onApply()  ) );
62   connect( mySetBTDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
63   
64   mySetBTDlg->exec();
65 }
66
67  bool HYDROGUI_SetBoundaryTypePolygonOp::processApply( int& theUpdateFlags,
68                                         QString& theErrorMsg,
69                                         QStringList& theBrowseObjectsEntries )
70 {
71   if ( !mySetBTDlg )
72     return false;
73
74   int aType = mySetBTDlg->GetCurrentType();
75
76   myBCP->SetBoundaryType( aType + 1 );
77   myBCP->SetFillingColor( myBCP->DefaultFillingColor() );
78   myBCP->SetBorderColor( myBCP->DefaultBorderColor() );
79     
80   module()->setIsToUpdate( myBCP );
81
82   theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced;  
83
84   return true;
85 }