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_MeasurementToolDlg.h"
20 #include <QVBoxLayout>
21 #include <QPushButton>
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>
31 #include <QTableWidget>
33 #include <QFormLayout>
37 #include <QRadioButton>
38 #include <QStringList>
41 HYDROGUI_MeasurementToolDlg::HYDROGUI_MeasurementToolDlg( QWidget* theParent )
42 : QDialog( theParent ), myExit (false)
44 QFormLayout* aMLayout = new QFormLayout( this );
46 mySwitcherLD = new QRadioButton(tr("LINEAR_DISTANCE"));
47 QRadioButton* aSwitcherPD = new QRadioButton(tr("POLYLINE_DISTANCE"));
49 myPolylinesCBox = new QComboBox( this );
51 aMLayout->addRow(mySwitcherLD);
52 aMLayout->addRow(aSwitcherPD, myPolylinesCBox);
54 myTotalDst = new QLineEdit( this );
55 myTotalDst->setReadOnly(true);
57 aMLayout->addRow(new QLabel(tr("TOTAL_DST")), myTotalDst);
59 QPushButton* aClearButton = new QPushButton( tr("CLEAR") );
61 QPushButton* aCloseButton = new QPushButton( tr("CLOSE"), this );
63 QGroupBox* aPolyLenGroup = new QGroupBox(tr("POLYLINES_LENGTH"));
64 QVBoxLayout* aPolyLayout = new QVBoxLayout( aPolyLenGroup );
66 aMLayout->addRow(aClearButton, aCloseButton);
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 () ) );
74 mySwitcherLD->setChecked(true);
79 HYDROGUI_MeasurementToolDlg::~HYDROGUI_MeasurementToolDlg()
83 void HYDROGUI_MeasurementToolDlg::setTotalDst(QString strVal)
85 myTotalDst->setText(strVal);
88 bool HYDROGUI_MeasurementToolDlg::IsLDChecked() const
90 return mySwitcherLD->isChecked();
93 void HYDROGUI_MeasurementToolDlg::setPolylineNames(QStringList thePolyNames)
95 myPolylinesCBox->clear();
96 foreach (QString aName, thePolyNames)
97 myPolylinesCBox->addItem(aName);
100 int HYDROGUI_MeasurementToolDlg::currentSelectedPolyline() const
102 return myPolylinesCBox->currentIndex();
105 bool HYDROGUI_MeasurementToolDlg::GetExitFlag() const
110 void HYDROGUI_MeasurementToolDlg::onExit()
116 void HYDROGUI_MeasurementToolDlg::onClear()
121 void HYDROGUI_MeasurementToolDlg::onSetMode(bool mode)
125 myPolylinesCBox->setDisabled(true);
127 myPolylinesCBox->setDisabled(false);