From ceda10e52300b9ebbd02a378a9624db3dcb59a56 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Mon, 31 Dec 2012 11:52:42 +0000 Subject: [PATCH] Small update of DynamicLabel for Isis. --- hurricane/src/viewer/ControllerWidget.cpp | 14 +---- hurricane/src/viewer/DynamicLabel.cpp | 35 ++++++----- hurricane/src/viewer/GraphicsWidget.cpp | 14 +---- .../src/viewer/hurricane/viewer/CellViewer.h | 2 +- .../hurricane/viewer/ControllerWidget.h | 16 ++--- .../viewer/hurricane/viewer/DynamicLabel.h | 62 +++++-------------- .../viewer/hurricane/viewer/GraphicsWidget.h | 14 +---- 7 files changed, 47 insertions(+), 110 deletions(-) diff --git a/hurricane/src/viewer/ControllerWidget.cpp b/hurricane/src/viewer/ControllerWidget.cpp index 84020598..8a562a6a 100644 --- a/hurricane/src/viewer/ControllerWidget.cpp +++ b/hurricane/src/viewer/ControllerWidget.cpp @@ -2,14 +2,9 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | C O R I O L I S | // | V L S I B a c k e n d D a t a - B a s e | // | | @@ -17,10 +12,7 @@ // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Module : "./ControllerWidget.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ #include diff --git a/hurricane/src/viewer/DynamicLabel.cpp b/hurricane/src/viewer/DynamicLabel.cpp index 5d89a2f0..98b6dd0a 100644 --- a/hurricane/src/viewer/DynamicLabel.cpp +++ b/hurricane/src/viewer/DynamicLabel.cpp @@ -2,14 +2,9 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | @@ -17,10 +12,7 @@ // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Module : "./DynamicLabel.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ # include @@ -47,18 +39,16 @@ namespace Hurricane { //_staticLabel->setFrameStyle (QFrame::Panel | QFrame::Raised ); QFont font = Graphics::getFixedFont(QFont::Bold); - int cwidth = QFontMetrics(font).width('X'); - _dynamicLabel = new QLabel (); _dynamicLabel->setText ( "vvv.vu" ); - _dynamicLabel->setIndent ( cwidth/2 ); - _dynamicLabel->setMinimumSize ( QSize(cwidth*10,QFontMetrics(font).height()) ); _dynamicLabel->setAlignment ( Qt::AlignRight ); _dynamicLabel->setFont ( font ); + setDynamicWidth ( 10 ); QHBoxLayout* layout = new QHBoxLayout (); - layout->addWidget ( _staticLabel ); - layout->addWidget ( _dynamicLabel ); + layout->addWidget ( _staticLabel ); + layout->addWidget ( _dynamicLabel ); + layout->setSpacing ( 0 ); layout->setContentsMargins ( 0, 0, 0, 0 ); setLayout ( layout ); @@ -77,6 +67,17 @@ namespace Hurricane { } + void DynamicLabel::setDynamicWidth ( int chars, int flags ) + { + QFont font = Graphics::getFixedFont(QFont::Bold); + int cwidth = QFontMetrics(font).width('X'); + + if ( flags|NoIndent ) _dynamicLabel->setIndent( 0 ); + if ( flags|HalfIndent ) _dynamicLabel->setIndent( cwidth/2 ); + _dynamicLabel->setMinimumSize( QSize(cwidth*chars,QFontMetrics(font).height()) ); + } + + void DynamicLabel::setStaticText ( const QString& text ) { _staticLabel->setText ( text ); diff --git a/hurricane/src/viewer/GraphicsWidget.cpp b/hurricane/src/viewer/GraphicsWidget.cpp index 127e079c..c861ad64 100644 --- a/hurricane/src/viewer/GraphicsWidget.cpp +++ b/hurricane/src/viewer/GraphicsWidget.cpp @@ -2,14 +2,9 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | @@ -17,10 +12,7 @@ // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Module : "./GraphicsWidget.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ #include diff --git a/hurricane/src/viewer/hurricane/viewer/CellViewer.h b/hurricane/src/viewer/hurricane/viewer/CellViewer.h index 86a5e3d5..5b841144 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellViewer.h +++ b/hurricane/src/viewer/hurricane/viewer/CellViewer.h @@ -67,7 +67,7 @@ namespace Hurricane { inline void setEnableRedrawInterrupt ( bool ); inline void setApplicationName ( const QString& ); Cell* getCell () const; - void setCell ( Cell* ); + virtual void setCell ( Cell* ); void renameCell ( const char* ); virtual Cell* getCellFromDb ( const char* ); inline CellWidget* getCellWidget (); diff --git a/hurricane/src/viewer/hurricane/viewer/ControllerWidget.h b/hurricane/src/viewer/hurricane/viewer/ControllerWidget.h index 09e1a01e..86509bc5 100644 --- a/hurricane/src/viewer/hurricane/viewer/ControllerWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/ControllerWidget.h @@ -2,25 +2,17 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | C O R I O L I S | // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | -// | C++ Header : "./ControllerWidget.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// | C++ Header : "./hurricane/viewer/ControllerWidget.h" | +// +-----------------------------------------------------------------+ #ifndef __HURRICANE_CONTROLLER_WIDGET__ diff --git a/hurricane/src/viewer/hurricane/viewer/DynamicLabel.h b/hurricane/src/viewer/hurricane/viewer/DynamicLabel.h index 7a394680..0b7042db 100644 --- a/hurricane/src/viewer/hurricane/viewer/DynamicLabel.h +++ b/hurricane/src/viewer/hurricane/viewer/DynamicLabel.h @@ -1,53 +1,18 @@ // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | -// | C++ Header : "./DynamicLabel.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// | C++ Header : "./hurricane/viewer/DynamicLabel.h" | +// +-----------------------------------------------------------------+ # ifndef __DYNAMIC_LABEL_H__ @@ -68,15 +33,18 @@ namespace Hurricane { class DynamicLabel : public QWidget { Q_OBJECT; + public: + enum Indent { NoIndent=1, HalfIndent=2 }; public: // Constructor. - DynamicLabel ( QWidget* parent=NULL ); - // Methods. - QString getStaticText () const; - QString getDynamicText () const; - void setStaticText ( const QString& text ); - void setDynamicText ( const QString& text ); - void setDynamicText ( DbU::Unit u ); + DynamicLabel ( QWidget* parent=NULL ); + // Methods. + QString getStaticText () const; + QString getDynamicText () const; + void setDynamicWidth ( int chars, int flags=HalfIndent ); + void setStaticText ( const QString& text ); + void setDynamicText ( const QString& text ); + void setDynamicText ( DbU::Unit u ); protected: // Internal - Attributes. diff --git a/hurricane/src/viewer/hurricane/viewer/GraphicsWidget.h b/hurricane/src/viewer/hurricane/viewer/GraphicsWidget.h index 1363a161..00a991cb 100644 --- a/hurricane/src/viewer/hurricane/viewer/GraphicsWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/GraphicsWidget.h @@ -2,14 +2,9 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | @@ -17,10 +12,7 @@ // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Header : "./GraphicsWidget.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ #ifndef __HURRICANE_GRAPHICS_WIDGET__