From 779d1c3e386947b6fb1f4807aacfaddeefe7f765 Mon Sep 17 00:00:00 2001 From: ouv Date: Wed, 4 Sep 2013 12:47:44 +0000 Subject: [PATCH] HYDRO bug 15: Labels to distinguish the imported and reference images. --- src/HYDROGUI/HYDROGUI_ImportImageOp.cxx | 18 +++++++--- src/HYDROGUI/HYDROGUI_PrsImage.cxx | 40 +++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_PrsImage.h | 4 +++ src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 8 +++++ 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index f2835a47..52ea65d9 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -394,10 +394,17 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName ) if( !aViewPort ) return; - aViewPort->removeItem( myRefPreviewPrs ); + if( myPreviewPrs ) + myPreviewPrs->setCaption( QString() ); + + if( myRefPreviewPrs ) + { + myRefPreviewPrs->setCaption( QString() ); + aViewPort->removeItem( myRefPreviewPrs ); - delete myRefPreviewPrs; - myRefPreviewPrs = 0; + delete myRefPreviewPrs; + myRefPreviewPrs = 0; + } QImage anImage; Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast( @@ -416,8 +423,11 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName ) // vertically shift the reference prs relatively to the main prs if( myPreviewPrs ) { + myPreviewPrs->setCaption( tr( "IMPORTED_IMAGE" ) ); + QImage anImage = myPreviewPrs->getImage(); - myRefPreviewPrs->moveBy( 0, anImage.height() + 20 ); + myRefPreviewPrs->moveBy( 0, anImage.height() + 60 ); + myRefPreviewPrs->setCaption( tr( "REFERENCE_IMAGE" ) ); } aViewPort->addItem( myRefPreviewPrs ); diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.cxx b/src/HYDROGUI/HYDROGUI_PrsImage.cxx index 90e54cf6..4a4ee5bb 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.cxx +++ b/src/HYDROGUI/HYDROGUI_PrsImage.cxx @@ -35,6 +35,7 @@ HYDROGUI_PrsImage::HYDROGUI_PrsImage( const Handle(HYDROData_Object)& theObject ) : HYDROGUI_Prs( theObject ), myPixmapItem( 0 ), + myCaptionItem( 0 ), myPrsImageFrame( 0 ), myIsTransformationPointPreview( false ), myTransformationPointType( None ) @@ -73,6 +74,30 @@ QImage HYDROGUI_PrsImage::getImage() const return myImage; } +//================================================================ +// Function : setCaption +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::setCaption( const QString& theCaption ) +{ + if( myCaptionItem ) + { + myCaptionItem->setText( theCaption ); + myCaptionItem->setVisible( !theCaption.isEmpty() ); + } +} + +//================================================================ +// Function : getCaption +// Purpose : +//================================================================ +QString HYDROGUI_PrsImage::getCaption() const +{ + if( myCaptionItem ) + return myCaptionItem->text(); + return QString(); +} + //================================================================ // Function : setIsTransformationPointPreview // Purpose : @@ -150,12 +175,27 @@ void HYDROGUI_PrsImage::compute() myPixmapItem = new QGraphicsPixmapItem( this ); addToGroup( myPixmapItem ); } + if( !myCaptionItem ) + { + myCaptionItem = new QGraphicsSimpleTextItem( this ); + + QFont aFont = myCaptionItem->font(); + aFont.setPointSize( 14 ); + myCaptionItem->setFont( aFont ); + + addToGroup( myCaptionItem ); + } if( !myPrsImageFrame ) { myPrsImageFrame = new HYDROGUI_PrsImageFrame( this ); addToGroup( myPrsImageFrame ); } + myPixmapItem->setPixmap( QPixmap::fromImage( myImage ) ); + + myCaptionItem->setPos( 0, -30 ); + myCaptionItem->setVisible( false ); + myPrsImageFrame->compute(); } diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.h b/src/HYDROGUI/HYDROGUI_PrsImage.h index 3f78316c..c59218ff 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.h +++ b/src/HYDROGUI/HYDROGUI_PrsImage.h @@ -53,6 +53,9 @@ public: void setImage( const QImage& theImage ); QImage getImage() const; + void setCaption( const QString& theCaption ); + QString getCaption() const; + void setIsTransformationPointPreview( const bool theState ); bool getIsTransformationPointPreview() const; @@ -93,6 +96,7 @@ protected: QImage myImage; QGraphicsPixmapItem* myPixmapItem; + QGraphicsSimpleTextItem* myCaptionItem; HYDROGUI_PrsImageFrame* myPrsImageFrame; bool myIsTransformationPointPreview; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index d3fb9693..4ebc6382 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -187,6 +187,10 @@ file cannot be correctly imported for a Bathymetry definition. IMPORT_IMAGE Import image + + IMPORTED_IMAGE + Imported image + TRANSFORM_IMAGE Transform image @@ -199,6 +203,10 @@ file cannot be correctly imported for a Bathymetry definition. REFERENCE_POINTS_A_B_C_BELONG_TO_SINGLE_LINE Reference points A, B, C belong to a single line. + + REFERENCE_IMAGE + Reference image + TRANSFORMATION_MATRIX_CANNOT_BE_COMPUTED Transformation matrix cannot be computed. -- 2.39.2