From 445104eaf7f35a2d8a5cb06c2cefabe7d5f57cf3 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sat, 6 Jun 2015 18:41:28 +0200 Subject: [PATCH] Start to support high DPI screen (> 192dpi). * New: In Hurricane, in Graphics, add a new static method ::isHighDpi() which returns true if the DPI is greater than 192. A "normal" screen is typically 96dpi, we sets the trigger at twice that value. Then in all the widgets with size settings, we uses that method to select the more appropriate size. --- crlcore/src/LibraryManager/CellsWidget.cpp | 6 +- crlcore/src/LibraryManager/LibraryManager.cpp | 5 +- hurricane/src/hurricane/hurricane/Torus.h | 23 ++--- hurricane/src/viewer/CellWidget.cpp | 7 +- hurricane/src/viewer/ControllerWidget.cpp | 4 +- hurricane/src/viewer/DisplayFilterWidget.cpp | 41 ++++----- hurricane/src/viewer/ExceptionWidget.cpp | 4 +- hurricane/src/viewer/Graphics.cpp | 27 ++++-- hurricane/src/viewer/GraphicsWidget.cpp | 23 +++-- .../src/viewer/PaletteExtensionGoItem.cpp | 54 +++++------- hurricane/src/viewer/PaletteItem.cpp | 44 ++++++---- hurricane/src/viewer/PaletteLayerItem.cpp | 5 +- hurricane/src/viewer/SelectionPopup.cpp | 86 +++++++++---------- hurricane/src/viewer/SelectionPopupModel.cpp | 45 +++++----- .../src/viewer/hurricane/viewer/CellWidget.h | 2 +- .../hurricane/viewer/DisplayFilterWidget.h | 24 ++---- .../src/viewer/hurricane/viewer/Graphics.h | 4 +- .../viewer/hurricane/viewer/GraphicsWidget.h | 7 +- .../hurricane/viewer/PaletteExtensionGoItem.h | 24 ++---- .../src/viewer/hurricane/viewer/PaletteItem.h | 42 ++++----- .../viewer/hurricane/viewer/SelectionPopup.h | 39 +++------ .../hurricane/viewer/SelectionPopupModel.h | 44 ++++------ 22 files changed, 257 insertions(+), 303 deletions(-) diff --git a/crlcore/src/LibraryManager/CellsWidget.cpp b/crlcore/src/LibraryManager/CellsWidget.cpp index 863bccd8..b181039b 100644 --- a/crlcore/src/LibraryManager/CellsWidget.cpp +++ b/crlcore/src/LibraryManager/CellsWidget.cpp @@ -52,10 +52,12 @@ namespace CRL { _view->setSelectionBehavior ( QAbstractItemView::SelectRows ); _view->setSortingEnabled ( true ); _view->setModel ( _baseModel ); - _view->resizeColumnToContents ( 0 ); + //_view->resizeColumnToContents ( 1 ); QHeaderView* horizontalHeader = _view->horizontalHeader(); - horizontalHeader->setStretchLastSection( true ); + horizontalHeader->setResizeMode ( 0, QHeaderView::Stretch ); + horizontalHeader->setResizeMode ( 1, QHeaderView::ResizeToContents ); + //horizontalHeader->setStretchLastSection( false ); QHeaderView* verticalHeader = _view->verticalHeader(); verticalHeader->setVisible( false ); diff --git a/crlcore/src/LibraryManager/LibraryManager.cpp b/crlcore/src/LibraryManager/LibraryManager.cpp index 8ae048e8..e95c7cb0 100644 --- a/crlcore/src/LibraryManager/LibraryManager.cpp +++ b/crlcore/src/LibraryManager/LibraryManager.cpp @@ -55,6 +55,9 @@ namespace CRL { splitter->addWidget( _librariesWidget ); splitter->addWidget( _cellsWidget ); splitter->addWidget( _viewsWidget ); + splitter->setStretchFactor( 0, 1 ); + splitter->setStretchFactor( 1, 2 ); + splitter->setStretchFactor( 2, 0 ); QFrame* separator = new QFrame (); separator->setFrameShape ( QFrame::HLine ); @@ -97,7 +100,7 @@ namespace CRL { _librariesWidget->initSelection(); - resize( 750, 550 ); + resize( Graphics::toHighDpi(750), Graphics::toHighDpi(550) ); } diff --git a/hurricane/src/hurricane/hurricane/Torus.h b/hurricane/src/hurricane/hurricane/Torus.h index f8b5731d..3a05a74a 100644 --- a/hurricane/src/hurricane/hurricane/Torus.h +++ b/hurricane/src/hurricane/hurricane/Torus.h @@ -1,7 +1,6 @@ - // -*- C++ -*- // -// Copyright (c) BULL S.A. 2000-2010, All Rights Reserved +// Copyright (c) BULL S.A. 2000-2015, All Rights Reserved // // This file is part of Hurricane. // @@ -19,12 +18,7 @@ // License along with Hurricane. If not, see // . // -// =================================================================== -// -// $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 | // | | @@ -32,16 +26,13 @@ // | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Header : "./hurricane/Torus.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#ifndef __HURRICANE_TORUS__ -#define __HURRICANE_TORUS__ +#ifndef HURRICANE_TORUS_H +#define HURRICANE_TORUS_H -#include "hurricane/Box.h" +#include "hurricane/Box.h" namespace Hurricane { @@ -78,4 +69,4 @@ namespace Hurricane { INSPECTOR_PV_SUPPORT(Hurricane::Torus); -#endif // __HURRICANE_TORUS__ +#endif // HURRICANE_TORUS_H diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index 24487cdf..8981c15e 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2015, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | @@ -1041,7 +1041,7 @@ namespace Hurricane { // Class : "Hurricane::CellWidget". - const int CellWidget::_initialSide = 400; + int CellWidget::_initialSide = 400; CellWidget::CellWidget ( QWidget* parent ) @@ -1085,6 +1085,9 @@ namespace Hurricane { QFont font = Graphics::getNormalFont(); _textFontHeight = QFontMetrics(font).ascent(); + + _initialSide = Graphics::toHighDpi( _initialSide ); + if (Graphics::isHighDpi()) resize( _initialSide, _initialSide ); } diff --git a/hurricane/src/viewer/ControllerWidget.cpp b/hurricane/src/viewer/ControllerWidget.cpp index 817584aa..ad15f900 100644 --- a/hurricane/src/viewer/ControllerWidget.cpp +++ b/hurricane/src/viewer/ControllerWidget.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2015, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | @@ -511,7 +511,7 @@ namespace Hurricane { connect ( _tabSelection->getSelection(), SIGNAL(inspect(Occurrence&)) , _tabInspector , SLOT (setSelectionOccurrence(Occurrence&)) ); - resize ( 600, 560 ); + resize ( Graphics::toHighDpi(600), Graphics::toHighDpi(500) ); } diff --git a/hurricane/src/viewer/DisplayFilterWidget.cpp b/hurricane/src/viewer/DisplayFilterWidget.cpp index 073d16f2..5987665b 100644 --- a/hurricane/src/viewer/DisplayFilterWidget.cpp +++ b/hurricane/src/viewer/DisplayFilterWidget.cpp @@ -1,15 +1,9 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved +// Copyright (c) UPMC 2008-2015, 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,24 +11,20 @@ // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Module : "./DisplayFilterWidget.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "hurricane/viewer/Graphics.h" -#include "hurricane/viewer/CellWidget.h" -#include "hurricane/viewer/DisplayFilterWidget.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "hurricane/viewer/Graphics.h" +#include "hurricane/viewer/CellWidget.h" +#include "hurricane/viewer/DisplayFilterWidget.h" namespace Hurricane { @@ -114,6 +104,7 @@ namespace Hurricane { gLayout->addWidget ( _doComponents, 5, 0, 1, 2 ); connect ( _doComponents, SIGNAL(stateChanged(int)), this, SLOT(setDoComponents(int)) ); + if (Graphics::isHighDpi()) gLayout->setContentsMargins( 30, 30, 30, 30 ); groupBox->setLayout ( gLayout ); wLayout->addWidget ( groupBox ); @@ -141,6 +132,7 @@ namespace Hurricane { group->addButton ( _steiner ); hLayout->addWidget ( _steiner ); + if (Graphics::isHighDpi()) hLayout->setContentsMargins( 30, 30, 30, 30 ); groupBox->setLayout ( hLayout ); wLayout->addWidget ( groupBox ); @@ -174,6 +166,7 @@ namespace Hurricane { group->addButton ( _microMode ); hLayout->addWidget ( _microMode ); + if (Graphics::isHighDpi()) hLayout->setContentsMargins( 30, 30, 30, 30 ); groupBox->setLayout ( hLayout ); wLayout->addWidget ( groupBox ); wLayout->addStretch (); diff --git a/hurricane/src/viewer/ExceptionWidget.cpp b/hurricane/src/viewer/ExceptionWidget.cpp index f01a1164..d136bc7a 100644 --- a/hurricane/src/viewer/ExceptionWidget.cpp +++ b/hurricane/src/viewer/ExceptionWidget.cpp @@ -102,7 +102,7 @@ namespace Hurricane { setWindowTitle( tr("") ); setToolTip ( tr("Ben mon cochon, t'es dans le bouillon") ); - _header->setMinimumWidth ( 200 ); + _header->setMinimumWidth ( Graphics::isHighDpi() ? 400 : 200 ); _header->setTextFormat ( Qt::RichText ); _header->setText ( "[ERROR]" ); @@ -112,7 +112,7 @@ namespace Hurricane { _trace->setTextInteractionFlags ( Qt::TextBrowserInteraction ); _trace->setAcceptRichText ( true ); _trace->setHtml ( "No program trace sets yet." ); - _trace->setMinimumSize ( QSize(800,500) ); + _trace->setMinimumSize ( QSize( Graphics::isHighDpi() ? 1800 : 800, 500) ); _trace->setLineWrapMode ( QTextEdit::NoWrap ); //_trace->setSizePolicy ( QSizePolicy::Ignored, QSizePolicy::Ignored ); _trace->hide (); diff --git a/hurricane/src/viewer/Graphics.cpp b/hurricane/src/viewer/Graphics.cpp index d9348878..92cc4575 100644 --- a/hurricane/src/viewer/Graphics.cpp +++ b/hurricane/src/viewer/Graphics.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2015, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // // +-----------------------------------------------------------------+ // | H U R R I C A N E | @@ -19,6 +19,7 @@ #include #include #include +#include #include "hurricane/Name.h" #include "hurricane/Exception.h" #include "hurricane/Warning.h" @@ -40,6 +41,7 @@ namespace Hurricane { , _rainbowColorScale () , _temperatureColorScale() , _qtEnabled (false) + , _highDpi (false) { _htmlTranslator.addTranslation ( "
" , "
" ); _htmlTranslator.addTranslation ( "" , "" ); @@ -123,6 +125,8 @@ namespace Hurricane { _rainbowColorScale.qtAllocate(); _temperatureColorScale.qtAllocate(); + _highDpi = (qApp->desktop()->logicalDpiX() > 192); + Breakpoint::setStopCb ( Graphics::breakpointStopCb ); } @@ -196,15 +200,15 @@ namespace Hurricane { bool Graphics::isEnabled () - { - return getGraphics()->_qtEnabled; - } + { return getGraphics()->_qtEnabled; } + + + bool Graphics::isHighDpi () + { return getGraphics()->_highDpi; } void Graphics::enable () - { - return getGraphics()->_enable(); - } + { return getGraphics()->_enable(); } void Graphics::addStyle ( DisplayStyle* displayStyle ) @@ -325,6 +329,15 @@ namespace Hurricane { } + int Graphics::toHighDpi ( int value ) + { + if (isHighDpi()) { + // For now, for high DPI, multiplies by 2.5. + value = value*2 + value/2; + } + return value; + } + bool Graphics::breakpointStopCb ( const string& message ) { static BreakpointWidget* bpw = NULL; diff --git a/hurricane/src/viewer/GraphicsWidget.cpp b/hurricane/src/viewer/GraphicsWidget.cpp index c861ad64..24582a40 100644 --- a/hurricane/src/viewer/GraphicsWidget.cpp +++ b/hurricane/src/viewer/GraphicsWidget.cpp @@ -1,8 +1,7 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // // +-----------------------------------------------------------------+ // | H U R R I C A N E | @@ -15,16 +14,15 @@ // +-----------------------------------------------------------------+ -#include -#include -#include -#include -#include -#include - -#include "hurricane/viewer/Graphics.h" -#include "hurricane/viewer/DisplayStyle.h" -#include "hurricane/viewer/GraphicsWidget.h" +#include +#include +#include +#include +#include +#include +#include "hurricane/viewer/Graphics.h" +#include "hurricane/viewer/DisplayStyle.h" +#include "hurricane/viewer/GraphicsWidget.h" namespace Hurricane { @@ -65,6 +63,7 @@ namespace Hurricane { gLayout->addWidget ( label , istyle-hideFallback, 1 ); group->addButton ( button, istyle ); } + if (Graphics::isHighDpi()) gLayout->setContentsMargins( 30, 30, 30, 30 ); groupBox->setLayout ( gLayout ); wLayout->addWidget ( groupBox ); diff --git a/hurricane/src/viewer/PaletteExtensionGoItem.cpp b/hurricane/src/viewer/PaletteExtensionGoItem.cpp index d172549c..c5947c98 100644 --- a/hurricane/src/viewer/PaletteExtensionGoItem.cpp +++ b/hurricane/src/viewer/PaletteExtensionGoItem.cpp @@ -1,15 +1,9 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC 2008-2015, 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,17 +11,13 @@ // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Module : "./PaletteExtensionGoItem.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#include -#include - -#include "hurricane/viewer/Graphics.h" -#include "hurricane/viewer/PaletteExtensionGoItem.h" +#include +#include +#include "hurricane/viewer/Graphics.h" +#include "hurricane/viewer/PaletteExtensionGoItem.h" namespace Hurricane { @@ -35,9 +25,9 @@ namespace Hurricane { PaletteExtensionGoItem::PaletteExtensionGoItem ( const Name& name ) : PaletteItem() - , _visible(NULL) + , _visible (NULL) , _selectable(NULL) - , _name(name) + , _name (name) { } @@ -52,25 +42,27 @@ namespace Hurricane { void PaletteExtensionGoItem::_postCreate () { QHBoxLayout* layout = new QHBoxLayout (); - layout->setContentsMargins ( 0, 0, 0, 0 ); + layout->setContentsMargins( 0, 0, 0, 0 ); _visible = new QCheckBox ( this ); - _visible->setChecked ( false ); - _visible->setText ( getString(getName()).c_str() ); - _visible->setFont ( Graphics::getFixedFont() ); + _visible->setChecked( false ); + _visible->setText ( getString(getName()).c_str() ); + _visible->setFont ( Graphics::getFixedFont() ); - _selectable = new QCheckBox ( this ); - _selectable->setFixedWidth ( 23 ); - _selectable->setChecked ( true ); - _selectable->setStyleSheet ( "QCheckBox { background-color: red;" - " padding: 2px 3px 2px 3px }" ); + _selectable = new QCheckBox( this ); + if (not Graphics::isHighDpi()) + _selectable->setFixedWidth( 23 ); + _selectable->setChecked ( true ); + _selectable->setStyleSheet( "QCheckBox { background-color: red;" + " padding: 2px 2px 6px 6px }" ); layout->addWidget ( _selectable ); layout->addWidget ( _visible ); - setLayout ( layout ); + layout->addStretch( 1 ); + setLayout( layout ); - connect ( _visible , SIGNAL(clicked()), this, SIGNAL(visibleToggled ()) ); - connect ( _selectable, SIGNAL(clicked()), this, SIGNAL(selectableToggled()) ); + connect( _visible , SIGNAL(clicked()), this, SIGNAL(visibleToggled ()) ); + connect( _selectable, SIGNAL(clicked()), this, SIGNAL(selectableToggled()) ); } diff --git a/hurricane/src/viewer/PaletteItem.cpp b/hurricane/src/viewer/PaletteItem.cpp index 34e40bdd..9282258e 100644 --- a/hurricane/src/viewer/PaletteItem.cpp +++ b/hurricane/src/viewer/PaletteItem.cpp @@ -26,29 +26,43 @@ namespace Hurricane { // Class : "Hurricane::DrawingStyleSample". + int DrawingStyleSample::_side = 20; + int DrawingStyleSample::_border = 2; + + DrawingStyleSample::DrawingStyleSample ( PaletteItem* entry ) : QWidget() - , _sample(QSize(20,20)) + , _sample(NULL) , _entry(entry) { - setAttribute ( Qt::WA_StaticContents ); - setSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed ); - setFixedSize ( 20, 20 ); + if (Graphics::isHighDpi()) { + _side = 40; + _border = 4; + } + _sample = new QPixmap( _side, _side ); - redraw (); + setAttribute ( Qt::WA_StaticContents ); + setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + setFixedSize ( _side, _side ); + + redraw(); } + DrawingStyleSample::~DrawingStyleSample () + { delete _sample; } + + void DrawingStyleSample::redraw () { - QPainter painter ( &_sample ); + QPainter painter ( _sample ); - painter.setPen ( Qt::NoPen ); - painter.setBackground ( Graphics::getBrush("background") ); - painter.eraseRect ( 0, 0, 20, 20 ); - painter.setPen ( Graphics::getPen (_entry->getName()) ); - painter.setBrush ( Graphics::getBrush(_entry->getName()) ); - painter.drawRect ( 2, 2, 16, 16 ); + painter.setPen ( Qt::NoPen ); + painter.setBackground( Graphics::getBrush("background") ); + painter.eraseRect ( 0, 0, _side, _side ); + painter.setPen ( Graphics::getPen (_entry->getName()) ); + painter.setBrush ( Graphics::getBrush(_entry->getName()) ); + painter.drawRect ( _border, _border, _side-2*_border, _side-2*_border ); update (); } @@ -56,8 +70,8 @@ namespace Hurricane { void DrawingStyleSample::paintEvent ( QPaintEvent* ) { - QPainter painter ( this ); - painter.drawPixmap ( 0, 0, _sample ); + QPainter painter( this ); + painter.drawPixmap( 0, 0, *_sample ); } @@ -76,7 +90,7 @@ namespace Hurricane { } - void PaletteItem::setItemSelectable ( bool ) + void PaletteItem::setItemSelectable ( bool ) { } diff --git a/hurricane/src/viewer/PaletteLayerItem.cpp b/hurricane/src/viewer/PaletteLayerItem.cpp index 38550f93..02ecc039 100644 --- a/hurricane/src/viewer/PaletteLayerItem.cpp +++ b/hurricane/src/viewer/PaletteLayerItem.cpp @@ -48,10 +48,11 @@ namespace Hurricane { _visible->setText ( label.str().c_str() ); _visible->setFont ( Graphics::getFixedFont() ); - _selectable->setFixedWidth ( 23 ); + if (not Graphics::isHighDpi()) + _selectable->setFixedWidth ( 23 ); _selectable->setChecked ( true ); _selectable->setStyleSheet ( "QCheckBox { background-color: red;" - " padding: 2px 3px 2px 3px; }" ); + " padding: 2px 2px 6px 6px; }" ); //_selectable->setStyleSheet ( "QCheckBox::indicator {" // " border: 2px solid red;" // "}" diff --git a/hurricane/src/viewer/SelectionPopup.cpp b/hurricane/src/viewer/SelectionPopup.cpp index da8fc325..92488e14 100644 --- a/hurricane/src/viewer/SelectionPopup.cpp +++ b/hurricane/src/viewer/SelectionPopup.cpp @@ -1,38 +1,28 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | H U R R I C A N E | // | | // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Module : "./SelectionPopup.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#include -#include -#include -#include -#include -#include - -#include "hurricane/Commons.h" -#include "hurricane/viewer/Graphics.h" -#include "hurricane/viewer/SelectionPopupModel.h" -#include "hurricane/viewer/SelectionPopup.h" +#include +#include +#include +#include +#include +#include +#include "hurricane/Commons.h" +#include "hurricane/viewer/Graphics.h" +#include "hurricane/viewer/SelectionPopupModel.h" +#include "hurricane/viewer/SelectionPopup.h" namespace Hurricane { @@ -47,40 +37,41 @@ namespace Hurricane { , _model(NULL) , _view(NULL) , _rowHeight(20) + , _charWidth(15) { - setAttribute ( Qt::WA_DeleteOnClose ); - setAttribute ( Qt::WA_QuitOnClose, false ); - //setWindowFlags ( Qt::Popup ); - setWindowFlags ( Qt::FramelessWindowHint ); - setWindowOpacity ( 0.7 ); + setAttribute ( Qt::WA_DeleteOnClose ); + setAttribute ( Qt::WA_QuitOnClose, false ); + //setWindowFlags ( Qt::Popup ); + setWindowFlags ( Qt::FramelessWindowHint ); + setWindowOpacity( 0.9 ); _rowHeight = QFontMetrics(Graphics::getFixedFont()).height() + 4; - - _model = new SelectionPopupModel ( this ); + _charWidth = QFontMetrics(Graphics::getFixedFont()).averageCharWidth() + 1; + _model = new SelectionPopupModel ( this ); _view = new QTableView ( this ); - _view->setShowGrid ( false ); - _view->setAlternatingRowColors ( true ); - _view->setSelectionBehavior ( QAbstractItemView::SelectRows ); - _view->setModel ( _model ); - _view->horizontalHeader()->setStretchLastSection ( true ); - _view->setWordWrap ( false ); + _view->setShowGrid( false ); + _view->setAlternatingRowColors( true ); + _view->setSelectionBehavior( QAbstractItemView::SelectRows ); + _view->setModel( _model ); + _view->horizontalHeader()->setStretchLastSection( true ); + _view->setWordWrap( false ); //_view->setTextElideMode ( Qt::ElideRight ); //_view->setFixedSize ( QSize(300,100) ); //_view->setIconSize ( QSize(600,40) ); //_view->setStyleSheet ( "QTableView { background-color: #555555; }" ); - QHeaderView* horizontalHeader = _view->horizontalHeader (); - horizontalHeader->setStretchLastSection ( true ); - horizontalHeader->setMinimumSectionSize ( 200 ); - horizontalHeader->setVisible ( false ); + QHeaderView* horizontalHeader = _view->horizontalHeader(); + horizontalHeader->setStretchLastSection( true ); + horizontalHeader->setMinimumSectionSize( (Graphics::isHighDpi()) ? 1500 : 200 ); + horizontalHeader->setVisible( false ); QHeaderView* verticalHeader = _view->verticalHeader (); - verticalHeader->setVisible ( false ); + verticalHeader->setVisible( false ); - connect ( _model, SIGNAL(layoutChanged()), this, SLOT(forceRowHeight()) ); + connect( _model, SIGNAL(layoutChanged()), this, SLOT(forceRowHeight()) ); - resize ( 600, 10 ); + resize( Graphics::isHighDpi() ? 1500 : 600, 10 ); } @@ -147,11 +138,12 @@ namespace Hurricane { // This seems a very bad way to set the size of the popup window // and underlying QTableView (top-down instead of bottom-up). - int rows = _model->rowCount(); - QSize windowSize = QSize ( 600, _rowHeight*rows + 4 ); + int pixelHeight = _model->rowCount() * _rowHeight + 4; + int pixelWidth = _model->charWidth() * _charWidth; + QSize windowSize = QSize( pixelWidth, pixelHeight ); - resize ( windowSize ); - _view->resize ( windowSize ); + resize( windowSize ); + _view->resize( windowSize ); } diff --git a/hurricane/src/viewer/SelectionPopupModel.cpp b/hurricane/src/viewer/SelectionPopupModel.cpp index bd466a73..d9effafa 100644 --- a/hurricane/src/viewer/SelectionPopupModel.cpp +++ b/hurricane/src/viewer/SelectionPopupModel.cpp @@ -1,15 +1,9 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC 2008-2015, 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,20 +11,16 @@ // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Module : "./SelectionPopupModel.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#include - -#include "hurricane/Path.h" -#include "hurricane/Entity.h" -#include "hurricane/Occurrence.h" -#include "hurricane/viewer/Graphics.h" -#include "hurricane/viewer/Selector.h" -#include "hurricane/viewer/SelectionPopupModel.h" +#include +#include "hurricane/Path.h" +#include "hurricane/Entity.h" +#include "hurricane/Occurrence.h" +#include "hurricane/viewer/Graphics.h" +#include "hurricane/viewer/Selector.h" +#include "hurricane/viewer/SelectionPopupModel.h" namespace Hurricane { @@ -61,6 +51,7 @@ namespace Hurricane { : QAbstractTableModel(parent) , _filter (new Occurrence_AcceptAll()) , _occurrences (NULL) + , _charWidth (50) { } @@ -80,13 +71,21 @@ namespace Hurricane { { return _filter; } + int SelectionPopupModel::charWidth () const + { return _charWidth; } + + void SelectionPopupModel::loadOccurrences ( Occurrences occurrences, bool showChange ) { - if ( !_occurrences ) _occurrences = new vector (); + _charWidth = 50; + if (not _occurrences) _occurrences = new vector (); forEach ( Occurrence, ioccurrence, occurrences.getSubSet(getFilter()) ) { - _occurrences->push_back ( *ioccurrence ); + _occurrences->push_back( *ioccurrence ); + string name = getString( (*ioccurrence).getPath().getName() ) + "::" + + getString( (*ioccurrence).getEntity() ); + _charWidth = std::max( _charWidth, (int)name.size() ); } - if ( showChange ) emit layoutChanged (); + if (showChange) emit layoutChanged (); } diff --git a/hurricane/src/viewer/hurricane/viewer/CellWidget.h b/hurricane/src/viewer/hurricane/viewer/CellWidget.h index 1c82f37f..2be1da63 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/CellWidget.h @@ -618,7 +618,7 @@ namespace Hurricane { protected: // Internal: Attributes. - static const int _initialSide; + static int _initialSide; vector _cursors; // MapView* _mapView; Technology* _technology; diff --git a/hurricane/src/viewer/hurricane/viewer/DisplayFilterWidget.h b/hurricane/src/viewer/hurricane/viewer/DisplayFilterWidget.h index 27297ffe..025a2f1c 100644 --- a/hurricane/src/viewer/hurricane/viewer/DisplayFilterWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/DisplayFilterWidget.h @@ -1,15 +1,9 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved +// Copyright (c) UPMC 2008-2015, 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,14 +11,11 @@ // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Header : "./DisplayFilterWidget.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#ifndef __HURRICANE_DISPLAY_FILTER_WIDGET__ -#define __HURRICANE_DISPLAY_FILTER_WIDGET__ +#ifndef HURRICANE_DISPLAY_FILTER_WIDGET_H +#define HURRICANE_DISPLAY_FILTER_WIDGET_H #include @@ -84,7 +75,6 @@ namespace Hurricane { }; -} // End of Hurricane namespace. +} // Hurricane namespace. - -#endif +#endif // HURRICANE_DISPLAY_FILTER_WIDGET_H diff --git a/hurricane/src/viewer/hurricane/viewer/Graphics.h b/hurricane/src/viewer/hurricane/viewer/Graphics.h index 3b57248a..fdc392aa 100644 --- a/hurricane/src/viewer/hurricane/viewer/Graphics.h +++ b/hurricane/src/viewer/hurricane/viewer/Graphics.h @@ -1,4 +1,3 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. @@ -44,6 +43,7 @@ namespace Hurricane { // Accessors. static Graphics* getGraphics (); static bool isEnabled (); + static bool isHighDpi (); static const QFont getFixedFont ( int weight=QFont::Normal, bool italic=false, bool underline=false, int scale=0 ); static const QFont getNormalFont ( bool bold=false, bool italic=false, bool underline=false ); static const Name& getGroup ( const Name& key ); @@ -57,6 +57,7 @@ namespace Hurricane { static QColor darken ( const QColor& ); static const TextTranslator& getHtmlTranslator(); static string toHtml ( const string& ); + static int toHighDpi ( int ); static bool breakpointStopCb ( const string& message ); // Modifiers. @@ -78,6 +79,7 @@ namespace Hurricane { RainbowColorScale _rainbowColorScale; TemperatureColorScale _temperatureColorScale; bool _qtEnabled; + bool _highDpi; // Internals - Constructors & Destructors. Graphics (); diff --git a/hurricane/src/viewer/hurricane/viewer/GraphicsWidget.h b/hurricane/src/viewer/hurricane/viewer/GraphicsWidget.h index 00a991cb..206dc73a 100644 --- a/hurricane/src/viewer/hurricane/viewer/GraphicsWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/GraphicsWidget.h @@ -1,8 +1,7 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // // +-----------------------------------------------------------------+ // | H U R R I C A N E | @@ -15,8 +14,8 @@ // +-----------------------------------------------------------------+ -#ifndef __HURRICANE_GRAPHICS_WIDGET__ -#define __HURRICANE_GRAPHICS_WIDGET__ +#ifndef HURRICANE_GRAPHICS_WIDGET_H +#define HURRICANE_GRAPHICS_WIDGET_H #include diff --git a/hurricane/src/viewer/hurricane/viewer/PaletteExtensionGoItem.h b/hurricane/src/viewer/hurricane/viewer/PaletteExtensionGoItem.h index 44bb8123..bdf3e125 100644 --- a/hurricane/src/viewer/hurricane/viewer/PaletteExtensionGoItem.h +++ b/hurricane/src/viewer/hurricane/viewer/PaletteExtensionGoItem.h @@ -1,15 +1,9 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC 2008-2015, 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,14 +11,11 @@ // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Header : "./PaletteExtensionGoItem.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#ifndef __HURRICANE_PALETTE_EXTENSION_GO_ITEM__ -#define __HURRICANE_PALETTE_EXTENSION_GO_ITEM__ +#ifndef HURRICANE_PALETTE_EXTENSION_GO_ITEM_H +#define HURRICANE_PALETTE_EXTENSION_GO_ITEM_H class QCheckBox; @@ -61,7 +52,6 @@ namespace Hurricane { }; -} // End of Hurricane namespace. +} // Hurricane namespace. - -#endif // __LAYER_PALETTE_ENTRY__ +#endif // HURRICANE_PALETTE_EXTENSION_GO_ITEM_H diff --git a/hurricane/src/viewer/hurricane/viewer/PaletteItem.h b/hurricane/src/viewer/hurricane/viewer/PaletteItem.h index 8651a551..0e516154 100644 --- a/hurricane/src/viewer/hurricane/viewer/PaletteItem.h +++ b/hurricane/src/viewer/hurricane/viewer/PaletteItem.h @@ -1,35 +1,25 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC 2008-2015, 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 | // | | // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | -// | C++ Header : "./PaletteItem.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// | C++ Header : "./hurricane/viewer/PaletteItem.h" | +// +-----------------------------------------------------------------+ -#ifndef __HURRICANE_PALETTE_ITEM__ -#define __HURRICANE_PALETTE_ITEM__ +#ifndef HURRICANE_PALETTE_ITEM_H +#define HURRICANE_PALETTE_ITEM_H #include #include #include - class QPaintEvent; class QCheckBox; @@ -38,7 +28,6 @@ class QCheckBox; namespace Hurricane { - class Name; class PaletteItem; @@ -51,13 +40,17 @@ namespace Hurricane { Q_OBJECT; public: - DrawingStyleSample ( PaletteItem* ); + DrawingStyleSample ( PaletteItem* ); + ~DrawingStyleSample (); protected: - QPixmap _sample; - PaletteItem* _entry; + QPixmap* _sample; + PaletteItem* _entry; + private: + static int _side; + static int _border; public slots: - void redraw (); - void paintEvent ( QPaintEvent* ); + void redraw (); + void paintEvent ( QPaintEvent* ); }; @@ -86,7 +79,6 @@ namespace Hurricane { }; -} // End of Hurricane namespace. +} // Hurricane namespace. - -# endif // __HURRICANE_PALETTE_ITEM__ +#endif // HURRICANE_PALETTE_ITEM_H diff --git a/hurricane/src/viewer/hurricane/viewer/SelectionPopup.h b/hurricane/src/viewer/hurricane/viewer/SelectionPopup.h index e67b7ac3..4be63cea 100644 --- a/hurricane/src/viewer/hurricane/viewer/SelectionPopup.h +++ b/hurricane/src/viewer/hurricane/viewer/SelectionPopup.h @@ -1,38 +1,27 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC 2008-2015, 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 | // | | // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | -// | C++ Header : "./SelectionPopup.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// | C++ Header : "./hurricane/viewer/SelectionPopup.h" | +// +-----------------------------------------------------------------+ -#ifndef __HURRICANE_SELECTION_POPUP_WIDGET_H__ -#define __HURRICANE_SELECTION_POPUP_WIDGET_H__ +#ifndef HURRICANE_SELECTION_POPUP_WIDGET_H +#define HURRICANE_SELECTION_POPUP_WIDGET_H - -#include -#include - -#include "hurricane/Commons.h" -#include "hurricane/Occurrence.h" -#include "hurricane/Occurrences.h" +#include +#include +#include "hurricane/Commons.h" +#include "hurricane/Occurrence.h" +#include "hurricane/Occurrences.h" class QModelIndex; @@ -75,10 +64,10 @@ namespace Hurricane { SelectionPopupModel* _model; QTableView* _view; int _rowHeight; + int _charWidth; }; -} // End of Hurricane namespace. +} // Hurricane namespace. - -#endif // __HURRICANE_SELECTION_POPUP_WIDGET_H__ +#endif // HURRICANE_SELECTION_POPUP_WIDGET_H diff --git a/hurricane/src/viewer/hurricane/viewer/SelectionPopupModel.h b/hurricane/src/viewer/hurricane/viewer/SelectionPopupModel.h index 53f47f11..2d39ec17 100644 --- a/hurricane/src/viewer/hurricane/viewer/SelectionPopupModel.h +++ b/hurricane/src/viewer/hurricane/viewer/SelectionPopupModel.h @@ -1,47 +1,35 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC 2008-2015, 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 | // | | // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | -// | C++ Header : "./SelectionPopupModel.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// | C++ Header : "./hurricane/viewer/SelectionPopupModel.h" | +// +-----------------------------------------------------------------+ -#ifndef __HURRICANE_SELECTION_POPUP_MODEL_H__ -#define __HURRICANE_SELECTION_POPUP_MODEL_H__ +#ifndef HURRICANE_SELECTION_POPUP_MODEL_H +#define HURRICANE_SELECTION_POPUP_MODEL_H -#include -#include - -#include -#include -#include - -#include "hurricane/Commons.h" -#include "hurricane/Occurrence.h" -#include "hurricane/Occurrences.h" -#include "hurricane/viewer/Graphics.h" +#include +#include +#include +#include +#include +#include "hurricane/Commons.h" +#include "hurricane/Occurrence.h" +#include "hurricane/Occurrences.h" +#include "hurricane/viewer/Graphics.h" namespace Hurricane { - class Selector; @@ -57,6 +45,7 @@ namespace Hurricane { void loadOccurrences ( Occurrences, bool showChange=false ); void clear (); void updateLayout (); + int charWidth () const; int rowCount ( const QModelIndex& parent=QModelIndex() ) const; int columnCount ( const QModelIndex& parent=QModelIndex() ) const; QVariant data ( const QModelIndex& index, int role=Qt::DisplayRole ) const; @@ -66,6 +55,7 @@ namespace Hurricane { private: OccurrenceFilter _filter; vector* _occurrences; + int _charWidth; };