]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.cxx
Salome HOME
Merge branch 'BR_v14_rc' into BR_SINUSX_FORMAT
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_SplitPolylinesDlg.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_SplitPolylinesDlg.h>
20 #include <HYDROGUI_ObjComboBox.h>
21 #include <HYDROGUI_ObjListBox.h>
22 #include <HYDROGUI_Tool.h>
23 #include <QtxDoubleSpinBox.h>
24 #include <QFrame>
25 #include <QGridLayout>
26 #include <QTabWidget>
27 #include <gp_Pnt2d.hxx>
28
29 HYDROGUI_SplitPolylinesDlg::HYDROGUI_SplitPolylinesDlg( HYDROGUI_Module* theModule, const QString& theTitle )
30 : HYDROGUI_InputPanel( theModule, theTitle )
31 {
32   QFrame* aFrame = new QFrame( mainFrame() );
33   addWidget( aFrame, 1 );
34
35   QGridLayout* aLayout = new QGridLayout( aFrame );
36   aLayout->setMargin( 5 );
37   aLayout->setSpacing( 5 );
38
39   myTab = new QTabWidget( aFrame );
40   aLayout->addWidget( myTab, 0, 0 );
41
42   QFrame* aPointPage = new QFrame();
43   QGridLayout* aPointPageLayout = new QGridLayout( aPointPage );
44
45   myTab->addTab( aPointPage, tr( "BY_POINT" ) );
46
47   QFrame* aToolPage = new QFrame();
48   myTab->addTab( aToolPage, tr( "BY_TOOL" ) );
49
50   QFrame* aSplitPage = new QFrame();
51   myTab->addTab( aSplitPage, tr( "COMPLETE_SPLIT" ) );
52 }
53
54 HYDROGUI_SplitPolylinesDlg::~HYDROGUI_SplitPolylinesDlg()
55 {
56 }
57
58 HYDROGUI_SplitPolylinesDlg::Mode HYDROGUI_SplitPolylinesDlg::GetMode() const
59 {
60   return ( Mode )myTab->currentIndex();
61 }
62
63 Handle( HYDROData_PolylineXY ) HYDROGUI_SplitPolylinesDlg::GetMainPolyline() const
64 {
65   switch( GetMode() )
66   {
67   case ByPoint:
68     return Handle( HYDROData_PolylineXY )::DownCast( myMainPolyline1->GetObject() );
69   case ByTool:
70     return Handle( HYDROData_PolylineXY )::DownCast( myMainPolyline2->GetObject() );
71   default:
72     return Handle( HYDROData_PolylineXY )();
73   }
74 }
75
76 Handle( HYDROData_PolylineXY ) HYDROGUI_SplitPolylinesDlg::GetToolPolyline() const
77 {
78   if( GetMode()==ByTool )
79     return Handle( HYDROData_PolylineXY )::DownCast( myToolPolyline->GetObject() );
80   else
81     return Handle( HYDROData_PolylineXY )();
82 }
83
84 gp_Pnt2d HYDROGUI_SplitPolylinesDlg::GetPoint() const
85 {
86   return gp_Pnt2d( myX->value(), myY->value() );
87 }
88
89 HYDROData_SequenceOfObjects HYDROGUI_SplitPolylinesDlg::GetPolylines() const
90 {
91   if( GetMode()==Split )
92     return myPolylines->selectedObjects();
93   else
94     return HYDROData_SequenceOfObjects();
95 }
96
97 void HYDROGUI_SplitPolylinesDlg::setPolylinesFromSelection()
98 {
99   Handle( HYDROData_Entity ) anObject = HYDROGUI_Tool::GetSelectedObject( module() );
100   if( anObject.IsNull() || anObject->GetKind() != KIND_POLYLINEXY )
101     return;
102
103   QString aName = anObject->GetName();
104   myMainPolyline1->setObjectName( aName );
105   myMainPolyline2->setObjectName( aName );
106   myPolylines->setObjectsFromSelection();
107 }