]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Bug #191: Show coordinates in profile dialog.
authormzn <mzn@opencascade.com>
Thu, 5 Dec 2013 13:22:05 +0000 (13:22 +0000)
committermzn <mzn@opencascade.com>
Thu, 5 Dec 2013 13:22:05 +0000 (13:22 +0000)
src/HYDROGUI/HYDROGUI_ProfileDlg.cxx
src/HYDROGUI/HYDROGUI_ProfileDlg.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 7af6f434382f57534d4831d73bce0a57b3c698bd..4952ce856ee8d8151e64165914d2bfda6b3d5497 100644 (file)
@@ -23,6 +23,8 @@
 #include "HYDROGUI_ProfileDlg.h"
 
 #include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+
 #include <CurveCreator_Widget.h>
 #include <CurveCreator_ICurve.hxx>
 
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
 
+#include <GEOMUtils.hxx>
+
 #include <QGroupBox>
 #include <QHBoxLayout>
 #include <QLabel>
 #include <QLineEdit>
+#include <QMouseEvent>
 
 HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QString& theTitle )
 : HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL)
@@ -93,6 +98,23 @@ HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QStr
   connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) );
 
   myAddElementBox->hide();
+
+  // Coordinates
+  connect( myViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
+           this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+  if ( aViewWin ) {
+    OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWin );
+    if ( aViewFrame && aViewFrame->getViewPort() ) {
+      aViewFrame->getViewPort()->installEventFilter( this );
+    }
+  }
+
+  myCoordLabel = new QLabel( this );
+  QHBoxLayout* aCoordLayout = new QHBoxLayout();
+  aCoordLayout->addWidget( myCoordLabel );
+  aCoordLayout->addStretch();
+
+  addLayout( aCoordLayout );
 }
 
 HYDROGUI_ProfileDlg::~HYDROGUI_ProfileDlg()
@@ -173,3 +195,28 @@ void HYDROGUI_ProfileDlg::processFinishedSubOperation( QWidget* theWidget )
   theWidget->hide();
   myAddElementBox->hide();
 }
+
+void HYDROGUI_ProfileDlg::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
+{
+  OCCViewer_ViewWindow* anOCCViewWindow = 
+    dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
+  if ( anOCCViewWindow && anOCCViewWindow->getViewPort() ) {
+    gp_Pnt aPnt = GEOMUtils::ConvertClickToPoint( 
+      theEvent->x(), theEvent->y(), anOCCViewWindow->getViewPort()->getView() );
+
+    // Show the coordinates
+    QString aX = HYDROGUI_Tool::GetCoordinateString( aPnt.X() );
+    QString anY = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
+    myCoordLabel->setText( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );
+  }
+}
+
+bool HYDROGUI_ProfileDlg::eventFilter( QObject* theObj, QEvent* theEvent )
+{
+  if ( theObj->inherits( "OCCViewer_ViewPort" ) && 
+       theEvent->type() == QEvent::Leave ) {
+    myCoordLabel->clear();
+  }
+
+  return HYDROGUI_InputPanel::eventFilter( theObj, theEvent );
+}
\ No newline at end of file
index f4c760562f8c7054bc9e51c2041544a4120d6965..5459a5a64d2009eaf1ac659c56fe25aed0e446ad 100644 (file)
 
 #include <AIS_InteractiveContext.hxx>
 
-class QLineEdit;
 class CurveCreator_Widget;
 class CurveCreator_ICurve;
 class OCCViewer_ViewManager;
+class SUIT_ViewWindow;
 class QGroupBox;
+class QLineEdit;
+class QLabel;
 
 class HYDROGUI_ProfileDlg : public HYDROGUI_InputPanel
 {
@@ -56,10 +58,15 @@ public:
   void  deleteSelected();
   bool  deleteEnabled();
 
+protected:
+  virtual bool eventFilter( QObject*, QEvent* );
+
 protected slots:
   void processStartedSubOperation( QWidget* );
   void processFinishedSubOperation( QWidget* );
 
+  void onMouseMove( SUIT_ViewWindow*, QMouseEvent* );
+
 signals:
   void                  createPreview( QString );
   void                  selectionChanged();
@@ -67,10 +74,11 @@ signals:
   void                  subOperationStarted(QWidget*);
   void                  subOperationFinished(QWidget*);
 private:
-  QLineEdit*            myName;
-  CurveCreator_Widget*  myEditorWidget;
-  QGroupBox*            myAddElementBox;
+  QLineEdit*             myName;
+  CurveCreator_Widget*   myEditorWidget;
+  QGroupBox*             myAddElementBox;
   OCCViewer_ViewManager* myViewManager;
+  QLabel*                myCoordLabel;
 };
 
 #endif
index 751d79b516ccdd7d95c1aa6d0966b4be49dc74d4..e0f239cfe57d5d7281dbbef6298526be432fbda7 100644 (file)
@@ -169,6 +169,10 @@ does not exist or you have not enough permissions to open it.</translation>
       <translation>BREP files (*.brep);;IGES files (*.iges *.igs);;STEP files (*.step *.stp);;
 All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
     </message>
+    <message>
+      <source>COORDINATES_INFO</source>
+      <translation>X: %1, Y: %2</translation>
+    </message>
   </context>
 
   <context>
@@ -213,10 +217,6 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>REMOVE</source>
       <translation>Remove</translation>
     </message>
-    <message>
-      <source>EMPTY_GEOMETRY_OBJECTS</source>
-      <translation>No one geometry object is selected, should be at least one.</translation>
-    </message>
   </context>
 
   <context>
@@ -657,8 +657,8 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <translation>Undo</translation>
     </message>
     <message>
-      <source>DSK_UPDATE_OBJECT</source>
-      <translation>Update</translation>
+      <source>DSK_UPDATE_IMAGE</source>
+      <translation>Update image</translation>
     </message>
     <message>
       <source>DSK_IMPORT_OBSTACLE_FROM_FILE</source>
@@ -869,8 +869,8 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <translation>Undo</translation>
     </message>
     <message>
-      <source>MEN_UPDATE_OBJECT</source>
-      <translation>Update</translation>
+      <source>MEN_UPDATE_IMAGE</source>
+      <translation>Update image</translation>
     </message>
     <message>
       <source>MEN_IMPORT_OBSTACLE_FROM_FILE</source>
@@ -1057,8 +1057,8 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <translation>Undo</translation>
     </message>
     <message>
-      <source>STB_UPDATE_OBJECT</source>
-      <translation>Update</translation>
+      <source>STB_UPDATE_IMAGE</source>
+      <translation>Update image</translation>
     </message>
     <message>
       <source>STB_IMPORT_OBSTACLE_FROM_FILE</source>
@@ -1080,10 +1080,6 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>STB_COLOR</source>
       <translation>Set object color</translation>
     </message>
-    <message>
-      <source>COORDINATES_INFO</source>
-      <translation>X: %1, Y: %2</translation>
-    </message>
   </context>
   
   <context>
@@ -1599,6 +1595,10 @@ file cannot be correctly imported for an Obstacle definition.</translation>
       <source>STREAM_HYDRAULIC_AXIS</source>
       <translation>Hydraulic axis</translation>
     </message>
+    <message>
+      <source>PROFILES</source>
+      <translation>Profiles:</translation>
+    </message>
     <message>
       <source>ADD</source>
       <translation>Add</translation>