]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #661: implement a transparency feature for land cover maps.
authormkr <mkr@opencascade.com>
Fri, 13 Nov 2015 15:10:45 +0000 (18:10 +0300)
committermkr <mkr@opencascade.com>
Fri, 13 Nov 2015 15:10:45 +0000 (18:10 +0300)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_SetTransparencyOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_SetTransparencyOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_TransparencyDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_TransparencyDlg.h [new file with mode: 0644]
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 061a7632643e1b94780b48af8ef8073f1678931b..40a5fe2f524397395f184791a078e1ec6a11d5e3 100644 (file)
@@ -138,6 +138,8 @@ set(PROJECT_HEADERS
     HYDROGUI_RecognizeContoursDlg.h
     HYDROGUI_RecognizeContoursOp.h
     HYDROGUI_LandCoverColoringOp.h
+    HYDROGUI_SetTransparencyOp.h
+    HYDROGUI_TransparencyDlg.h
 )
 
 QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
@@ -279,6 +281,8 @@ set(PROJECT_SOURCES
     HYDROGUI_RecognizeContoursDlg.cxx
     HYDROGUI_RecognizeContoursOp.cxx
     HYDROGUI_LandCoverColoringOp.cxx
+    HYDROGUI_SetTransparencyOp.cxx
+    HYDROGUI_TransparencyDlg.cxx
 )
 
 add_definitions(
index 05e583ab67e0917e511d2a0b4ff3f6447d39cf0f..f861ac792105ff447509003d9ee25772dd21dba8 100644 (file)
@@ -700,6 +700,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       if ( anIsObjectCanBeColored )
       {
         theMenu->addAction( action( SetColorId ) );
+        if ( anIsLandCoverMap )
+          theMenu->addAction( action( SetTransparencyId ) );
         theMenu->addSeparator();
       }
     } else if ( anAllAreProfiles ) {
index b88069dba3c66c5ea9d318be21c5ea42a63bc148..e15ed250f98b0fc4be70649e3bb401dfeae452ba 100644 (file)
@@ -68,6 +68,7 @@
 #include "HYDROGUI_MergePolylinesOp.h"
 #include "HYDROGUI_SplitPolylinesOp.h"
 #include "HYDROGUI_LandCoverColoringOp.h"
+#include "HYDROGUI_SetTransparencyOp.h"
 
 #include "HYDROGUI_ImportLandCoverMapOp.h"
 
@@ -205,6 +206,7 @@ void HYDROGUI_Module::createActions()
                 SLOT( onDelete() ) );
 
   createAction( SetColorId, "COLOR" );
+  createAction( SetTransparencyId, "TRANSPARENCY" );
   createAction( SetZLevelId, "ZLEVEL" );
   createAction( EditLocalCSId, "EDIT_LOCAL_CS" );
 
@@ -623,6 +625,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case SetColorId:
     anOp = new HYDROGUI_SetColorOp( aModule );
     break;
+  case SetTransparencyId:
+    anOp = new HYDROGUI_SetTransparencyOp( aModule );
+    break;
   case SetZLevelId:
     anOp = new HYDROGUI_ZLevelsOp( aModule );
     break;
index a048c16ff6f9f7a72317068d39c1583f8f27cb1f..22ce77dcb91d2626ca28f331048bfa2ad520ac26 100644 (file)
@@ -100,6 +100,7 @@ enum OperationId
   HideAllId,
 
   SetColorId,
+  SetTransparencyId,
   SetZLevelId,
   EditLocalCSId,
 
diff --git a/src/HYDROGUI/HYDROGUI_SetTransparencyOp.cxx b/src/HYDROGUI/HYDROGUI_SetTransparencyOp.cxx
new file mode 100644 (file)
index 0000000..85d9d68
--- /dev/null
@@ -0,0 +1,98 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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_SetTransparencyOp.h"
+
+#include "HYDROGUI_TransparencyDlg.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <SUIT_Desktop.h>
+
+/**
+  Constructor.
+  @param theModule the module
+*/
+HYDROGUI_SetTransparencyOp::HYDROGUI_SetTransparencyOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule ),
+  myDlg( NULL )
+{
+  setName( tr( "SET_TRANSPARENCY" ) );
+}
+
+/**
+  Destructor.
+*/
+HYDROGUI_SetTransparencyOp::~HYDROGUI_SetTransparencyOp()
+{
+}
+
+void HYDROGUI_SetTransparencyOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  myEditedObject = Handle(HYDROData_LandCoverMap)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+  if ( !myEditedObject.IsNull() )
+  {
+    myDlg = new HYDROGUI_TransparencyDlg( module()->getApp()->desktop() );
+    myDlg->setModal( true );
+    myDlg->setWindowTitle( getName() );
+    myDlg->setTransparency( myEditedObject->GetTransparency() );
+
+    connect( myDlg, SIGNAL( applyAndClose() ), this, SLOT( onApplyAndClose() ) );
+    connect( myDlg, SIGNAL( apply() ), this, SLOT( onApply() ) );
+    connect( myDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
+
+    myDlg->exec();
+  }  
+}
+
+bool HYDROGUI_SetTransparencyOp::processApply( int& theUpdateFlags,
+                                               QString& theErrorMsg,
+                                               QStringList& theBrowseObjectsEntries )
+{
+  if ( !myDlg || myEditedObject.IsNull() )
+    return false;
+  
+  myEditedObject->SetTransparency( myDlg->getTransparency() );
+
+  module()->setIsToUpdate( myEditedObject );
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+  
+  return true;
+}
+
+void HYDROGUI_SetTransparencyOp::processCancel()
+{
+  // Delete the dialog
+  if ( myDlg ) {
+    delete myDlg;
+    myDlg = 0;
+  }
+}
+
+void HYDROGUI_SetTransparencyOp::onApplyAndClose()
+{
+  HYDROGUI_Operation::onApplyAndClose();
+  if ( myDlg )
+    myDlg->reject();
+}
diff --git a/src/HYDROGUI/HYDROGUI_SetTransparencyOp.h b/src/HYDROGUI/HYDROGUI_SetTransparencyOp.h
new file mode 100644 (file)
index 0000000..5cde45b
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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_SETTRANSPARENCYOP_H
+#define HYDROGUI_SETTRANSPARENCYOP_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_LandCoverMap.h>
+
+class HYDROGUI_TransparencyDlg;
+
+class HYDROGUI_SetTransparencyOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_SetTransparencyOp( HYDROGUI_Module* theModule );
+  virtual ~HYDROGUI_SetTransparencyOp( );
+
+protected:
+  virtual void startOperation();
+  virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+                             QStringList& theBrowseObjectsEntries );
+  virtual void processCancel();
+
+protected slots:
+  virtual void onApplyAndClose();
+
+private:
+  HYDROGUI_TransparencyDlg* myDlg;
+
+  Handle(HYDROData_LandCoverMap)  myEditedObject;
+};
+
+#endif
index 5fb6e381f352d5e584d100acef7552cc97a98e64..3d44b09abfe3cf1f018c401178ca1ae49d1a9c74 100644 (file)
@@ -31,6 +31,7 @@
 #include <HYDROData_ShapesGroup.h>
 #include <HYDROData_Stream.h>
 #include <HYDROData_Zone.h>
+#include <HYDROData_LandCoverMap.h>
 
 #include <AIS_Shape.hxx>
 #include <BRep_Builder.hxx>
@@ -516,7 +517,8 @@ void HYDROGUI_Shape::buildShape()
   if ( !myObject.IsNull() )
     myShape->SetOwner( myObject );
 
-  myShape->SetTransparency( 0 );
+  if ( !myObject->IsKind( STANDARD_TYPE(HYDROData_LandCoverMap) ) )
+    myShape->SetTransparency( 0 );
   myShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode );
   myShape->SetSelectionMode( (Standard_Integer)mySelectionMode );
 
diff --git a/src/HYDROGUI/HYDROGUI_TransparencyDlg.cxx b/src/HYDROGUI/HYDROGUI_TransparencyDlg.cxx
new file mode 100644 (file)
index 0000000..ef7406e
--- /dev/null
@@ -0,0 +1,90 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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_TransparencyDlg.h"
+
+#include <QtxDoubleSpinBox.h>
+
+#include <QLabel>
+#include <QLayout>
+#include <QPushButton>
+
+const double RANGE = 1;
+const double STEP = 0.1;
+const double PREC = 1;
+
+/**
+  Constructor.
+  @param theParent the parent widget
+*/
+HYDROGUI_TransparencyDlg::HYDROGUI_TransparencyDlg( QWidget* theParent )
+  : QDialog( theParent )
+{
+  myTransparency = new QtxDoubleSpinBox( 0, RANGE, STEP, PREC, PREC, this );
+  myTransparency->setValue( 0.5 );
+
+  // Apply and close buttons
+  myApplyAndClose = new QPushButton( tr("APPLY_AND_CLOSE") );
+  myApplyAndClose->setDefault( true );
+  myApply = new QPushButton( tr("APPLY") );
+  myClose = new QPushButton( tr("CLOSE") );
+
+  // Layout
+  // Spin-box layout
+  QHBoxLayout* aLayout = new QHBoxLayout();
+  aLayout->setMargin( 5 );
+  aLayout->setSpacing( 5 );
+  aLayout->addWidget( new QLabel( tr( "TRANSPARENCY" ), this ) );
+  aLayout->addWidget( myTransparency );
+  // Apply and close buttons layout
+  QHBoxLayout* aDlgButtonsLayout = new QHBoxLayout(); 
+  aDlgButtonsLayout->addWidget( myApplyAndClose );
+  aDlgButtonsLayout->addWidget( myApply );
+  aDlgButtonsLayout->addWidget( myClose );
+  aDlgButtonsLayout->addStretch();
+  // Main layout
+  QVBoxLayout* aMainLayout = new QVBoxLayout( this );
+  aMainLayout->setMargin( 5 );
+  aMainLayout->setSpacing( 5 );
+  aMainLayout->addLayout( aLayout );
+  aMainLayout->addLayout( aDlgButtonsLayout );
+
+  // Connections
+  connect( myApplyAndClose, SIGNAL( clicked() ), this, SIGNAL( applyAndClose() ) );
+  connect( myApply, SIGNAL( clicked() ), this, SIGNAL( apply() ) );
+  connect( myClose, SIGNAL( clicked() ), this, SLOT( reject() ) );  
+
+  setFixedSize( 300, 90 );
+}
+
+/**
+  Destructor.
+*/
+HYDROGUI_TransparencyDlg::~HYDROGUI_TransparencyDlg()
+{
+}
+
+void HYDROGUI_TransparencyDlg::setTransparency( const double& theValue )
+{
+  myTransparency->setValue( theValue );
+}
+
+double HYDROGUI_TransparencyDlg::getTransparency() const
+{
+  return myTransparency->value();
+}
diff --git a/src/HYDROGUI/HYDROGUI_TransparencyDlg.h b/src/HYDROGUI/HYDROGUI_TransparencyDlg.h
new file mode 100644 (file)
index 0000000..0e26f90
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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_TRANSPARENCYDLG_H
+#define HYDROGUI_TRANSPARENCYDLG_H
+
+#include <QDialog>
+
+class QPushButton;
+class QtxDoubleSpinBox;
+
+class HYDROGUI_TransparencyDlg : public QDialog
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_TransparencyDlg( QWidget* theParent );
+  virtual ~HYDROGUI_TransparencyDlg();
+
+  void setTransparency( const double& theValue );
+  double getTransparency() const;
+
+signals:
+  void applyAndClose();
+  void apply();
+
+private:
+  QtxDoubleSpinBox* myTransparency;
+  QPushButton*      myApplyAndClose;    ///< the apply changes and close dialog button
+  QPushButton*      myApply;            ///< the apply changes button  
+  QPushButton*      myClose;            ///< the close dialog button
+};
+
+#endif
index 4d904c4950c0db0943d3527625bb1033d17d6841..bc48132d84956280752b5665c13476a6db7d0287 100644 (file)
@@ -1060,6 +1060,10 @@ Would you like to remove all references from the image?</translation>
       <source>DSK_COLOR</source>
       <translation>Set object color</translation>
     </message>
+    <message>
+      <source>DSK_TRANSPARENCY</source>
+      <translation>Set object transparency</translation>
+    </message>
     <message>
       <source>DSK_ZLEVEL</source>
       <translation>Change layer order</translation>
@@ -1405,6 +1409,10 @@ Would you like to remove all references from the image?</translation>
       <source>MEN_COLOR</source>
       <translation>Color</translation>
     </message>
+    <message>
+      <source>MEN_TRANSPARENCY</source>
+      <translation>Transparency</translation>
+    </message>
     <message>
       <source>MEN_ZLEVEL</source>
       <translation>Change layer order</translation>
@@ -1706,6 +1714,10 @@ Would you like to remove all references from the image?</translation>
       <source>STB_COLOR</source>
       <translation>Set object color</translation>
     </message>
+    <message>
+      <source>STB_TRANSPARENCY</source>
+      <translation>Set object transparency</translation>
+    </message>
     <message>
       <source>STB_ZLEVEL</source>
       <translation>Change layer order</translation>
@@ -2584,6 +2596,34 @@ file cannot be correctly imported for an Obstacle definition.</translation>
     </message>
   </context>
 
+  <context>
+    <name>HYDROGUI_SetTransparencyOp</name>
+    <message>
+      <source>SET_TRANSPARENCY</source>
+      <translation>Set transparency</translation>
+    </message>
+  </context>
+
+  <context>
+    <name>HYDROGUI_TransparencyDlg</name>
+    <message>
+      <source>TRANSPARENCY</source>
+      <translation>Transparency</translation>
+    </message>
+    <message>
+      <source>APPLY_AND_CLOSE</source>
+      <translation>Apply and Close</translation>
+    </message>
+    <message>
+      <source>APPLY</source>
+      <translation>Apply</translation>
+    </message>
+    <message>
+      <source>CLOSE</source>
+      <translation>Close</translation>
+    </message>
+  </context>
+
   <context>
     <name>HYDROGUI_StreamDlg</name>
     <message>