From 4cd726b073c12ecc98207ad9b6cca7ffe160c04a Mon Sep 17 00:00:00 2001 From: mzn Date: Thu, 5 Dec 2013 13:22:05 +0000 Subject: [PATCH] Bug #191: Show coordinates in profile dialog. --- src/HYDROGUI/HYDROGUI_ProfileDlg.cxx | 47 +++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_ProfileDlg.h | 16 ++++++-- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 28 +++++++------- 3 files changed, 73 insertions(+), 18 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index 7af6f434..4952ce85 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -23,6 +23,8 @@ #include "HYDROGUI_ProfileDlg.h" #include "HYDROGUI_Module.h" +#include "HYDROGUI_Tool.h" + #include #include @@ -35,10 +37,13 @@ #include #include +#include + #include #include #include #include +#include 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( 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(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 diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.h b/src/HYDROGUI/HYDROGUI_ProfileDlg.h index f4c76056..5459a5a6 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.h +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.h @@ -27,11 +27,13 @@ #include -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 diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 751d79b5..e0f239cf 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -169,6 +169,10 @@ does not exist or you have not enough permissions to open it. BREP files (*.brep);;IGES files (*.iges *.igs);;STEP files (*.step *.stp);; All supported formats (*.brep *.iges *.igs *.step *.stp) + + COORDINATES_INFO + X: %1, Y: %2 + @@ -213,10 +217,6 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) REMOVE Remove - - EMPTY_GEOMETRY_OBJECTS - No one geometry object is selected, should be at least one. - @@ -657,8 +657,8 @@ file cannot be correctly imported for a Bathymetry definition. Undo - DSK_UPDATE_OBJECT - Update + DSK_UPDATE_IMAGE + Update image DSK_IMPORT_OBSTACLE_FROM_FILE @@ -869,8 +869,8 @@ file cannot be correctly imported for a Bathymetry definition. Undo - MEN_UPDATE_OBJECT - Update + MEN_UPDATE_IMAGE + Update image MEN_IMPORT_OBSTACLE_FROM_FILE @@ -1057,8 +1057,8 @@ file cannot be correctly imported for a Bathymetry definition. Undo - STB_UPDATE_OBJECT - Update + STB_UPDATE_IMAGE + Update image STB_IMPORT_OBSTACLE_FROM_FILE @@ -1080,10 +1080,6 @@ file cannot be correctly imported for a Bathymetry definition. STB_COLOR Set object color - - COORDINATES_INFO - X: %1, Y: %2 - @@ -1599,6 +1595,10 @@ file cannot be correctly imported for an Obstacle definition. STREAM_HYDRAULIC_AXIS Hydraulic axis + + PROFILES + Profiles: + ADD Add -- 2.39.2