From: vsv Date: Fri, 8 Aug 2014 15:40:13 +0000 (+0400) Subject: Preferences created X-Git-Tag: V_0.4.4~114 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a8534ff001e5bc9da575c5d2bc9fb4bf3b4a5997;p=modules%2Fshaper.git Preferences created --- 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 000000000..a5f3308a9 Binary files /dev/null and b/src/XGUI/pictures/preferences.png differ diff --git a/src/XGUI/pictures/view_prefs.png b/src/XGUI/pictures/view_prefs.png new file mode 100644 index 000000000..9c11769f3 Binary files /dev/null and b/src/XGUI/pictures/view_prefs.png differ