From: mzn Date: Wed, 20 Nov 2013 07:38:17 +0000 (+0000) Subject: Feature #72: remove widgets for the color assignment from the immersible zone’s dialog X-Git-Tag: BR_hydro_v_0_3_1~51 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=16f06b749441da906280085ce23c213b175a49b4;p=modules%2Fhydro.git Feature #72: remove widgets for the color assignment from the immersible zone’s dialog --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 52bc47db..a3666627 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -57,6 +57,8 @@ set(PROJECT_HEADERS HYDROGUI_ImportObstacleFromFileOp.h HYDROGUI_ExportCalculationOp.h HYDROGUI_ObstacleDlg.h + HYDROGUI_SetColorOp.h + HYDROGUI_ColorDlg.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -115,16 +117,14 @@ set(PROJECT_SOURCES HYDROGUI_ImportObstacleFromFileOp.cxx HYDROGUI_ExportCalculationOp.cxx HYDROGUI_ObstacleDlg.cxx + HYDROGUI_SetColorOp.cxx + HYDROGUI_ColorDlg.cxx ) add_definitions( -DHYDROGUI_EXPORTS - -D__WIN32__ - -D__x86__ - -D_WIN32_WINNT=0x0400 - -D__NT__ - -D__OSVERSION__=4 ${CAS_DEFINITIONS} + ${OMNIORB_DEFINITIONS} ${QT_DEFINITIONS} # $(GUI_CXXFLAGS) ${GUI_DEFINITIONS} diff --git a/src/HYDROGUI/HYDROGUI_ColorDlg.cxx b/src/HYDROGUI/HYDROGUI_ColorDlg.cxx new file mode 100644 index 00000000..8a1d0090 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ColorDlg.cxx @@ -0,0 +1,132 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_ColorDlg.h" + +#include "HYDROGUI_ColorWidget.h" +#include "HYDROGUI_Tool.h" + +#include +#include +#include +#include +#include + +HYDROGUI_ColorDlg::HYDROGUI_ColorDlg( QWidget* theParent ) +: QDialog( theParent ) +{ + // Filling color + QFrame* aFillingFrame = new QFrame( this ); + QLabel* aFillingLabel = new QLabel( tr( "FILLING_COLOR" ), aFillingFrame ); + myFillingTransparent = new QRadioButton( tr( "TRANSPARENT" ), aFillingFrame ); + myFillingTransparent->setChecked( true ); + myFillingColor = new QRadioButton( tr( "COLOR" ), aFillingFrame ); + myFillingColorBox = new HYDROGUI_ColorWidget( aFillingFrame ); + + QGridLayout* aFillingLayout = new QGridLayout( aFillingFrame ); + aFillingLayout->setMargin( 5 ); + aFillingLayout->setSpacing( 5 ); + aFillingLayout->addWidget( aFillingLabel, 0, 0, 2, 1 ); + aFillingLayout->addWidget( myFillingTransparent, 0, 1 ); + aFillingLayout->addWidget( myFillingColor, 1, 1 ); + aFillingLayout->addWidget( myFillingColorBox, 1, 2 ); + + // Border color + myBorderColorGroup = new QGroupBox( tr( "BORDER_COLOR" ), this ); + myBorderColorGroup->setCheckable( true ); + + myBorderColorBox = new HYDROGUI_ColorWidget( myBorderColorGroup ); + + QBoxLayout* aBorderColorLayout = new QHBoxLayout( myBorderColorGroup ); + aBorderColorLayout->setMargin( 5 ); + aBorderColorLayout->setSpacing( 5 ); + aBorderColorLayout->addWidget( new QLabel( tr( "COLOR" ), myBorderColorGroup ) ); + aBorderColorLayout->addWidget( myBorderColorBox ); + + // Buttons + QPushButton* anOkButton = new QPushButton( tr( "OK" ), this ); + anOkButton->setDefault( true ); + QPushButton* aCancelButton = new QPushButton( tr( "CANCEL" ), this ); + aCancelButton->setAutoDefault( true ); + + QHBoxLayout* aButtonsLayout = new QHBoxLayout; + aButtonsLayout->setMargin( 5 ); + aButtonsLayout->setSpacing( 5 ); + aButtonsLayout->addWidget( anOkButton ); + aButtonsLayout->addStretch(); + aButtonsLayout->addWidget( aCancelButton ); + + // Common + QVBoxLayout* aMainLayout = new QVBoxLayout( this ); + aMainLayout->setMargin( 5 ); + aMainLayout->setSpacing( 5 ); + + aMainLayout->addWidget( aFillingFrame ); + aMainLayout->addWidget( myBorderColorGroup ); + aMainLayout->addStretch(); + aMainLayout->addLayout( aButtonsLayout ); + + setLayout( aMainLayout ); + + // Connect signals and slots + connect( anOkButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( aCancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +HYDROGUI_ColorDlg::~HYDROGUI_ColorDlg() +{ +} + +void HYDROGUI_ColorDlg::setFillingColor( const QColor& theColor ) +{ + if( theColor.alpha() == 0 ) // transparent + myFillingTransparent->setChecked( true ); + else + myFillingColor->setChecked( true ); + + myFillingColorBox->setColor( theColor ); +} + +QColor HYDROGUI_ColorDlg::getFillingColor() const +{ + QColor aColor( 255, 255, 255, 0 ); // transparent + if( myFillingColor->isChecked() ) + aColor = myFillingColorBox->color(); + return aColor; +} + +void HYDROGUI_ColorDlg::setBorderColor( const QColor& theColor ) +{ + bool isTransparent = theColor.alpha() == 0; + myBorderColorGroup->setChecked( !isTransparent ); + myBorderColorBox->setColor( !isTransparent ? theColor : QColor( Qt::black ) ); +} + +QColor HYDROGUI_ColorDlg::getBorderColor() const +{ + QColor aColor( Qt::transparent ); // transparent + if( myBorderColorGroup->isChecked() ) + aColor = myBorderColorBox->color(); + return aColor; +} + + diff --git a/src/HYDROGUI/HYDROGUI_ColorDlg.h b/src/HYDROGUI/HYDROGUI_ColorDlg.h new file mode 100644 index 00000000..4287e266 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ColorDlg.h @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_COLORDLG_H +#define HYDROGUI_COLORDLG_H + +#include + +class HYDROGUI_ColorWidget; +class QGroupBox; +class QRadioButton; + +class HYDROGUI_ColorDlg : public QDialog +{ + Q_OBJECT + +public: + HYDROGUI_ColorDlg( QWidget* ); + virtual ~HYDROGUI_ColorDlg(); + + void setFillingColor( const QColor& theColor ); + QColor getFillingColor() const; + + void setBorderColor( const QColor& theColor ); + QColor getBorderColor() const; + +protected slots: + +private: + QRadioButton* myFillingTransparent; + QRadioButton* myFillingColor; + HYDROGUI_ColorWidget* myFillingColorBox; + + QGroupBox* myBorderColorGroup; + HYDROGUI_ColorWidget* myBorderColorBox; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx index 697d37f8..fecb29f8 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx @@ -22,7 +22,6 @@ #include "HYDROGUI_ImmersibleZoneDlg.h" -#include "HYDROGUI_ColorWidget.h" #include "HYDROGUI_Tool.h" #include @@ -30,8 +29,6 @@ #include #include #include -#include -#include HYDROGUI_ImmersibleZoneDlg::HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ) @@ -60,43 +57,11 @@ HYDROGUI_ImmersibleZoneDlg::HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModu aPolyLayout->setSpacing( 5 ); aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), aPolylineFrame ) ); aPolyLayout->addWidget( myPolylines ); - - - QFrame* aFillingFrame = new QFrame( aParamGroup ); - QLabel* aFillingLabel = new QLabel( tr( "FILLING_COLOR" ), aFillingFrame ); - myFillingTransparent = new QRadioButton( tr( "TRANSPARENT" ), aFillingFrame ); - myFillingTransparent->setChecked( true ); - myFillingColor = new QRadioButton( tr( "COLOR" ), aFillingFrame ); - myFillingColorBox = new HYDROGUI_ColorWidget( aFillingFrame ); - - QGridLayout* aFillingLayout = new QGridLayout( aFillingFrame ); - aFillingLayout->setMargin( 0 ); - aFillingLayout->setSpacing( 5 ); - aFillingLayout->addWidget( aFillingLabel, 0, 0, 2, 1 ); - aFillingLayout->addWidget( myFillingTransparent, 0, 1 ); - aFillingLayout->addWidget( myFillingColor, 1, 1 ); - aFillingLayout->addWidget( myFillingColorBox, 1, 2 ); - - - myBorderColorGroup = new QGroupBox( tr( "BORDER_COLOR" ), mainFrame() ); - myBorderColorGroup->setCheckable( true ); - - myBorderColorBox = new HYDROGUI_ColorWidget( myBorderColorGroup ); - - QBoxLayout* aBorderColorLayout = new QHBoxLayout( myBorderColorGroup ); - aBorderColorLayout->setMargin( 5 ); - aBorderColorLayout->setSpacing( 5 ); - aBorderColorLayout->addWidget( new QLabel( tr( "COLOR" ), myBorderColorGroup ) ); - aBorderColorLayout->addWidget( myBorderColorBox ); - - + QBoxLayout* aParamLayout = new QVBoxLayout( aParamGroup ); aParamLayout->setMargin( 5 ); aParamLayout->setSpacing( 5 ); aParamLayout->addWidget( aPolylineFrame ); - aParamLayout->addWidget( aFillingFrame ); - aParamLayout->addWidget( myBorderColorGroup ); - QGroupBox* aBathGroup = new QGroupBox( tr( "ZONE_BATHYMETRY" ), mainFrame() ); @@ -119,11 +84,6 @@ HYDROGUI_ImmersibleZoneDlg::HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModu // Connect signals and slots connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) ); - connect( myFillingTransparent, SIGNAL( toggled( bool ) ), this, SLOT( onFillingColorChanged( const bool ) ) ); - connect( myFillingColor, SIGNAL( toggled( bool ) ), this, SLOT( onFillingColorChanged( const bool ) ) ); - connect( myFillingColorBox, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( onFillingColorChanged() ) ); - connect( myBorderColorGroup, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) ); - connect( myBorderColorBox, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( onZoneDefChanged() ) ); } HYDROGUI_ImmersibleZoneDlg::~HYDROGUI_ImmersibleZoneDlg() @@ -139,12 +99,6 @@ void HYDROGUI_ImmersibleZoneDlg::reset() myPolylines->clear(); myBathymetries->clear(); - myFillingTransparent->setChecked( true ); - myFillingColorBox->resetColor(); - - myBorderColorGroup->setChecked( false ); - myBorderColorBox->resetColor(); - blockSignals( isBlocked ); onZoneDefChanged(); @@ -209,67 +163,6 @@ QString HYDROGUI_ImmersibleZoneDlg::getBathymetryName() const return myBathymetries->currentText(); } -void HYDROGUI_ImmersibleZoneDlg::setFillingColor( const QColor& theColor ) -{ - bool isBlocked = blockSignals( true ); - - if( theColor.alpha() == 0 ) // transparent - myFillingTransparent->setChecked( true ); - else - myFillingColor->setChecked( true ); - - myFillingColorBox->setColor( theColor ); - - blockSignals( isBlocked ); - - onZoneDefChanged(); -} - -QColor HYDROGUI_ImmersibleZoneDlg::getFillingColor() const -{ - QColor aColor( 255, 255, 255, 0 ); // transparent - if( myFillingColor->isChecked() ) - aColor = myFillingColorBox->color(); - return aColor; -} - -void HYDROGUI_ImmersibleZoneDlg::setBorderColor( const QColor& theColor ) -{ - bool isBlocked = blockSignals( true ); - - bool isTransparent = theColor.alpha() == 0; - myBorderColorGroup->setChecked( !isTransparent ); - myBorderColorBox->setColor( !isTransparent ? theColor : QColor( Qt::black ) ); - - blockSignals( isBlocked ); - - onZoneDefChanged(); -} - -QColor HYDROGUI_ImmersibleZoneDlg::getBorderColor() const -{ - QColor aColor( Qt::transparent ); // transparent - if( myBorderColorGroup->isChecked() ) - aColor = myBorderColorBox->color(); - return aColor; -} - -void HYDROGUI_ImmersibleZoneDlg::onFillingColorChanged() -{ - if ( !myFillingColor->isChecked() ) - return; - - onZoneDefChanged(); -} - -void HYDROGUI_ImmersibleZoneDlg::onFillingColorChanged( const bool theIsChecked ) -{ - if ( !theIsChecked ) - return; - - onZoneDefChanged(); -} - void HYDROGUI_ImmersibleZoneDlg::onZoneDefChanged() { if ( signalsBlocked() ) @@ -278,5 +171,3 @@ void HYDROGUI_ImmersibleZoneDlg::onZoneDefChanged() QString aPolylineName = getPolylineName(); emit CreatePreview( aPolylineName ); } - - diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h b/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h index 1de986ce..88a42e09 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h @@ -25,12 +25,9 @@ #include "HYDROGUI_InputPanel.h" -class HYDROGUI_ColorWidget; class QComboBox; class QGroupBox; class QLineEdit; -class QListWidget; -class QRadioButton; class HYDROGUI_ImmersibleZoneDlg : public HYDROGUI_InputPanel { @@ -53,19 +50,11 @@ public: void setBathymetryName( const QString& theBathymetry ); QString getBathymetryName() const; - void setFillingColor( const QColor& theColor ); - QColor getFillingColor() const; - - void setBorderColor( const QColor& theColor ); - QColor getBorderColor() const; - signals: void CreatePreview( const QString& thePolylineName ); private slots: void onZoneDefChanged(); - void onFillingColorChanged(); - void onFillingColorChanged( const bool theIsChecked ); private: @@ -74,13 +63,6 @@ private: QComboBox* myPolylines; QComboBox* myBathymetries; - - QRadioButton* myFillingTransparent; - QRadioButton* myFillingColor; - HYDROGUI_ColorWidget* myFillingColorBox; - - QGroupBox* myBorderColorGroup; - HYDROGUI_ColorWidget* myBorderColorBox; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx index 2059057f..d9b072d4 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx @@ -133,9 +133,6 @@ void HYDROGUI_ImmersibleZoneOp::startOperation() } aPanel->setObjectName( anObjectName ); - - aPanel->setFillingColor( aFillingColor ); - aPanel->setBorderColor( aBorderColor ); aPanel->setPolylineNames( aPolylines ); aPanel->setBathymetryNames( aBathymetries ); @@ -217,8 +214,10 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags, aZoneObj->SetName( anObjectName ); - aZoneObj->SetFillingColor( aPanel->getFillingColor() ); - aZoneObj->SetBorderColor( aPanel->getBorderColor() ); + if ( !myIsEdit ) { + aZoneObj->SetFillingColor( HYDROData_ImmersibleZone::DefaultFillingColor() ); + aZoneObj->SetBorderColor( HYDROData_ImmersibleZone::DefaultBorderColor() ); + } aZoneObj->SetPolyline( aZonePolyline ); aZoneObj->SetBathymetry( aZoneBathymetry ); @@ -266,8 +265,15 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName if ( !myViewManager || !myPreviewPrs ) return; - myPreviewPrs->setFillingColor( aPanel->getFillingColor(), false, false ); - myPreviewPrs->setBorderColor( aPanel->getBorderColor(), false, false ); + QColor aFillingColor = HYDROData_ImmersibleZone::DefaultFillingColor(); + QColor aBorderColor = HYDROData_ImmersibleZone::DefaultBorderColor(); + if ( !myEditedObject.IsNull() ) { + aFillingColor = myEditedObject->GetFillingColor(); + aBorderColor = myEditedObject->GetBorderColor(); + } + + myPreviewPrs->setFillingColor( aFillingColor, false, false ); + myPreviewPrs->setBorderColor( aBorderColor, false, false ); myPreviewPrs->setFace( aWire ); } diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 0733dcdc..5af8b51b 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -38,6 +38,7 @@ #include #include +#include #include @@ -218,6 +219,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsRegion = false; bool anIsZone = false; bool anIsObstacle = false; + bool anIsGeomObject = false; // check the selected GEOM objects if ( !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) { @@ -280,6 +282,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, else if( anObject->GetKind() == KIND_OBSTACLE ) anIsObstacle = true; } + + anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject ); } // check the selected partitions @@ -379,6 +383,13 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( LoadVisualStateId ) ); theMenu->addSeparator(); } + + // Add set color action for geometrical objects + if ( anIsGeomObject ) + { + theMenu->addAction( action( SetColorId ) ); + theMenu->addSeparator(); + } } theMenu->addAction( action( DeleteId ) ); diff --git a/src/HYDROGUI/HYDROGUI_SetColorOp.cxx b/src/HYDROGUI/HYDROGUI_SetColorOp.cxx new file mode 100644 index 00000000..245e11c6 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_SetColorOp.cxx @@ -0,0 +1,95 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_SetColorOp.h" + +#include "HYDROGUI_ColorDlg.h" +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_UpdateFlags.h" + +#include +#include + +#include + +HYDROGUI_SetColorOp::HYDROGUI_SetColorOp( HYDROGUI_Module* theModule ) +: HYDROGUI_Operation( theModule ), + myColorDlg( 0 ) +{ + setName( tr( "SET_COLOR" ) ); +} + +HYDROGUI_SetColorOp::~HYDROGUI_SetColorOp() +{ +} + +void HYDROGUI_SetColorOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + // Get the selected object + myEditedObject = Handle(HYDROData_Object)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + + if( !myEditedObject.IsNull() ) { + // Get colors from the object + QColor aFillingColor = myEditedObject->GetFillingColor(); + QColor aBorderColor = myEditedObject->GetBorderColor(); + + // Create color dialog + myColorDlg = new HYDROGUI_ColorDlg( module()->getApp()->desktop() ); + myColorDlg->setModal( true ); + myColorDlg->setWindowTitle( getName() ); + + // Set colors from the object + myColorDlg->setFillingColor( aFillingColor ); + myColorDlg->setBorderColor( aBorderColor ); + + // Connect the dialog to operation slots + connect( myColorDlg, SIGNAL( accepted() ), this, SLOT( onApply() ) ); + connect( myColorDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) ); + + // Show the dialog + myColorDlg->exec(); + } +} + +bool HYDROGUI_SetColorOp::processApply( int& theUpdateFlags, + QString& theErrorMsg ) +{ + bool anIsOk = false; + + if ( myColorDlg && myEditedObject ) { + QColor aFillingColor = myColorDlg->getFillingColor(); + QColor aBorderColor = myColorDlg->getBorderColor(); + + myEditedObject->SetFillingColor( aFillingColor ); + myEditedObject->SetBorderColor( aBorderColor ); + + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced; + + anIsOk = true; + } + + return anIsOk; +} diff --git a/src/HYDROGUI/HYDROGUI_SetColorOp.h b/src/HYDROGUI/HYDROGUI_SetColorOp.h new file mode 100644 index 00000000..10d02b99 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_SetColorOp.h @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_SETCOLOROP_H +#define HYDROGUI_SETCOLOROP_H + +#include "HYDROGUI_Operation.h" + +#include + +class HYDROGUI_ColorDlg; + +class HYDROGUI_SetColorOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_SetColorOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_SetColorOp(); + +protected: + virtual void startOperation(); + + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + +private: + HYDROGUI_ColorDlg* myColorDlg; + + Handle(HYDROData_Object) myEditedObject; +}; + +#endif \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index a54e7ccd..1491564f 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -230,8 +230,11 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) myTopoShape = anObstacle->GetShape3D(); myDisplayMode = AIS_Shaded; - //TODO colors should be defined in another way - setFillingColor( Qt::green, false, false ); + QColor aFillingColor = anObstacle->GetFillingColor(); + QColor aBorderColor = anObstacle->GetBorderColor(); + + setFillingColor( aFillingColor, false, false ); + setBorderColor( aBorderColor, false, false ); buildShape(); updateShape( false, false ); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 24e8dd5a..408e0518 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -588,6 +588,10 @@ file cannot be correctly imported for a Bathymetry definition. DSK_CREATE_CYLINDER Create cylinder obstacle + + DSK_COLOR + Set object color + MEN_CREATE_CALCULATION Create new calculation case @@ -740,6 +744,10 @@ file cannot be correctly imported for a Bathymetry definition. MEN_CREATE_CYLINDER Cylinder + + MEN_COLOR + Color + STB_CREATE_CALCULATION Create new calculation case @@ -884,6 +892,10 @@ file cannot be correctly imported for a Bathymetry definition. STB_CREATE_CYLINDER Create cylinder obstacle + + STB_COLOR + Set object color + @@ -1060,26 +1072,10 @@ file cannot be correctly imported for a Bathymetry definition. HYDROGUI_ImmersibleZoneDlg - - BORDER_COLOR - Border - - - COLOR - Color - - - FILLING_COLOR - Filling color - NAME Name - - TRANSPARENT - Transparent - ZONE_BATHYMETRY Bathymetry @@ -1160,6 +1156,10 @@ file cannot be correctly imported for an Obstacle definition. HYDROGUI_ObstacleDlg + + DEFAULT_OBSTACLE_NAME + Obstacle + GET_SHAPE_FROM_FILE Get shape from file @@ -1206,4 +1206,32 @@ file cannot be correctly imported for an Obstacle definition. + + HYDROGUI_SetColorOp + + SET_COLOR + Set color + + + + + HYDROGUI_ColorDlg + + COLOR + Color + + + FILLING_COLOR + Filling color + + + TRANSPARENT + Transparent + + + BORDER_COLOR + Border + + +