From caf3b17a2587b53f0957958a12872f48acb018eb Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 22 Jan 2009 13:12:46 +0000 Subject: [PATCH] Merge from BR_V5_IMP_P8 --- src/OCCViewer/OCCViewer_ViewWindow.cxx | 25 +++ src/OCCViewer/OCCViewer_ViewWindow.h | 5 +- src/OCCViewer/resources/OCCViewer_msg_en.ts | 4 + src/Qtx/QtxFontEdit.cxx | 178 +++++++++++++++++++- src/Qtx/QtxFontEdit.h | 23 ++- src/Qtx/QtxPagePrefMgr.cxx | 102 +++++++++++ src/Qtx/QtxPagePrefMgr.h | 9 + src/Qtx/QtxResourceMgr.cxx | 4 + src/SalomeApp/SalomeApp_DataObject.cxx | 25 ++- src/VTKViewer/Makefile.am | 3 +- 10 files changed, 364 insertions(+), 14 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index c2d5e075d..b36d156ea 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -66,6 +66,7 @@ #include #include #include +#include static QEvent* l_mbPressEvent = 0; @@ -1393,6 +1394,30 @@ QImage OCCViewer_ViewWindow::dumpView() return px.toImage(); } +bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, + const QString& fileName, + const QString& format ) +{ + if ( format != "PS" && format != "EPS") + return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format ); + + Handle(Visual3d_View) a3dView = myViewPort->getView()->View(); + + if (format == "PS") + a3dView->Export(qPrintable(fileName), Graphic3d_EF_PostScript); + else if (format == "EPS") + a3dView->Export(qPrintable(fileName), Graphic3d_EF_EnhPostScript); + + return true; +} + + +QString OCCViewer_ViewWindow::filter() const +{ + return tr( "OCC_IMAGE_FILES" ); +} + + /*! \brief Set parameters of the cutting plane \param on if \c true, cutting plane is enabled diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 3383af342..180e66c19 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -117,6 +117,7 @@ public slots: virtual void showEvent( QShowEvent * ); virtual void hideEvent( QHideEvent * ); + signals: void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type); void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type); @@ -126,7 +127,9 @@ signals: void Hide( QHideEvent * ); protected: - QImage dumpView(); + virtual QImage dumpView(); + virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format ); + virtual QString filter() const; /* Transformation selected but not started yet */ bool transformRequested() const; diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index b90f4328c..e48ac131a 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -232,6 +232,10 @@ MNU_SCALING Scaling + + OCC_IMAGE_FILES + Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps) + OCCViewer_CreateRestoreViewDlg diff --git a/src/Qtx/QtxFontEdit.cxx b/src/Qtx/QtxFontEdit.cxx index 4587ef04b..30cacf8db 100644 --- a/src/Qtx/QtxFontEdit.cxx +++ b/src/Qtx/QtxFontEdit.cxx @@ -60,7 +60,8 @@ */ QtxFontEdit::QtxFontEdit( const int feat, QWidget* parent ) : QFrame( parent ), - myFeatures( feat ) + myFeatures( feat ), + myMode( Native ) { initialize(); } @@ -122,6 +123,7 @@ QFont QtxFontEdit::currentFont() const fnt.setBold( script & Bold ); fnt.setItalic( script & Italic ); fnt.setUnderline( script & Underline ); + fnt.setOverline( script & Shadow ); //addVtkFontPref( tr( "LABELS" ), valLblFontGr, "values_labeling_font" ); return fnt; } @@ -134,18 +136,21 @@ QFont QtxFontEdit::currentFont() const void QtxFontEdit::setCurrentFont( const QFont& fnt ) { myFamily->blockSignals( true ); + myCustomFams->blockSignals( true ); mySize->blockSignals( true ); myB->blockSignals( true ); myI->blockSignals( true ); myU->blockSignals( true ); - + setFontFamily( fnt.family() ); setFontSize( fnt.pointSize() ); setFontScripting( ( fnt.bold() ? Bold : 0 ) | ( fnt.italic() ? Italic : 0 ) | - ( fnt.underline() ? Underline : 0 ) ); + ( fnt.underline() ? Underline : 0 ) | + ( fnt.overline() ? Shadow : 0 ) ); myFamily->blockSignals( false ); + myCustomFams->blockSignals( false ); mySize->blockSignals( false ); myB->blockSignals( false ); myI->blockSignals( false ); @@ -161,7 +166,10 @@ void QtxFontEdit::setCurrentFont( const QFont& fnt ) */ QString QtxFontEdit::fontFamily() const { - return myFamily->currentFont().family(); + if ( myMode == Native ) + return myFamily->currentFont().family(); + else + return myCustomFams->currentText(); } /*! @@ -185,7 +193,8 @@ int QtxFontEdit::fontScripting() const { return ( myB->isChecked() ? Bold : 0 ) | ( myI->isChecked() ? Italic : 0 ) | - ( myU->isChecked() ? Underline : 0 ); + ( myU->isChecked() ? Underline : 0 ) | + ( myS->isChecked() ? Shadow : 0 ) ; } /*! @@ -195,8 +204,17 @@ int QtxFontEdit::fontScripting() const */ void QtxFontEdit::setFontFamily( const QString& fam ) { - myFamily->setCurrentFont( QFont( fam ) ); - onFontChanged( myFamily->currentFont() ); + if ( myMode == Native ) + { + myFamily->setCurrentFont( QFont( fam ) ); + onFontChanged( myFamily->currentFont() ); + } + else + { + myCustomFams->setCurrentIndex( myCustomFams->findText( fam ) ); + if ( !myCustomFams->signalsBlocked() ) + emit( changed( currentFont() ) ); + } } /*! @@ -226,6 +244,7 @@ void QtxFontEdit::setFontScripting( const int script ) myB->setChecked( script & Bold ); myI->setChecked( script & Italic ); myU->setChecked( script & Underline ); + myS->setChecked( script & Shadow ); } /*! @@ -235,11 +254,13 @@ void QtxFontEdit::updateState() { int feat = features(); - myFamily->setVisible( feat & Family ); + myFamily->setVisible( ( feat & Family ) && myMode == Native ); + myCustomFams->setVisible( ( feat & Family ) && myMode == Custom ); mySize->setVisible( feat & Size ); myB->setVisible( feat & Bold ); myI->setVisible( feat & Italic ); myU->setVisible( feat & Underline ); + myS->setVisible( feat & Shadow ); myPreview->setVisible( feat & Preview ); mySize->setEditable( feat & UserSize ); @@ -299,6 +320,7 @@ void QtxFontEdit::initialize() base->setSpacing( 5 ); base->addWidget( myFamily = new QFontComboBox( this ) ); + base->addWidget( myCustomFams = new QComboBox( this ) ); base->addWidget( mySize = new QtxComboBox( this ) ); mySize->setInsertPolicy( QComboBox::NoInsert ); mySize->setValidator( new QIntValidator( 1, 250, mySize ) ); @@ -315,10 +337,15 @@ void QtxFontEdit::initialize() myU->setText( tr( "U" ) ); myU->setCheckable( true ); + base->addWidget( myS = new QToolButton( this ) ); + myS->setText( tr( "S" ) ); + myS->setCheckable( true ); + base->addWidget( myPreview = new QToolButton( this ) ); myPreview->setText( "..." ); myFamily->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); + myCustomFams->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); connect( myPreview, SIGNAL( clicked( bool ) ), this, SLOT( onPreview( bool ) ) ); connect( myFamily, SIGNAL( currentFontChanged( const QFont& ) ), this, SLOT( onFontChanged( const QFont& ) ) ); @@ -328,6 +355,141 @@ void QtxFontEdit::initialize() connect( myI, SIGNAL( toggled( bool ) ), this, SLOT( onPropertyChanged() ) ); connect( myU, SIGNAL( toggled( bool ) ), this, SLOT( onPropertyChanged() ) ); + myCustomFams->hide(); + myS->hide(); + updateState(); onFontChanged( currentFont() ); } + +/*! + \brief Specifies whether widget works in Native or Custom mode. Native mode + is intended for working with system fonts. Custom mode is intended for + working with manually defined set of fonts. Set of custom fonts can be + specified with setCustomFonts() method + \param mode mode from QtxFontEdit::Mode enumeration + \sa mode() +*/ +void QtxFontEdit::setMode( const int mode ) +{ + if ( myMode == mode ) + return; + + myMode = mode; + + myFamily->setShown( myMode == Native ); + myCustomFams->setShown( myMode == Custom ); + + updateGeometry(); +} + +/*! + \brief Verifies whether widget works in Native or Custom mode + \return Native or Custom mode + \sa setMode() +*/ +int QtxFontEdit::mode() const +{ + return myMode; +} + +/*! + \brief Sets list of custom fonts. + This method is intended for working in Custom mode. + \param fams list of families + \sa fonts(), setMode() +*/ +void QtxFontEdit::setFonts( const QStringList& fams ) +{ + QString currFam = myCustomFams->currentText(); + + myCustomFams->clear(); + myCustomFams->addItems( fams ); + + int ind = myCustomFams->findText( currFam ); + if ( ind != -1 ) + myCustomFams->setCurrentIndex( ind ); + + setSizes( QList() ); +} + +/*! + \brief Sets list of available font sizes. + This method is intended for working in Custom mode. The list of sizes can + be empty. In this case system generate listof size automatically from 8 till 72. + \param sizes list of sizes + \sa sizes(), setMode() +*/ +void QtxFontEdit::setSizes( const QList& sizes ) +{ + QString currSize = mySize->currentText(); + + mySize->clear(); + if ( !sizes.isEmpty() ) + { + QStringList szList; + for ( QList::const_iterator it = sizes.begin(); it != sizes.end(); ++it ) + szList.append( QString::number( *it ) ); + mySize->addItems( szList ); + } + else + { + static QStringList defLst; + if ( defLst.isEmpty() ) + { + QString str( "8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72" ); + defLst = str.split( " " ); + } + mySize->addItems( defLst ); + } + + int ind = mySize->findText( currSize ); + if ( ind != -1 ) + mySize->setCurrentIndex( ind ); +} + +/*! + \brief Gets list of custom fonts + \return list of families + \sa setFonts(), setMode() +*/ +QStringList QtxFontEdit::fonts() const +{ + QStringList fams; + for ( int i = 0, n = myCustomFams->count(); i < n; i++ ) + fams.append( myCustomFams->itemText( i ) ); + return fams; +} + +/*! + \brief Gets list of custom fonts + \return list of families + \sa setCustomFonts(), setMode() +*/ +QList QtxFontEdit::sizes() const +{ + QList lst; + for ( int i = 0, n = mySize->count(); i < n; i++ ) + lst.append( mySize->itemText( i ).toInt() ); + return lst; +} + + + + + + + + + + + + + + + + + + + + diff --git a/src/Qtx/QtxFontEdit.h b/src/Qtx/QtxFontEdit.h index 5f0029e0e..8934f9cdd 100644 --- a/src/Qtx/QtxFontEdit.h +++ b/src/Qtx/QtxFontEdit.h @@ -30,6 +30,7 @@ #include class QtxComboBox; +class QComboBox; class QToolButton; class QFontComboBox; @@ -46,11 +47,18 @@ public: Bold = 0x08, //!< show 'bold' widget Italic = 0x10, //!< show 'italic' widget Underline = 0x20, //!< show 'underline' widget - Preview = 0x40, //!< show font preview widget + Shadow = 0x40, //!< show 'shadow' widget + Preview = 0x80, //!< show font preview widget Scripting = Bold | Italic | Underline, //!< show font scripting widgets ('bold','italic','underline') All = Family | Size | UserSize | Scripting | Preview //!< show all font widgets } Features; + typedef enum + { + Native, //!< Native mode intended for working with system fonts + Custom //!< Custom mode intended for working with manually defined set of fonts + } Mode; + public: QtxFontEdit( const int, QWidget* = 0 ); QtxFontEdit( QWidget* = 0 ); @@ -70,6 +78,15 @@ public: int features() const; void setFeatures( const int ); + void setMode( const int ); + int mode() const; + + void setFonts( const QStringList& ); + QStringList fonts() const; + + void setSizes( const QList& = QList() ); + QList sizes() const; + signals: void changed( const QFont& ); @@ -87,7 +104,9 @@ private: QFontComboBox* myFamily; QToolButton* myPreview; int myFeatures; - QToolButton *myB, *myI, *myU; + QToolButton *myB, *myI, *myU, *myS; + int myMode; + QComboBox* myCustomFams; }; #endif // QTXFONTEDIT_H diff --git a/src/Qtx/QtxPagePrefMgr.cxx b/src/Qtx/QtxPagePrefMgr.cxx index 66aad76c9..4d333f884 100644 --- a/src/Qtx/QtxPagePrefMgr.cxx +++ b/src/Qtx/QtxPagePrefMgr.cxx @@ -3081,6 +3081,72 @@ void QtxPagePrefFontItem::setFeatures( const int f ) myFont->setFeatures( f ); } +/*! + \brief Specifies whether widget works in Native or Custom mode. Native mode + is intended for working with system fonts. Custom mode is intended for + working with manually defined set of fonts. Set of custom fonts can be + specified with setFonts() method + \param mode mode from QtxFontEdit::Mode enumeration + \sa mode() +*/ +void QtxPagePrefFontItem::setMode( const int mode ) +{ + myFont->setMode( mode ); +} + +/*! + \brief Verifies whether widget works in Native or Custom mode + \return Native or Custom mode + \sa setMode() +*/ +int QtxPagePrefFontItem::mode() const +{ + return myFont->mode(); +} + +/*! + \brief Sets list of custom fonts. + This method is intended for working in Custom mode only. + \param fams list of families + \sa fonts(), setMode() +*/ +void QtxPagePrefFontItem::setFonts( const QStringList& fams ) +{ + myFont->setFonts( fams ); +} + +/*! + \brief Gets list of custom fonts + \return list of families + \sa setFonts(), setMode() +*/ +QStringList QtxPagePrefFontItem::fonts() const +{ + return myFont->fonts(); +} + +/*! + \brief Sets list of available font sizes. + This method is intended for working in Custom mode only. The list of sizes can + be empty. In this case system generate listof size automatically from 8 till 72. + \param sizes list of sizes + \sa sizes(), setMode() +*/ +void QtxPagePrefFontItem::setSizes( const QList& sizes ) +{ + myFont->setSizes( sizes ); +} + +/*! + \brief Gets list of custom fonts + \return list of families + \sa setFonts(), setMode() +*/ +QList QtxPagePrefFontItem::sizes() const +{ + return myFont->sizes(); +} + /*! \brief Store preference item to the resource manager. \sa retrieve() @@ -3109,6 +3175,18 @@ QVariant QtxPagePrefFontItem::optionValue( const QString& name ) const { if ( name == "features" ) return features(); + else if ( name == "mode" ) + return mode(); + else if ( name == "fonts" || name == "families" ) + return fonts(); + else if ( name == "sizes" ) + { + QList lst; + QList nums = sizes(); + for ( QList::const_iterator it = nums.begin(); it != nums.end(); ++it ) + lst.append( *it ); + return lst; + } else return QtxPageNamedPrefItem::optionValue( name ); } @@ -3126,6 +3204,30 @@ void QtxPagePrefFontItem::setOptionValue( const QString& name, const QVariant& v if ( val.canConvert( QVariant::Int ) ) setFeatures( val.toInt() ); } + else if ( name == "mode" ) + { + if ( val.canConvert( QVariant::Int ) ) + setMode( val.toInt() ); + } + else if ( name == "fonts" || name == "families" ) + { + if ( val.canConvert( QVariant::StringList ) ) + setFonts( val.toStringList() ); + } + else if ( name == "sizes" ) + { + if ( val.type() == QVariant::List ) + { + QList lst; + QList varList = val.toList(); + for ( QList::const_iterator it = varList.begin(); it != varList.end(); ++it ) + { + if ( (*it).canConvert( QVariant::Int ) ) + lst.append( (*it).toInt() ); + } + setSizes( lst ); + } + } else QtxPageNamedPrefItem::setOptionValue( name, val ); } diff --git a/src/Qtx/QtxPagePrefMgr.h b/src/Qtx/QtxPagePrefMgr.h index 9593451d2..28fada6dc 100644 --- a/src/Qtx/QtxPagePrefMgr.h +++ b/src/Qtx/QtxPagePrefMgr.h @@ -544,6 +544,15 @@ public: int features() const; void setFeatures( const int ); + void setMode( const int ); + int mode() const; + + void setFonts( const QStringList& ); + QStringList fonts() const; + + void setSizes( const QList& = QList() ); + QList sizes() const; + virtual void store(); virtual void retrieve(); diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index a97ccedbd..cf91632aa 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -1391,6 +1391,8 @@ bool QtxResourceMgr::value( const QString& sect, const QString& name, QFont& fVa fVal.setItalic( true ); else if ( curval == QString( "underline" ) ) fVal.setUnderline( true ); + else if ( curval == QString( "shadow" ) || curval == QString( "overline" ) ) + fVal.setOverline( true ); else { bool isOk = false; @@ -1826,6 +1828,8 @@ void QtxResourceMgr::setValue( const QString& sect, const QString& name, const Q fontDescr.append( "Italic" ); if ( val.underline() ) fontDescr.append( "Underline" ); + if ( val.overline() ) + fontDescr.append( "Overline" ); fontDescr.append( QString( "%1" ).arg( val.pointSize() ) ); setResource( sect, name, fontDescr.join( "," ) ); diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 8169b55f4..13d537177 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -23,14 +23,17 @@ // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // #include "SalomeApp_DataObject.h" - #include "SalomeApp_Study.h" +#include "SalomeApp_Application.h" #include +#include #include #include +#include + #include #include @@ -251,6 +254,26 @@ QString SalomeApp_DataObject::toolTip( const int /*id*/ ) const { // we ignore parameter in order to use the same tooltip for // all columns + + // Get customized tooltip in case of it exists + const SalomeApp_DataObject* compObj = dynamic_cast( componentObject() ); + // Check if the component has been loaded. + // In order to avoid loading the component only for getting a custom tooltip. + if ( compObj && compObj != this && !ior(compObj->object()).isEmpty() ) { + SalomeApp_Application* app = + dynamic_cast( SUIT_Session::session()->activeApplication() ); + if ( app ) { + Engines::Component_var aComponent = + app->lcc()->FindOrLoad_Component( "FactoryServer", componentDataType().toLatin1().constData() ); + + if ( !CORBA::is_nil(aComponent) && aComponent->hasObjectInfo() ) { + LightApp_RootObject* aRoot = dynamic_cast( root() ); + if ( aRoot && aRoot->study() ) + return QString( aComponent->getObjectInfo( aRoot->study()->id(), entry().toLatin1().constData()) ); + } + } + } + return QString( "Object \'%1\', module \'%2\', ID=%3" ).arg( name() ).arg( componentDataType() ).arg( entry() ); } diff --git a/src/VTKViewer/Makefile.am b/src/VTKViewer/Makefile.am index e6f495533..65a01c533 100755 --- a/src/VTKViewer/Makefile.am +++ b/src/VTKViewer/Makefile.am @@ -22,8 +22,7 @@ # File : Makefile.in # Author : Vladimir Klyachin (OCN) # Module : VTKViewer -# $Header$ -# + include $(top_srcdir)/adm_local/unix/make_common_starter.am lib_LTLIBRARIES = libVTKViewer.la -- 2.39.2