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_PolylineDlg.h"
21 #include "HYDROGUI_Module.h"
22 #include <CurveCreator_Widget.h>
23 #include <CurveCreator_ICurve.hxx>
25 #include <OCCViewer_ViewModel.h>
28 #include <QHBoxLayout>
31 #include <QScrollArea>
33 HYDROGUI_PolylineDlg::HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QString& theTitle )
34 : HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL)
36 QScrollArea* aScrollView = new QScrollArea( this );
37 aScrollView->setFrameStyle( QFrame::NoFrame );
38 addWidget( aScrollView );
40 QWidget* aContent = new QWidget( aScrollView );
41 QVBoxLayout* aCLayout = new QVBoxLayout( aContent );
42 aCLayout->setMargin( 0 );
44 aScrollView->setWidget( aContent );
45 aScrollView->setWidgetResizable( true );
47 QHBoxLayout* aNameLayout = new QHBoxLayout();
48 QLabel* aNameLabel = new QLabel(tr("POLYLINE_NAME_TLT"), aContent);
49 aNameLayout->addWidget(aNameLabel);
50 myName = new QLineEdit(aContent);
51 aNameLayout->addWidget(myName);
53 aCLayout->addLayout(aNameLayout);
55 myEditorWidget = new CurveCreator_Widget( aContent, NULL );
56 aCLayout->addWidget( myEditorWidget, 3 );
58 myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), aContent );
59 aCLayout->addWidget( myAddElementBox, 2 );
61 QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
62 anAddElementLayout->setMargin( 0 );
63 anAddElementLayout->setSpacing( 5 );
65 connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
66 connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*, bool) ), this, SLOT( processStartedSubOperation(QWidget*, bool) ) );
67 connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) );
69 myAddElementBox->hide();
72 HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg()
76 void HYDROGUI_PolylineDlg::setOCCViewer( OCCViewer_Viewer* theViewer )
78 myEditorWidget->setOCCViewer( theViewer );
81 void HYDROGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit )
83 myEditorWidget->setEnabled( false );
85 myAddElementBox->setTitle( theIsEdit ? tr( "EDIT_ELEMENT" ) : tr( "ADD_ELEMENT" ) );
86 QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
87 anAddElementLayout->addWidget( theWidget );
90 myAddElementBox->show();
93 void HYDROGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget )
95 myEditorWidget->setEnabled( true );
97 QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
98 anAddElementLayout->removeWidget( theWidget );
101 myAddElementBox->hide();
104 void HYDROGUI_PolylineDlg::reset()
108 void HYDROGUI_PolylineDlg::setPolylineName( const QString& theName )
110 myName->setText(theName);
113 QString HYDROGUI_PolylineDlg::getPolylineName() const
115 return myName->text();
118 void HYDROGUI_PolylineDlg::setCurve( CurveCreator_ICurve* theCurve )
120 myEditorWidget->setCurve( theCurve );
123 QList<int> HYDROGUI_PolylineDlg::getSelectedSections()
125 return myEditorWidget->getSelectedSections();
129 * Redirect the delete action to editor widget
131 void HYDROGUI_PolylineDlg::deleteSelected()
133 myEditorWidget->removeSelected();
137 * Checks whether there are some to delete
139 bool HYDROGUI_PolylineDlg::deleteEnabled()
141 return myEditorWidget->removeEnabled();