1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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_ProfileDlg.h"
25 #include "HYDROGUI_Module.h"
26 #include "HYDROGUI_Tool.h"
27 #include "HYDROGUI_AISTrihedron.h"
29 #include <CurveCreator_Widget.h>
30 #include <CurveCreator_ICurve.hxx>
31 #include <CurveCreator_Utils.hxx>
33 #include <OCCViewer_ViewPort3d.h>
34 #include <OCCViewer_Utilities.h>
35 #include <OCCViewer_ViewManager.h>
36 #include <OCCViewer_ViewFrame.h>
37 #include <LightApp_Application.h>
39 #include <SUIT_Session.h>
40 #include <SUIT_ResourceMgr.h>
43 #include <QHBoxLayout>
46 #include <QMouseEvent>
48 HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QString& theTitle )
49 : HYDROGUI_ViewerDlg( theModule, theTitle ),
52 QHBoxLayout* aNameLayout = new QHBoxLayout();
53 QLabel* aNameLabel = new QLabel(tr("PROFILE_NAME_TLT"), this);
54 aNameLayout->addWidget(aNameLabel);
55 myName = new QLineEdit(this);
56 aNameLayout->addWidget(myName);
58 addLayout(aNameLayout);
61 CurveCreator_Widget::DisableNewSection | CurveCreator_Widget::DisableDetectionMode |
62 CurveCreator_Widget::DisableClosedSection;
63 QStringList aCoordTitles;
64 aCoordTitles << tr( "U_TITLE" ) << tr( "Z_TITLE" );
65 myEditorWidget = new CurveCreator_Widget( this, NULL, anActionFlags, aCoordTitles );
66 addWidget( myEditorWidget, 3 );
68 myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), this );
69 addWidget( myAddElementBox, 2 );
71 QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
72 anAddElementLayout->setMargin( 0 );
73 anAddElementLayout->setSpacing( 5 );
75 myEditorWidget->setOCCViewer( viewer() );
77 connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
78 connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*, bool) ), this, SLOT( processStartedSubOperation(QWidget*, bool) ) );
79 connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) );
81 myAddElementBox->hide();
84 HYDROGUI_ProfileDlg::~HYDROGUI_ProfileDlg()
88 void HYDROGUI_ProfileDlg::reset()
90 myEditorWidget->reset();
91 myEditorWidget->setActionMode( CurveCreator_Widget::AdditionMode );
94 void HYDROGUI_ProfileDlg::setProfileName( const QString& theName )
96 myName->setText(theName);
99 QString HYDROGUI_ProfileDlg::getProfileName() const
101 return myName->text();
104 void HYDROGUI_ProfileDlg::setProfile( CurveCreator_ICurve* theProfile )
106 myEditorWidget->setCurve( theProfile );
108 // select the single section by default
109 QList<int> aSections;
111 myEditorWidget->setSelectedSections( aSections );
114 QList<int> HYDROGUI_ProfileDlg::getSelectedSections()
116 return myEditorWidget->getSelectedSections();
120 * Redirect the delete action to editor widget
122 void HYDROGUI_ProfileDlg::deleteSelected()
124 myEditorWidget->removeSelected();
128 * Checks whether there are some to delete
130 bool HYDROGUI_ProfileDlg::deleteEnabled()
132 return myEditorWidget->removeEnabled();
135 void HYDROGUI_ProfileDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit )
137 myEditorWidget->setEnabled( false );
139 myAddElementBox->setTitle( theIsEdit ? tr( "EDIT_ELEMENT" ) : tr( "ADD_ELEMENT" ) );
140 QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
141 anAddElementLayout->addWidget( theWidget );
144 myAddElementBox->show();
147 void HYDROGUI_ProfileDlg::processFinishedSubOperation( QWidget* theWidget )
149 myEditorWidget->setEnabled( true );
151 QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
152 anAddElementLayout->removeWidget( theWidget );
155 myAddElementBox->hide();
158 Handle(AIS_Trihedron) HYDROGUI_ProfileDlg::trihedron()
160 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
161 Handle(AIS_Trihedron) aTrihedron =
162 HYDROGUI_AISTrihedron::createTrihedron( aResMgr->doubleValue( "3DViewer", "trihedron_size", viewer()->trihedronSize() ) );