Salome HOME
Fix for the bug #255: VTK viewer is not updated after modification of objects.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_PolylineDlg.cxx
index 894bc23a12b9e53099671ab5a55264e20042393e..abbd6ae4850f1c7f001de1df568cbb0b18dd33aa 100755 (executable)
 //
 
 #include "HYDROGUI_PolylineDlg.h"
+
+#include "HYDROGUI_Module.h"
 #include <CurveCreator_Widget.h>
-#include <CurveCreator_Curve.hxx>
+#include <CurveCreator_ICurve.hxx>
+
+#include <OCCViewer_ViewModel.h>
 
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
 
 HYDROGUI_PolylineDlg::HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QString& theTitle )
-: HYDROGUI_InputPanel( theModule, theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL)
 {
-   CurveCreator_Curve *aStaticCurve = NULL;
+  QHBoxLayout* aNameLayout = new QHBoxLayout();
+  QLabel* aNameLabel = new QLabel(tr("POLYLINE_NAME_TLT"), this);
+  aNameLayout->addWidget(aNameLabel);
+  myName = new QLineEdit(this);
+  aNameLayout->addWidget(myName);
+
+  addLayout(aNameLayout);
+
+  myEditorWidget = new CurveCreator_Widget( this, NULL );
+  addWidget( myEditorWidget, 3 );
+
+  myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), this );
+  addWidget( myAddElementBox, 2 );
 
-   aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim3d);
+  QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
+  anAddElementLayout->setMargin( 0 );
+  anAddElementLayout->setSpacing( 5 );
 
-   CurveCreator_Widget *aWidget =
-       new CurveCreator_Widget( this, aStaticCurve);
+  connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
+  connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*, bool) ), this, SLOT( processStartedSubOperation(QWidget*, bool) ) );
+  connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) );
 
-   addWidget( aWidget, 0, 0 );
-   setRowStretch();
+  myAddElementBox->hide();
 }
 
 HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg()
 {
 }
+
+void HYDROGUI_PolylineDlg::setOCCViewer( OCCViewer_Viewer* theViewer )
+{
+  myEditorWidget->setOCCViewer( theViewer );
+}
+
+void HYDROGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit )
+{
+  myEditorWidget->setEnabled( false );
+
+  myAddElementBox->setTitle( theIsEdit ? tr( "EDIT_ELEMENT" ) : tr( "ADD_ELEMENT" ) );
+  QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
+  anAddElementLayout->addWidget( theWidget );
+
+  theWidget->show();
+  myAddElementBox->show();
+}
+
+void HYDROGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget )
+{
+  myEditorWidget->setEnabled( true );
+
+  QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
+  anAddElementLayout->removeWidget( theWidget );
+
+  theWidget->hide();
+  myAddElementBox->hide();
+}
+
+void HYDROGUI_PolylineDlg::reset()
+{
+}
+
+void HYDROGUI_PolylineDlg::setPolylineName( const QString& theName )
+{
+  myName->setText(theName);
+}
+
+QString HYDROGUI_PolylineDlg::getPolylineName() const
+{
+  return myName->text();
+}
+
+void HYDROGUI_PolylineDlg::setCurve( CurveCreator_ICurve* theCurve )
+{
+  myEditorWidget->setCurve( theCurve );
+}
+
+QList<int> HYDROGUI_PolylineDlg::getSelectedSections()
+{
+  return myEditorWidget->getSelectedSections();
+}
+
+/**
+ * Redirect the delete action to editor widget
+ */
+void HYDROGUI_PolylineDlg::deleteSelected()
+{
+  myEditorWidget->removeSelected();
+}
+
+/**
+ * Checks whether there are some to delete
+ */
+bool HYDROGUI_PolylineDlg::deleteEnabled()
+{
+  return myEditorWidget->removeEnabled();
+}