1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_PolylineDlg.h"
25 #include "HYDROGUI_Module.h"
26 #include <CurveCreator_Widget.h>
27 #include <CurveCreator_ICurve.hxx>
29 #include <OCCViewer_ViewModel.h>
32 #include <QHBoxLayout>
35 #include <QScrollArea>
37 HYDROGUI_PolylineDlg::HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QString& theTitle )
38 : HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL)
40 QScrollArea* aScrollView = new QScrollArea( this );
41 aScrollView->setFrameStyle( QFrame::NoFrame );
42 addWidget( aScrollView );
44 QWidget* aContent = new QWidget( aScrollView );
45 QVBoxLayout* aCLayout = new QVBoxLayout( aContent );
46 aCLayout->setMargin( 0 );
48 aScrollView->setWidget( aContent );
49 aScrollView->setWidgetResizable( true );
51 QHBoxLayout* aNameLayout = new QHBoxLayout();
52 QLabel* aNameLabel = new QLabel(tr("POLYLINE_NAME_TLT"), aContent);
53 aNameLayout->addWidget(aNameLabel);
54 myName = new QLineEdit(aContent);
55 aNameLayout->addWidget(myName);
57 aCLayout->addLayout(aNameLayout);
59 myEditorWidget = new CurveCreator_Widget( aContent, NULL );
60 aCLayout->addWidget( myEditorWidget, 3 );
62 myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), aContent );
63 aCLayout->addWidget( myAddElementBox, 2 );
65 QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
66 anAddElementLayout->setMargin( 0 );
67 anAddElementLayout->setSpacing( 5 );
69 connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
70 connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*, bool) ), this, SLOT( processStartedSubOperation(QWidget*, bool) ) );
71 connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) );
73 myAddElementBox->hide();
76 HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg()
80 void HYDROGUI_PolylineDlg::setOCCViewer( OCCViewer_Viewer* theViewer )
82 myEditorWidget->setOCCViewer( theViewer );
85 void HYDROGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit )
87 myEditorWidget->setEnabled( false );
89 myAddElementBox->setTitle( theIsEdit ? tr( "EDIT_ELEMENT" ) : tr( "ADD_ELEMENT" ) );
90 QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
91 anAddElementLayout->addWidget( theWidget );
94 myAddElementBox->show();
97 void HYDROGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget )
99 myEditorWidget->setEnabled( true );
101 QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
102 anAddElementLayout->removeWidget( theWidget );
105 myAddElementBox->hide();
108 void HYDROGUI_PolylineDlg::reset()
112 void HYDROGUI_PolylineDlg::setPolylineName( const QString& theName )
114 myName->setText(theName);
117 QString HYDROGUI_PolylineDlg::getPolylineName() const
119 return myName->text();
122 void HYDROGUI_PolylineDlg::setCurve( CurveCreator_ICurve* theCurve )
124 myEditorWidget->setCurve( theCurve );
127 QList<int> HYDROGUI_PolylineDlg::getSelectedSections()
129 return myEditorWidget->getSelectedSections();
133 * Redirect the delete action to editor widget
135 void HYDROGUI_PolylineDlg::deleteSelected()
137 myEditorWidget->removeSelected();
141 * Checks whether there are some to delete
143 bool HYDROGUI_PolylineDlg::deleteEnabled()
145 return myEditorWidget->removeEnabled();