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_SplitPolylinesDlg.h>
20 #include <HYDROGUI_ObjComboBox.h>
21 #include <HYDROGUI_ObjListBox.h>
22 #include <HYDROGUI_Tool.h>
23 #include <QtxDoubleSpinBox.h>
25 #include <QGridLayout>
27 #include <gp_Pnt2d.hxx>
29 HYDROGUI_SplitPolylinesDlg::HYDROGUI_SplitPolylinesDlg( HYDROGUI_Module* theModule, const QString& theTitle )
30 : HYDROGUI_InputPanel( theModule, theTitle )
32 QFrame* aFrame = new QFrame( mainFrame() );
33 addWidget( aFrame, 1 );
35 QGridLayout* aLayout = new QGridLayout( aFrame );
36 aLayout->setMargin( 5 );
37 aLayout->setSpacing( 5 );
39 myTab = new QTabWidget( aFrame );
40 aLayout->addWidget( myTab, 0, 0 );
42 QFrame* aPointPage = new QFrame();
43 QGridLayout* aPointPageLayout = new QGridLayout( aPointPage );
45 myTab->addTab( aPointPage, tr( "BY_POINT" ) );
47 QFrame* aToolPage = new QFrame();
48 myTab->addTab( aToolPage, tr( "BY_TOOL" ) );
50 QFrame* aSplitPage = new QFrame();
51 myTab->addTab( aSplitPage, tr( "COMPLETE_SPLIT" ) );
54 HYDROGUI_SplitPolylinesDlg::~HYDROGUI_SplitPolylinesDlg()
58 HYDROGUI_SplitPolylinesDlg::Mode HYDROGUI_SplitPolylinesDlg::GetMode() const
60 return ( Mode )myTab->currentIndex();
63 Handle( HYDROData_PolylineXY ) HYDROGUI_SplitPolylinesDlg::GetMainPolyline() const
68 return Handle( HYDROData_PolylineXY )::DownCast( myMainPolyline1->GetObject() );
70 return Handle( HYDROData_PolylineXY )::DownCast( myMainPolyline2->GetObject() );
72 return Handle( HYDROData_PolylineXY )();
76 Handle( HYDROData_PolylineXY ) HYDROGUI_SplitPolylinesDlg::GetToolPolyline() const
78 if( GetMode()==ByTool )
79 return Handle( HYDROData_PolylineXY )::DownCast( myToolPolyline->GetObject() );
81 return Handle( HYDROData_PolylineXY )();
84 gp_Pnt2d HYDROGUI_SplitPolylinesDlg::GetPoint() const
86 return gp_Pnt2d( myX->value(), myY->value() );
89 HYDROData_SequenceOfObjects HYDROGUI_SplitPolylinesDlg::GetPolylines() const
91 if( GetMode()==Split )
92 return myPolylines->selectedObjects();
94 return HYDROData_SequenceOfObjects();
97 void HYDROGUI_SplitPolylinesDlg::setPolylinesFromSelection()
99 Handle( HYDROData_Entity ) anObject = HYDROGUI_Tool::GetSelectedObject( module() );
100 if( anObject.IsNull() || anObject->GetKind() != KIND_POLYLINEXY )
103 QString aName = anObject->GetName();
104 myMainPolyline1->setObjectName( aName );
105 myMainPolyline2->setObjectName( aName );
106 myPolylines->setObjectsFromSelection();