]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_PolylineOp.cxx
Salome HOME
1) Image name
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_PolylineOp.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #include "HYDROGUI_Module.h"
23 #include "HYDROGUI_PolylineOp.h"
24 #include "HYDROGUI_PolylineDlg.h"
25 #include "HYDROGUI_Tool.h"
26
27 #include <HYDROData_Document.h>
28 #include <HYDROData_Polyline.h>
29
30 #include <LightApp_Application.h>
31 #include <LightApp_UpdateFlags.h>
32
33
34 HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit )
35 : HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit)
36 {
37   setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) );
38 }
39
40 HYDROGUI_PolylineOp::~HYDROGUI_PolylineOp()
41 {
42 }
43
44 HYDROGUI_InputPanel* HYDROGUI_PolylineOp::createInputPanel() const
45 {
46   return new HYDROGUI_PolylineDlg( module(), getName() );
47 }
48
49 bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags,
50                                         QString& theErrorMsg )
51 {
52   HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
53
54   int aStudyId = module()->getStudyId();
55   bool aHasDoc = HYDROData_Document::HasDocument(aStudyId);
56   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
57   if( aDocument.IsNull() )
58     return false;
59
60   Handle(HYDROData_Polyline) aPolylineObj;
61   if( myIsEdit ){
62     aPolylineObj = myEditedObject;
63   }
64   else{
65     aPolylineObj = Handle(HYDROData_Polyline)::DownCast( aDocument->CreateObject( KIND_POLYLINE ) );
66   }
67
68   if( aPolylineObj.IsNull() )
69     return false;
70
71   if( !myIsEdit ){
72     static int PolylineId = 0;
73     aPolylineObj->SetName( QString( "Polyline_%1" ).arg( QString::number( ++PolylineId ) ) );
74   }
75
76   aPolylineObj->SetVisibility( true );
77
78   theUpdateFlags = UF_Model | UF_Viewer;
79   return true;
80 }
81
82 void HYDROGUI_PolylineOp::startOperation()
83 {
84   HYDROGUI_Operation::startOperation();
85
86   HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
87   aPanel->reset();
88
89   myEditedObject = Handle(HYDROData_Polyline)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
90   if( !myEditedObject.IsNull() )
91   {
92   }
93 }