Salome HOME
lot 10 - warnings for DTM - untested
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_MeasurementToolDlg.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_MeasurementToolDlg.h"
20 #include <QVBoxLayout>
21 #include <QPushButton>
22 #include <QLineEdit>
23
24 #include <OCCViewer_ViewManager.h>
25 #include <OCCViewer_ViewWindow.h>
26 #include <OCCViewer_ViewPort3d.h>
27 #include <CurveCreator_Utils.hxx>
28 #include <SUIT_ViewWindow.h>
29 #include <QMouseEvent>
30 #include <gp_Pnt.hxx>
31 #include <QTableWidget>
32 #include <QGroupBox>
33 #include <QFormLayout>
34 #include <QLabel>
35 #include <QComboBox>
36
37 #include <QRadioButton>
38 #include <QStringList>
39
40
41 HYDROGUI_MeasurementToolDlg::HYDROGUI_MeasurementToolDlg( QWidget* theParent )
42   : QDialog( theParent ), myExit (false)
43 {  
44   QFormLayout* aMLayout = new QFormLayout( this );
45
46   mySwitcherLD = new QRadioButton(tr("LINEAR_DISTANCE"));
47   QRadioButton* aSwitcherPD = new QRadioButton(tr("POLYLINE_DISTANCE"));
48
49   myPolylinesCBox = new QComboBox( this );
50
51   aMLayout->addRow(mySwitcherLD);
52   aMLayout->addRow(aSwitcherPD, myPolylinesCBox);
53
54   myTotalDst = new QLineEdit( this );
55   myTotalDst->setReadOnly(true);
56
57   aMLayout->addRow(new QLabel(tr("TOTAL_DST")), myTotalDst);
58
59   QPushButton* aClearButton = new QPushButton( tr("CLEAR") );
60
61   QPushButton* aCloseButton = new QPushButton( tr("CLOSE"), this );
62
63   QGroupBox* aPolyLenGroup = new QGroupBox(tr("POLYLINES_LENGTH"));
64   QVBoxLayout* aPolyLayout = new QVBoxLayout( aPolyLenGroup );
65
66   aMLayout->addRow(aClearButton, aCloseButton);
67   ////
68   connect( aClearButton, SIGNAL( clicked() ), this, SLOT( onClear () ) );
69   connect( aCloseButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
70   connect( this, SIGNAL( rejected() ), this, SLOT( onExit () ) );
71   connect( mySwitcherLD, SIGNAL( toggled(bool) ), this, SLOT( onSetMode (bool) ) );
72   connect( myPolylinesCBox, SIGNAL( currentIndexChanged(int) ), this, SLOT( onClear () ) );
73
74   mySwitcherLD->setChecked(true);
75
76   setLayout(aMLayout);
77 }
78
79 HYDROGUI_MeasurementToolDlg::~HYDROGUI_MeasurementToolDlg()
80 {
81 }
82
83 void HYDROGUI_MeasurementToolDlg::setTotalDst(QString strVal)
84 {
85   myTotalDst->setText(strVal);
86 }
87
88 bool HYDROGUI_MeasurementToolDlg::IsLDChecked() const
89 {
90   return mySwitcherLD->isChecked();
91 }
92
93 void HYDROGUI_MeasurementToolDlg::setPolylineNames(QStringList thePolyNames)
94 {
95   myPolylinesCBox->clear();
96   foreach (QString aName, thePolyNames)
97     myPolylinesCBox->addItem(aName);
98 }
99
100 int HYDROGUI_MeasurementToolDlg::currentSelectedPolyline() const
101 {
102   return myPolylinesCBox->currentIndex();
103 }
104
105 bool HYDROGUI_MeasurementToolDlg::GetExitFlag() const
106 {
107   return myExit;
108 }
109
110 void HYDROGUI_MeasurementToolDlg::onExit()
111 {
112   myExit = true;
113   emit doExit();
114 }
115
116 void HYDROGUI_MeasurementToolDlg::onClear()
117 {
118   emit clearLine();
119 }
120
121 void HYDROGUI_MeasurementToolDlg::onSetMode(bool mode)
122 {
123   emit onClear();
124   if (mode)
125     myPolylinesCBox->setDisabled(true);
126   else
127     myPolylinesCBox->setDisabled(false);
128 }
129
130
131