From: ouv Date: Mon, 22 Nov 2010 09:32:13 +0000 (+0000) Subject: Improvement of View Name feature X-Git-Tag: DIAGRAM_0_1~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0ed5b92b6d763567c240f7d985371f42e430ac56;p=modules%2Fgui.git Improvement of View Name feature --- diff --git a/src/GraphicsView/GraphicsView_ViewPort.cxx b/src/GraphicsView/GraphicsView_ViewPort.cxx index 6559b44a9..f9ede1288 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.cxx +++ b/src/GraphicsView/GraphicsView_ViewPort.cxx @@ -115,6 +115,7 @@ void GraphicsView_ViewPort::destroyCursors() //======================================================================= GraphicsView_ViewPort::GraphicsView_ViewPort( QWidget* theParent ) : QGraphicsView( theParent ), + myNameLabel( 0 ), myForegroundItem( 0 ), myIsTransforming( false ), myHighlightedObject( 0 ), @@ -132,14 +133,6 @@ GraphicsView_ViewPort::GraphicsView_ViewPort( QWidget* theParent ) myScene = new GraphicsView_Scene( this ); setScene( myScene ); - // view name - myNameLabel = new NameLabel( viewport() ); - myNameLabel->setVisible( false ); - - QBoxLayout* aLayout = new QVBoxLayout( viewport() ); - aLayout->addStretch(); - aLayout->addWidget( myNameLabel ); - // background setBackgroundBrush( QBrush( Qt::white ) ); @@ -304,21 +297,35 @@ QImage GraphicsView_ViewPort::dumpView( bool theWholeScene ) } //================================================================ -// Function : setViewName +// Function : setViewNameEnabled // Purpose : //================================================================ -void GraphicsView_ViewPort::setViewName( const QString& theName ) +void GraphicsView_ViewPort::setViewNameEnabled( bool theState, + bool theIsForced ) { - myNameLabel->setText( theName ); + if( theIsForced && !myNameLabel ) + { + myNameLabel = new NameLabel( viewport() ); + + QBoxLayout* aLayout = new QVBoxLayout( viewport() ); + aLayout->setMargin( 10 ); + aLayout->setSpacing( 0 ); + aLayout->addStretch(); + aLayout->addWidget( myNameLabel ); + } + + if( myNameLabel ) + myNameLabel->setVisible( theState ); } //================================================================ -// Function : setViewNameEnabled +// Function : setViewName // Purpose : //================================================================ -void GraphicsView_ViewPort::setViewNameEnabled( bool theState ) +void GraphicsView_ViewPort::setViewName( const QString& theName ) { - myNameLabel->setVisible( theState ); + if( myNameLabel ) + myNameLabel->setText( theName ); } //================================================================ @@ -447,14 +454,16 @@ void GraphicsView_ViewPort::pan( double theDX, double theDY ) { myIsTransforming = true; - myNameLabel->setAcceptMoveEvents( false ); + if( myNameLabel ) + myNameLabel->setAcceptMoveEvents( false ); if( QScrollBar* aHBar = horizontalScrollBar() ) aHBar->setValue( aHBar->value() - theDX ); if( QScrollBar* aVBar = verticalScrollBar() ) aVBar->setValue( aVBar->value() + theDY ); - myNameLabel->setAcceptMoveEvents( true ); + if( myNameLabel ) + myNameLabel->setAcceptMoveEvents( true ); myIsTransforming = false; } diff --git a/src/GraphicsView/GraphicsView_ViewPort.h b/src/GraphicsView/GraphicsView_ViewPort.h index 93ea6f62c..c5e7be216 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.h +++ b/src/GraphicsView/GraphicsView_ViewPort.h @@ -67,8 +67,8 @@ public: public: // view name + void setViewNameEnabled( bool theState, bool theIsForced = false ); void setViewName( const QString& theName ); - void setViewNameEnabled( bool theState ); // background / foreground QColor backgroundColor() const;