From a8534ff001e5bc9da575c5d2bc9fb4bf3b4a5997 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 8 Aug 2014 19:40:13 +0400 Subject: [PATCH] Preferences created --- src/XGUI/CMakeLists.txt | 2 + src/XGUI/XGUI_Constants.h | 14 ++-- src/XGUI/XGUI_Preferences.cpp | 113 ++++++++++++++++++++++++++++++ src/XGUI/XGUI_Preferences.h | 42 +++++++++++ src/XGUI/XGUI_ViewPort.cpp | 6 +- src/XGUI/XGUI_Viewer.cpp | 4 +- src/XGUI/XGUI_Workshop.cpp | 21 +++--- src/XGUI/XGUI_Workshop.h | 8 +-- src/XGUI/XGUI_pictures.qrc | 3 + src/XGUI/pictures/preferences.png | Bin 0 -> 3664 bytes src/XGUI/pictures/view_prefs.png | Bin 0 -> 790 bytes 11 files changed, 185 insertions(+), 28 deletions(-) create mode 100644 src/XGUI/XGUI_Preferences.cpp create mode 100644 src/XGUI/XGUI_Preferences.h create mode 100644 src/XGUI/pictures/preferences.png create mode 100644 src/XGUI/pictures/view_prefs.png diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index a5a313301..eca046d10 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -31,6 +31,7 @@ SET(PROJECT_HEADERS XGUI_ContextMenuMgr.h XGUI_ModuleConnector.h XGUI_Selection.h + XGUI_Preferences.h ) SET(PROJECT_AUTOMOC @@ -62,6 +63,7 @@ SET(PROJECT_SOURCES XGUI_ContextMenuMgr.cpp XGUI_ModuleConnector.cpp XGUI_Selection.cpp + XGUI_Preferences.cpp ) SET(PROJECT_RESOURCES diff --git a/src/XGUI/XGUI_Constants.h b/src/XGUI/XGUI_Constants.h index 6058ba3b4..5cd0f2523 100644 --- a/src/XGUI/XGUI_Constants.h +++ b/src/XGUI/XGUI_Constants.h @@ -51,13 +51,13 @@ enum Mode2dType }; //! Types of background in view window -enum BackgroundMode -{ - NoBackground, // no (invalid) background data - ColorBackground, // single color - SimpleGradientBackground, // simple two-color gradient - CustomGradientBackground // custom (complex) gradient -}; +//enum BackgroundMode +//{ +// NoBackground, // no (invalid) background data +// ColorBackground, // single color +// SimpleGradientBackground, // simple two-color gradient +// CustomGradientBackground // custom (complex) gradient +//}; //! Texture mode enum TextureMode diff --git a/src/XGUI/XGUI_Preferences.cpp b/src/XGUI/XGUI_Preferences.cpp new file mode 100644 index 000000000..12a21bee5 --- /dev/null +++ b/src/XGUI/XGUI_Preferences.cpp @@ -0,0 +1,113 @@ +// File: XGUI_Preferences.cpp +// Created: 07 Aug 2014 +// Author: Vitaly SMETANNIKOV + +#include "XGUI_Preferences.h" +#include "XGUI_Constants.h" + +#include +#include + +#include +#include +#include + +SUIT_ResourceMgr* XGUI_Preferences::myResourceMgr = 0; + + +SUIT_ResourceMgr* XGUI_Preferences::resourceMgr() +{ + if (!myResourceMgr) { + myResourceMgr = new SUIT_ResourceMgr("NewGeom"); + myResourceMgr->setCurrentFormat("xml"); + } + return myResourceMgr; +} + +void XGUI_Preferences::editPreferences() +{ + XGUI_PreferencesDlg aDlg(resourceMgr(), QApplication::activeWindow()); + aDlg.exec(); +} + + + +//********************************************************** +//********************************************************** +//********************************************************** +XGUI_PreferencesDlg::XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent) + : QDialog(theParent) +{ + setWindowTitle( tr("Edit preferences") ); + + QVBoxLayout* main = new QVBoxLayout(this); + main->setMargin( 5 ); + main->setSpacing( 5 ); + + myPreferences = new SUIT_PreferenceMgr(theResurces, this); + main->addWidget( myPreferences ); + + setFocusProxy( myPreferences ); + myPreferences->setFrameStyle( QFrame::Box | QFrame::Sunken ); + //myPreferences->show(); + + QDialogButtonBox* aBtnBox = new QDialogButtonBox( + QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); + main->addWidget(aBtnBox); + connect(aBtnBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(aBtnBox, SIGNAL(rejected()), this, SLOT(reject())); + + myPreferences->retrieve(); + createEditors(); +} + +XGUI_PreferencesDlg::~XGUI_PreferencesDlg() +{ +} + +void XGUI_PreferencesDlg::createEditors() +{ + int aLFpage = myPreferences->addItem("Look&Feel"); + myPreferences->setItemIcon(aLFpage, QIcon(":pictures/view_prefs.png")); + + int viewTab = myPreferences->addItem( tr("Viewer"), aLFpage ); + + QStringList gradList; + gradList << tr("Horizontal gradient") << tr("Vertical gradient") << + tr("First diagonal gradient") << tr("Second diagonal gradient") << + tr("First corner gradient") << tr("Second corner gradient") << + tr("Third corner gradient") << tr("Fourth corner gradient"); + + QList anIndicesList; + QIntList idList; + idList << XGUI::HorizontalGradient << XGUI::VerticalGradient << + XGUI::Diagonal1Gradient << XGUI::Diagonal2Gradient << + XGUI::Corner1Gradient << XGUI::Corner2Gradient << + XGUI::Corner3Gradient << XGUI::Corner4Gradient; + + foreach(int gid, idList ) anIndicesList << gid; + + int bgGroup = myPreferences->addItem( tr( "Background" ), viewTab ); + + //QIntList txtList; + //txtList << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture; + + QString aImgFiles("Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs)"); + + int bgId = myPreferences->addItem( tr("Viewer 3d" ), bgGroup, + SUIT_PreferenceMgr::Background, "Viewer", "background" ); + myPreferences->setItemProperty( "gradient_names", gradList, bgId ); + //myPreferences->setItemProperty( "gradient_ids", anIndicesList, bgId ); + myPreferences->setItemProperty( "texture_enabled", true, bgId ); + myPreferences->setItemProperty( "texture_center_enabled", true, bgId ); + myPreferences->setItemProperty( "texture_tile_enabled", true, bgId ); + myPreferences->setItemProperty( "texture_stretch_enabled", true, bgId ); + myPreferences->setItemProperty( "custom_enabled", false, bgId ); + myPreferences->setItemProperty( "image_formats", aImgFiles, bgId ); + +} + + + + + diff --git a/src/XGUI/XGUI_Preferences.h b/src/XGUI/XGUI_Preferences.h new file mode 100644 index 000000000..5453ec5a9 --- /dev/null +++ b/src/XGUI/XGUI_Preferences.h @@ -0,0 +1,42 @@ +// File: XGUI_Preferences.h +// Created: 07 Aug 2014 +// Author: Vitaly SMETANNIKOV + +#ifndef XGUI_Preferences_H +#define XGUI_Preferences_H + +#include "XGUI.h" +#include + +class SUIT_ResourceMgr; +class SUIT_PreferenceMgr; +class QWidget; + +class XGUI_EXPORT XGUI_Preferences +{ +public: + + static void editPreferences(); + + static SUIT_ResourceMgr* resourceMgr(); + +private: + static SUIT_ResourceMgr* myResourceMgr; +}; + + +class XGUI_PreferencesDlg: public QDialog +{ + Q_OBJECT +public: + XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0); + virtual ~XGUI_PreferencesDlg(); + +private: + void createEditors(); + + SUIT_PreferenceMgr* myPreferences; +}; + + +#endif \ No newline at end of file diff --git a/src/XGUI/XGUI_ViewPort.cpp b/src/XGUI/XGUI_ViewPort.cpp index 609db462f..f59055beb 100644 --- a/src/XGUI/XGUI_ViewPort.cpp +++ b/src/XGUI/XGUI_ViewPort.cpp @@ -156,7 +156,7 @@ void XGUI_ViewPort::updateBackground() // 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: { + case Qtx::ColorBackground: { QColor c = myBackground.color(); if (c.isValid()) { // Unset texture should be done here @@ -171,7 +171,7 @@ void XGUI_ViewPort::updateBackground() } break; } - case XGUI::SimpleGradientBackground: { + case Qtx::SimpleGradientBackground: { QColor c1, c2; int type = myBackground.gradient(c1, c2); if (c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient) { @@ -222,7 +222,7 @@ void XGUI_ViewPort::updateBackground() } break; } - case XGUI::CustomGradientBackground: + case Qtx::CustomGradientBackground: // NOT IMPLEMENTED YET break; default: diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index c0048f2fa..4f445729b 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -2,7 +2,7 @@ #include "XGUI_MainWindow.h" #include "XGUI_ViewWindow.h" #include "XGUI_ViewPort.h" -#include "XGUI_Workshop.h" +#include "XGUI_Preferences.h" #include @@ -184,7 +184,7 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType) if (myViews.size() == 0) setTrihedronShown(true); - Qtx::BackgroundData aBk = XGUI_Workshop::resourceMgr()->backgroundValue("Viewer", "background"); + Qtx::BackgroundData aBk = XGUI_Preferences::resourceMgr()->backgroundValue("Viewer", "background"); view->setBackground(aBk); view->updateEnabledDrawMode(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index a18688e22..25e616679 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -8,7 +8,6 @@ #include "XGUI_Workbench.h" #include "XGUI_Workshop.h" #include "XGUI_Viewer.h" -#include "ModuleBase_WidgetFactory.h" #include "XGUI_SelectionMgr.h" #include "XGUI_Selection.h" #include "XGUI_ObjectsBrowser.h" @@ -22,6 +21,7 @@ #include "XGUI_PropertyPanel.h" #include "XGUI_ContextMenuMgr.h" #include "XGUI_ModuleConnector.h" +#include "XGUI_Preferences.h" #include #include @@ -44,14 +44,13 @@ #include #include #include +#include "ModuleBase_WidgetFactory.h" #include #include #include #include -#include - #include #include #include @@ -71,8 +70,6 @@ #include #endif -SUIT_ResourceMgr* XGUI_Workshop::myResourceMgr = 0; - QMap XGUI_Workshop::myIcons; QString XGUI_Workshop::featureIcon(const std::string& theId) @@ -92,10 +89,6 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) myObjectBrowser(0), myDisplayer(0) { - if (!myResourceMgr) { - myResourceMgr = new SUIT_ResourceMgr("NewGeom"); - myResourceMgr->setCurrentFormat("xml"); - } myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow(); myDisplayer = new XGUI_Displayer(this); @@ -211,6 +204,10 @@ void XGUI_Workshop::initMenu() // QIcon(":pictures/new.png"), QKeySequence::New); //aCommand->connectTo(this, SLOT(onNew())); + aCommand = aGroup->addFeature("PREF_CMD", tr("Preferences"), tr("Edit preferences"), + QIcon(":pictures/preferences.png"), QKeySequence::Preferences); + aCommand->connectTo(this, SLOT(onPreferences())); + aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"), QIcon(":pictures/close.png"), QKeySequence::Close); aCommand->connectTo(this, SLOT(onExit())); @@ -667,6 +664,12 @@ void XGUI_Workshop::onRedo() updateCommandStatus(); } +//****************************************************** +void XGUI_Workshop::onPreferences() +{ + XGUI_Preferences::editPreferences(); +} + //****************************************************** ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule) { diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index c83583cc0..be2d9a032 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -43,8 +43,6 @@ class ModelAPI_ObjectUpdatedMessage; class ModelAPI_ObjectDeletedMessage; class QAction; -class SUIT_ResourceMgr; - /**\class XGUI_Workshop * \ingroup GUI * \brief Class which defines a configuration of the application (Workshop) and launches it. @@ -113,8 +111,6 @@ public: //! Returns icon name according to feature Id static QString featureIcon(const std::string& theId); - static SUIT_ResourceMgr* resourceMgr() { return myResourceMgr; } - //! Activates or deactivates a part //! If PartPtr is Null pointer then PartSet will be activated void activatePart(ResultPartPtr theFeature); @@ -142,6 +138,7 @@ public slots: void onExit(); void onUndo(); void onRedo(); + void onPreferences(); void showPropertyPanel(); void hidePropertyPanel(); @@ -216,9 +213,6 @@ private: QString myCurrentDir; static QMap myIcons; - - static SUIT_ResourceMgr* myResourceMgr; - }; #endif diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index efd946fcb..8a616c638 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -7,6 +7,7 @@ pictures/redo.png pictures/undo.png pictures/rebuild.png + pictures/preferences.png pictures/occ_view_back.png pictures/occ_view_bottom.png @@ -59,5 +60,7 @@ pictures/rename_edit.png pictures/eye_pencil.png pictures/eye_pencil_closed.png + + pictures/view_prefs.png diff --git a/src/XGUI/pictures/preferences.png b/src/XGUI/pictures/preferences.png new file mode 100644 index 0000000000000000000000000000000000000000..a5f3308a90a2e21ff79c454a32e24b4fc1156ba7 GIT binary patch literal 3664 zcmV-W4zKZvP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?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