From 580494d5bfe1c80d9195ebbf7a18826f67595a91 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 28 Mar 2014 19:09:58 +0400 Subject: [PATCH] Management of View background added --- src/XGUI/CMakeLists.txt | 2 + src/XGUI/XGUI_Constants.h | 23 ++++ src/XGUI/XGUI_ViewBackground.cpp | 214 +++++++++++++++++++++++++++++++ src/XGUI/XGUI_ViewBackground.h | 101 +++++++++++++++ src/XGUI/XGUI_ViewPort.cpp | 122 ++++++++++++++++++ src/XGUI/XGUI_ViewPort.h | 11 +- src/XGUI/XGUI_ViewWindow.cpp | 10 ++ src/XGUI/XGUI_ViewWindow.h | 4 + src/XGUI/XGUI_Viewer.cpp | 29 ++++- src/XGUI/XGUI_Viewer.h | 2 + src/XGUI/XGUI_msg_en.ts | 39 ++++++ 11 files changed, 554 insertions(+), 3 deletions(-) create mode 100644 src/XGUI/XGUI_ViewBackground.cpp create mode 100644 src/XGUI/XGUI_ViewBackground.h diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index b3e1c6058..e749048fc 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -18,6 +18,7 @@ SET(PROJECT_HEADERS XGUI_Viewer.h XGUI_RubberBand.h XGUI_Constants.h + XGUI_ViewBackground.h ) SET(PROJECT_AUTOMOC @@ -37,6 +38,7 @@ SET(PROJECT_SOURCES XGUI_ViewPort.cpp XGUI_Viewer.cpp XGUI_RubberBand.cpp + XGUI_ViewBackground.cpp ) SET(PROJECT_RESOURCES diff --git a/src/XGUI/XGUI_Constants.h b/src/XGUI/XGUI_Constants.h index 1b9c909c7..ceb93cc1f 100644 --- a/src/XGUI/XGUI_Constants.h +++ b/src/XGUI/XGUI_Constants.h @@ -2,10 +2,18 @@ #ifndef XGUI_Constants_H #define XGUI_Constants_H +#include + +typedef QList QIntList; //!< list of int values +typedef QList QShortList; //!< list of short int values +typedef QList QDoubleList; //!< list of double values + + namespace XGUI { enum GradientType { + NoGradient = -1, HorizontalGradient, VerticalGradient, Diagonal1Gradient, Diagonal2Gradient, Corner1Gradient, Corner2Gradient, @@ -23,6 +31,21 @@ enum InteractionStyle { STANDARD, KEY_FREE }; enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane}; +enum BackgroundMode { + NoBackground, // no (invalid) background data + ColorBackground, // single color + SimpleGradientBackground, // simple two-color gradient + CustomGradientBackground // custom (complex) gradient +}; + + //! Texture mode +enum TextureMode { + CenterTexture, // center texture + TileTexture, // tile texture + StretchTexture, // stretch texture +}; + + }; #endif \ No newline at end of file diff --git a/src/XGUI/XGUI_ViewBackground.cpp b/src/XGUI/XGUI_ViewBackground.cpp new file mode 100644 index 000000000..0c9d50543 --- /dev/null +++ b/src/XGUI/XGUI_ViewBackground.cpp @@ -0,0 +1,214 @@ +#include "XGUI_ViewBackground.h" + + +/*! + \brief Default constructor. + Creates invalid background data. +*/ +XGUI_ViewBackground::XGUI_ViewBackground() + : myTextureMode( XGUI::CenterTexture ), + myGradientType( XGUI::NoGradient ), + myTextureShown( false ) +{ + setMode( XGUI::NoBackground ); +} + +/*! + \brief Constructor. + Creates background data initialized with the specified color + \param c color +*/ +XGUI_ViewBackground::XGUI_ViewBackground( const QColor& theColor ) + : myTextureMode( XGUI::CenterTexture ), + myGradientType( XGUI::NoGradient ), + myTextureShown( false ) +{ + setColor( theColor ); +} + +/*! + \brief Constructor. + Creates background data initialized with the specified two-color gradient + \param type gradient type identifier + \param c1 first gradient color + \param c2 second gradient color + \note the interpretation of the gradient identifier should be done in the calling code +*/ +XGUI_ViewBackground::XGUI_ViewBackground( XGUI::GradientType type, const QColor& c1, const QColor& c2 ) + : myTextureMode( XGUI::CenterTexture ), + myGradientType( XGUI::NoGradient ), + myTextureShown( false ) +{ + setGradient( type, c1, c2 ); +} + +/*! + \brief Constructor. + Creates background data initialized with the arbirtary gradient data + \param grad gradient data +*/ +XGUI_ViewBackground::XGUI_ViewBackground( const QGradient& grad ) + : myTextureMode( XGUI::CenterTexture ), + myGradientType( XGUI::NoGradient ), + myTextureShown( false ) +{ + setGradient( grad ); +} + +/*! + \brief Destructor. +*/ +XGUI_ViewBackground::~XGUI_ViewBackground() +{ +} + +/*! + \brief Compares two background data objects +*/ +bool XGUI_ViewBackground::operator==( const XGUI_ViewBackground& other ) const +{ + return + ( myMode == other.myMode ) && + ( myTextureMode == other.myTextureMode ) && + ( myFileName == other.myFileName ) && + ( myColors == other.myColors ) && + ( myGradientType == other.myGradientType ) && + ( myGradient == other.myGradient ) && + ( myTextureShown == other.myTextureShown ); +} + +/*! + \brief Returns \c false if background data is not set (invalid) + \return \c true if background data is valid or \c false otherwise + \sa mode() +*/ +bool XGUI_ViewBackground::isValid() const +{ + return myMode != XGUI::NoBackground; +} + + +/*! + \brief Get file name used as a texture image + \return path to the texture image file + \sa setTexture(), setTextureShown() +*/ +XGUI::TextureMode XGUI_ViewBackground::texture( QString& fileName ) const +{ + fileName = myFileName; + return myTextureMode; +} + +/*! + \brief Set file name to be used as a texture image. + + \note To show texture image on the background it is necessary to call additionally + setTextureShown() method. + + \param fileName path to the texture image file name + \param m texture mode (CenterTexture by default) + \sa texture(), setTextureShown() +*/ +void XGUI_ViewBackground::setTexture( const QString& fileName, const XGUI::TextureMode m ) +{ + myFileName = fileName; + myTextureMode = m; +} + +/*! + \brief Check if "show texture" flag is switched on + \return \c true if "show texture" flag is set or \c false otherwise + \sa setTextureShown(), texture() +*/ +bool XGUI_ViewBackground::isTextureShown() const +{ + return myTextureShown; +} + +/*! + \brief Specify if texture should be shown on the background or no. + \param on \c true if texture should be shown or \c false otherwise + \sa isTextureShown(), texture() +*/ +void XGUI_ViewBackground::setTextureShown( bool on ) +{ + myTextureShown = on; +} + +/*! + \brief Get background color. Returns null QColor if color is not set + \return solid background color + \sa setColor(), mode() +*/ +QColor XGUI_ViewBackground::color() const +{ + return myColors.count() > 0 ? myColors[0] : QColor(); +} + +/*! + \brief Set background color and switch to the ColorBackground mode + \param c color + \sa color(), mode() +*/ +void XGUI_ViewBackground::setColor( const QColor& c ) +{ + myColors.clear(); + myColors << c; + setMode( XGUI::ColorBackground ); +} + +/*! + \brief Get simple gradient data. + Returns -1 and null QColor for \a c1 and \a c2 if gradient data is not set + \param c1 first gradient color is returned via this parameter + \param c2 second gradient color is returned via this parameter + \return current two-colored gradient mode type identifier + \note the interpretation of the gradient identifier should be done in the calling code + \sa setGradient(int, const QColor&, const QColor&), mode() +*/ +int XGUI_ViewBackground::gradient( QColor& c1, QColor& c2 ) const +{ + c1 = myColors.count() > 0 ? myColors[0] : QColor(); + c2 = myColors.count() > 1 ? myColors[1] : ( myColors.count() > 0 ? myColors[0] : QColor() ); + return myGradientType; +} + +/*! + \brief Set simple background gradient data and switch to the SimpleGradientBackground mode + \param type two-colored gradient mode type identifier + \param c1 first gradient color is returned via this parameter + \param c2 second gradient color is returned via this parameter + \note the interpretation of the gradient identifier should be done in the calling code + \sa gradient(QColor&, QColor&), mode() +*/ +void XGUI_ViewBackground::setGradient( XGUI::GradientType type, const QColor& c1, const QColor& c2 ) +{ + myColors.clear(); + myColors << c1 << c2; + myGradientType = type; + setMode( XGUI::SimpleGradientBackground ); +} + +/*! + \brief Get complex gradient data. + Returns QGradient of QGradient::NoGradient if gradient data is not set + \note This function does not transform simple gradient data set with + setGradient( const QString&, const QColor&, const QColor& ) to QGradient class + \return gradient data + \sa setGradient(const QGradient&), mode() +*/ +const QGradient* XGUI_ViewBackground::gradient() const +{ + return &myGradient; +} + +/*! + \brief Set complex background gradient data and switch to the CustomGradientBackground mode + \param grad gradient data (QLinearGradient, QRadialGradient or QConicalGradient) + \sa gradient(), mode() +*/ +void XGUI_ViewBackground::setGradient( const QGradient& grad ) +{ + myGradient = grad; + setMode( XGUI::CustomGradientBackground ); +} diff --git a/src/XGUI/XGUI_ViewBackground.h b/src/XGUI/XGUI_ViewBackground.h new file mode 100644 index 000000000..1906001da --- /dev/null +++ b/src/XGUI/XGUI_ViewBackground.h @@ -0,0 +1,101 @@ + +#ifndef XGUI_ViewBackground_H +#define XGUI_ViewBackground_H + +#include "XGUI_Constants.h" + +#include +#include +#include +#include + +typedef QList QColorList; //!< list of colors + +/*! + \class XGUI_ViewBackground + \brief Stores background data + + This class is used to store background data. Depending on the mode, + the background can be specified by: + - image (by assigning the file name to be used as background texture), see setTexture(), setTextureShown() + - single color (by assigning any color), see setColor() + - simple two-color gradient (with the gradient type id and two colors), see setGradient( int, const QColor&, const QColor& ) + - complex gradient (by assigning arbitrary gradient data), see setGradient( const QGradient& ) + + The class stores all the data passed to it, so switching between different modes can be done + just by calling setMode() function. + + \note Texture is used with combination of the background mode. + + \note Two-color gradient is specified by two colors and integer identifier. The interpretation of + this identifier should be done in the calling code. + + \code + XGUI_ViewBackground bg; + bg.setColor( QColor(100, 100, 100) ); // bg is switched to ColorBackground mode + bg.setGradient( Qt::Horizontal, Qt::gray, Qt::white ); // bg is switched to ColorBackground mode + QLinearGradient grad( 0,0,1,1 ); + grad.setColorAt( 0.0, Qt::gray ); + grad.setColorAt( 0.5, Qt::white ); + grad.setColorAt( 1.0, Qt::green ); + grad.setSpread( QGradient::PadSpread ); + bg.setGradient( grad ); // bg is switched to CustomGradientBackground mode + bg.setMode( ColorBackground ); // bg is switched back to ColorBackground mode + bg.setTexture( "/data/images/background.png" ); // specify texture (in the centered mode by default) + bg.setTextureShown( true ); // draw texture on the solid color background + \endcode +*/ +class XGUI_ViewBackground +{ +public: + XGUI_ViewBackground(); + XGUI_ViewBackground( const QColor& theColor ); + XGUI_ViewBackground( XGUI::GradientType type, const QColor& theColor1, const QColor& theColor2); + XGUI_ViewBackground( const QGradient& ); + virtual ~XGUI_ViewBackground(); + + bool operator==( const XGUI_ViewBackground&) const; + inline bool operator!=( const XGUI_ViewBackground& other ) const + { return !operator==( other ); } + + bool isValid() const; + + /*! + \brief Get background mode + \return current background mode + \sa setMode() + */ + XGUI::BackgroundMode mode() const { return myMode; } + + /*! + \brief Set background mode + \param m background mode being set + \sa mode() + */ + void setMode( const XGUI::BackgroundMode m ) { myMode = m; } + + XGUI::TextureMode texture( QString& ) const; + void setTexture( const QString&, XGUI::TextureMode = XGUI::CenterTexture ); + bool isTextureShown() const; + void setTextureShown( bool ); + + QColor color() const; + void setColor( const QColor& ); + + int gradient( QColor&, QColor& ) const; + void setGradient( XGUI::GradientType, const QColor&, const QColor& ); + + const QGradient* gradient() const; + void setGradient( const QGradient& ); + +private: + XGUI::BackgroundMode myMode; + XGUI::TextureMode myTextureMode; + QString myFileName; + QColorList myColors; + XGUI::GradientType myGradientType; + QGradient myGradient; + bool myTextureShown; +}; + +#endif \ No newline at end of file diff --git a/src/XGUI/XGUI_ViewPort.cpp b/src/XGUI/XGUI_ViewPort.cpp index 290cf7a33..b8ec91582 100644 --- a/src/XGUI/XGUI_ViewPort.cpp +++ b/src/XGUI/XGUI_ViewPort.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -330,6 +331,115 @@ bool XGUI_ViewPort::mapped( const Handle(V3d_View)& theView) const //*********************************************** void XGUI_ViewPort::updateBackground() { + if ( activeView().IsNull() ) return; + if ( !myBackground.isValid() ) return; + + // VSR: Important note on below code. + // In OCCT (in version 6.5.2), things about the background drawing + // are not straightforward and not clearly understandable: + // - Horizontal gradient is drawn vertically (!), well ok, from top side to bottom one. + // - Vertical gradient is drawn horizontally (!), from right side to left one (!!!). + // - First and second diagonal gradients are confused. + // - Image texture, once set, can not be removed (!). + // - Texture image fill mode Aspect_FM_NONE is not taken into account (and means the same + // as Aspect_FM_CENTERED). + // - The only way to cancel gradient background (and get back to single colored) is to + // set gradient background style to Aspect_GFM_NONE while passing two colors is also needed + // (see V3d_View::SetBgGradientColors() function). + // - Also, it is impossible to draw texture image above the gradiented background (only above + // single-colored). + // In OCCT 6.5.3 all above mentioned problems are fixed; so, above comment should be removed as soon + // as SALOME is migrated to OCCT 6.5.3. The same concerns #ifdef statements in the below code + switch ( myBackground.mode() ) { + case XGUI::ColorBackground: + { + QColor c = myBackground.color(); + if ( c.isValid() ) { + // Unset texture should be done here + // ... + Quantity_Color qCol( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB ); + activeView()->SetBgGradientStyle( Aspect_GFM_NONE ); // cancel gradient background + activeView()->SetBgImageStyle( Aspect_FM_NONE ); // cancel texture background + // then change background color + activeView()->SetBackgroundColor( qCol ); + // update viewer + activeView()->Update(); + } + break; + } + case XGUI::SimpleGradientBackground: + { + QColor c1, c2; + int type = myBackground.gradient( c1, c2 ); + if ( c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient ) { + // Unset texture should be done here + // ... + // Get colors and set-up gradiented background + if ( !c2.isValid() ) c2 = c1; + Quantity_Color qCol1( c1.red()/255., c1.green()/255., c1.blue()/255., Quantity_TOC_RGB ); + Quantity_Color qCol2( c2.red()/255., c2.green()/255., c2.blue()/255., Quantity_TOC_RGB ); + activeView()->SetBgImageStyle( Aspect_FM_NONE ); // cancel texture background + switch ( type ) { + case XGUI::HorizontalGradient: + activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_HOR, Standard_True ); + break; + case XGUI::VerticalGradient: + activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_VER, Standard_True ); + break; + case XGUI::Diagonal1Gradient: + activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_DIAG1, Standard_True ); + break; + case XGUI::Diagonal2Gradient: + activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_DIAG2, Standard_True ); + break; + case XGUI::Corner1Gradient: + activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_CORNER1, Standard_True ); + break; + case XGUI::Corner2Gradient: + activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_CORNER2, Standard_True ); + break; + case XGUI::Corner3Gradient: + activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_CORNER3, Standard_True ); + break; + case XGUI::Corner4Gradient: + activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_CORNER4, Standard_True ); + break; + default: + break; + } + } + break; + } + case XGUI::CustomGradientBackground: + // NOT IMPLEMENTED YET + break; + default: + break; + } + // VSR: In OCCT before v6.5.3 below code can't be used because of very ugly bug - it has been impossible to + // clear the background texture image as soon as it was once set to the viewer. + if ( myBackground.isTextureShown() ) { + QString fileName; + int textureMode = myBackground.texture( fileName ); + QFileInfo fi( fileName ); + if ( !fileName.isEmpty() && fi.exists() ) { + // set texture image: file name and fill mode + switch ( textureMode ) { + case XGUI::CenterTexture: + activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_CENTERED ); + break; + case XGUI::TileTexture: + activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_TILED ); + break; + case XGUI::StretchTexture: + activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_STRETCH ); + break; + default: + break; + } + activeView()->Update(); + } + } } //*********************************************** @@ -594,3 +704,15 @@ void XGUI_ViewPort::zoom( int x0, int y0, int x, int y ) emit vpTransformed( ); } } + +/*! + Sets the background data +*/ +void XGUI_ViewPort::setBackground( const XGUI_ViewBackground& bgData ) +{ + if ( bgData.isValid() ) { + myBackground = bgData; + updateBackground(); + emit vpChangeBackground( myBackground ); + } +} diff --git a/src/XGUI/XGUI_ViewPort.h b/src/XGUI/XGUI_ViewPort.h index 144fcfa21..cd79d564e 100644 --- a/src/XGUI/XGUI_ViewPort.h +++ b/src/XGUI/XGUI_ViewPort.h @@ -2,6 +2,8 @@ #ifndef XGUI_ViewPort_H #define XGUI_ViewPort_H +#include "XGUI_ViewBackground.h" + #include #include #include @@ -38,8 +40,11 @@ public: void setAdvancedZoomingEnabled( const bool theState ) { myIsAdvancedZoomingEnabled = theState; } bool isAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; } + XGUI_ViewBackground background() const { return myBackground; } + void setBackground( const XGUI_ViewBackground& bgData ); + signals: - //void vpChangeBackground( const Qtx::BackgroundData& ); + void vpChangeBackground( const XGUI_ViewBackground& ); void vpClosed(); void vpMapped(); void vpTransformed( ); @@ -70,6 +75,10 @@ private: bool myIsAdvancedZoomingEnabled; double myScale; + + XGUI_ViewBackground myBackground; + int myBgImgHeight; + int myBgImgWidth; }; diff --git a/src/XGUI/XGUI_ViewWindow.cpp b/src/XGUI/XGUI_ViewWindow.cpp index e80228be6..eb851c800 100644 --- a/src/XGUI/XGUI_ViewWindow.cpp +++ b/src/XGUI/XGUI_ViewWindow.cpp @@ -890,3 +890,13 @@ void XGUI_ViewWindow::resetState() setTransformInProcess( false ); setTransformRequested( NOTHING ); } + +XGUI_ViewBackground XGUI_ViewWindow::background() const +{ + return myViewPort ? myViewPort->background() : XGUI_ViewBackground(); +} + +void XGUI_ViewWindow::setBackground( const XGUI_ViewBackground& theBackground ) +{ + if ( myViewPort ) myViewPort->setBackground( theBackground ); +} diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h index c3dd02444..1d794e94d 100644 --- a/src/XGUI/XGUI_ViewWindow.h +++ b/src/XGUI/XGUI_ViewWindow.h @@ -2,6 +2,7 @@ #define XGUI_ViewWindow_H #include "XGUI_Constants.h" +#include "XGUI_ViewBackground.h" #include #include @@ -40,6 +41,9 @@ public: void setTransformEnabled( const OperationType, const bool ); bool transformEnabled( const OperationType ) const; + XGUI_ViewBackground background() const; + void setBackground( const XGUI_ViewBackground& theBackground ); + signals: void vpTransformationStarted(XGUI_ViewWindow::OperationType type); void vpTransformationFinished(XGUI_ViewWindow::OperationType type); diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index 485ae6008..77b61acca 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -58,6 +58,29 @@ Handle(V3d_Viewer) CreateViewer( const Standard_ExtString name, } +// VSR: Uncomment below line to allow texture background support in OCC viewer +#define OCC_ENABLE_TEXTURED_BACKGROUND + +/*! + Get data for supported background modes: gradient types, identifiers and supported image formats +*/ +QString XGUI_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList ) +{ + gradList << tr("GT_HORIZONTALGRADIENT") << tr("GT_VERTICALGRADIENT") << + tr("GT_FIRSTDIAGONALGRADIENT") << tr("GT_SECONDDIAGONALGRADIENT") << + tr("GT_FIRSTCORNERGRADIENT") << tr("GT_SECONDCORNERGRADIENT") << + tr("GT_THIRDCORNERGRADIENT") << tr("GT_FORTHCORNERGRADIENT"); + idList << XGUI::HorizontalGradient << XGUI::VerticalGradient << + XGUI::Diagonal1Gradient << XGUI::Diagonal2Gradient << + XGUI::Corner1Gradient << XGUI::Corner2Gradient << + XGUI::Corner3Gradient << XGUI::Corner4Gradient; +#ifdef OCC_ENABLE_TEXTURED_BACKGROUND + txtList << XGUI::CenterTexture << XGUI::TileTexture << XGUI::StretchTexture; +#endif + return tr("BG_IMAGE_FILES"); +} + + XGUI_Viewer::XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron) : QObject(theParent), @@ -102,7 +125,6 @@ QObject(theParent), // init CasCade viewers myV3dViewer = CreateViewer(TCollection_ExtendedString("Viewer3d").ToExtString(), "", "", 1000.0, V3d_XposYnegZpos, Standard_True, Standard_True ); - //myV3dViewer->Init(); // to avoid creation of the useless perspective view (see OCCT issue 0024267) myV3dViewer->SetDefaultLights(); // init selector @@ -118,7 +140,6 @@ QObject(theParent), myTrihedron->SetInfiniteState( Standard_True ); Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB); - //myTrihedron->SetColor( Col ); myTrihedron->SetArrowColor( Col.Name() ); myTrihedron->SetSize(myTrihedronSize); Handle(AIS_Drawer) drawer = myTrihedron->Attributes(); @@ -136,6 +157,8 @@ QObject(theParent), XGUI_Viewer::~XGUI_Viewer(void) { + myAISContext.Nullify(); + myV3dViewer.Nullify(); } @@ -153,6 +176,8 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType) connect(view->viewPort(), SIGNAL(vpClosed()), this, SLOT(onViewClosed())); connect(view->viewPort(), SIGNAL(vpMapped()), this, SLOT(onViewMapped())); + view->setBackground(XGUI_ViewBackground(XGUI::VerticalGradient, Qt::green, Qt::blue)); + QMdiArea* aMDI = myMainWindow->mdiArea(); QMdiSubWindow* aWnd = aMDI->addSubWindow(view, Qt::FramelessWindowHint); aWnd->setGeometry(0,0, aMDI->width() / 2, aMDI->height() / 2); diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index 363a2c140..78cfe55a5 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -18,6 +18,8 @@ class XGUI_Viewer : public QObject { Q_OBJECT public: + static QString backgroundData( QStringList&, QIntList&, QIntList& ); + XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron = true); ~XGUI_Viewer(); diff --git a/src/XGUI/XGUI_msg_en.ts b/src/XGUI/XGUI_msg_en.ts index a8ffce717..55984e580 100644 --- a/src/XGUI/XGUI_msg_en.ts +++ b/src/XGUI/XGUI_msg_en.ts @@ -117,4 +117,43 @@ Menu + + XGUI_Viewer + + GT_HORIZONTALGRADIENT + Horizontal gradient + + + GT_VERTICALGRADIENT + Vertical gradient + + + GT_FIRSTDIAGONALGRADIENT + First diagonal gradient + + + GT_SECONDDIAGONALGRADIENT + Second diagonal gradient + + + GT_FIRSTCORNERGRADIENT + First corner gradient + + + GT_SECONDCORNERGRADIENT + Second corner gradient + + + GT_THIRDCORNERGRADIENT + Third corner gradient + + + GT_FORTHCORNERGRADIENT + Fourth corner gradient + + + BG_IMAGE_FILES + Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs) + + -- 2.39.2