1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "HYDROGUI_Module.h"
23 #include "HYDROGUI_PolylineOp.h"
24 #include "HYDROGUI_PolylineDlg.h"
25 #include "HYDROGUI_Tool.h"
27 #include <HYDROData_Document.h>
28 #include <HYDROData_Polyline.h>
30 #include <LightApp_Application.h>
31 #include <LightApp_UpdateFlags.h>
34 HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit )
35 : HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit)
37 setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) );
40 HYDROGUI_PolylineOp::~HYDROGUI_PolylineOp()
44 HYDROGUI_InputPanel* HYDROGUI_PolylineOp::createInputPanel() const
46 return new HYDROGUI_PolylineDlg( module(), getName() );
49 bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags,
50 QString& theErrorMsg )
52 HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
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() )
60 Handle(HYDROData_Polyline) aPolylineObj;
62 aPolylineObj = myEditedObject;
65 aPolylineObj = Handle(HYDROData_Polyline)::DownCast( aDocument->CreateObject( KIND_POLYLINE ) );
68 if( aPolylineObj.IsNull() )
72 static int PolylineId = 0;
73 aPolylineObj->SetName( QString( "Polyline_%1" ).arg( QString::number( ++PolylineId ) ) );
76 aPolylineObj->SetVisibility( true );
78 theUpdateFlags = UF_Model | UF_Viewer;
82 void HYDROGUI_PolylineOp::startOperation()
84 HYDROGUI_Operation::startOperation();
86 HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
89 myEditedObject = Handle(HYDROData_Polyline)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
90 if( !myEditedObject.IsNull() )