From 798cc03ccedd7df6f2624fe14c07fef76ce14d56 Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 23 Nov 2006 13:01:21 +0000 Subject: [PATCH] Cache properties dialog --- idl/VISU_Gen.idl | 18 ++++ resources/SalomeApp.xml | 2 + src/VISUGUI/Makefile.in | 6 +- src/VISUGUI/VISU_msg_en.po | 15 +++ src/VISUGUI/VisuGUI.cxx | 50 +++++++-- src/VISUGUI/VisuGUI.h | 2 + src/VISUGUI/VisuGUI_ActionsDef.h | 2 + src/VISUGUI/VisuGUI_CacheDlg.cxx | 139 +++++++++++++++++++++++++ src/VISUGUI/VisuGUI_CacheDlg.h | 66 ++++++++++++ src/VISU_I/VISU_ColoredPrs3dCache_i.cc | 31 ++++++ src/VISU_I/VISU_ColoredPrs3dCache_i.hh | 23 +++- 11 files changed, 345 insertions(+), 9 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_CacheDlg.cxx create mode 100644 src/VISUGUI/VisuGUI_CacheDlg.h diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 310b95af..51da0b6e 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -627,6 +627,24 @@ module VISU { */ interface ColoredPrs3dCache : PrsObject, SALOME::GenericObj { + /*! + * This enumeration contains the cache memory modes. + */ + enum MemoryMode { + MINIMAL, /*!< Minimal memory mode (default behaviour). */ + LIMITED /*!< Limited memory mode (fixed memory size for presentations). */ + }; + + /*! + * Sets a memory mode. + */ + void SetMemoryMode(in MemoryMode theMode); + + /*! + * Sets a memory size for limited mode. + */ + void SetLimitedMemory(in long theMemorySize); + /*! * Creates %ColoredPrs3dHolder. */ diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 5488527c..d388080a 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -109,6 +109,8 @@ + +
diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index 369dcaf9..a6626b1a 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -77,7 +77,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_TransparencyDlg.cxx \ VisuGUI_Timer.cxx \ VisuGUI_Slider.cxx \ - VisuGUI_InputPane.cxx + VisuGUI_InputPane.cxx \ + VisuGUI_CacheDlg.cxx LIB_MOC = VisuGUI.h \ VisuGUI_Module.h \ @@ -104,7 +105,8 @@ LIB_MOC = VisuGUI.h \ VisuGUI_BuildProgressDlg.h \ VisuGUI_TransparencyDlg.h \ VisuGUI_Slider.h \ - VisuGUI_InputPane.h + VisuGUI_InputPane.h \ + VisuGUI_CacheDlg.h LIB_CLIENT_IDL = SALOME_Exception.idl \ VISU_Gen.idl \ diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 3dde5df0..867b914a 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -401,6 +401,9 @@ msgstr "Arrange Actors" msgid "VisuGUI::MEN_PLOT3D_FROM_CUTPLANE" msgstr "Plot3d" +msgid "VisuGUI::MEN_CACHE_PROPERTIES" +msgstr "Properties" + msgid "VisuGUI::ERR_ERROR_DURING_EXPORT" msgstr "Error has been occured during exporting to file" @@ -1729,6 +1732,18 @@ msgstr "Opaque" msgid "VisuGUI_TransparencyDlg::BUT_CLOSE" msgstr "Close" +msgid "VisuGUI_CacheDlg::CACHE_TITLE" +msgstr "Cache properties" + +msgid "VisuGUI_CacheDlg::MEMORY_MODE" +msgstr "Memory mode" + +msgid "VisuGUI_CacheDlg::MINIMAL_MEMORY" +msgstr "Minimal memory" + +msgid "VisuGUI_CacheDlg::LIMITED_MEMORY" +msgstr "Limited memory" + msgid "VVTK_ViewManager::VTK_VIEW_TITLE" msgstr "Gauss scene:%1 - viewer:%2" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 10829547..17d86621 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -87,6 +87,8 @@ #include "VISU_View_i.hh" #include "VISU_ViewManager_i.hh" #include "VISU_Plot3D_i.hh" +#include "VISU_ColoredPrs3dCache_i.hh" +#include "VISU_ColoredPrs3dHolder_i.hh" #include "VISU_Actor.h" @@ -105,6 +107,7 @@ #include "VisuGUI_Displayer.h" #include "VisuGUI_BuildProgressDlg.h" #include "VisuGUI_TransparencyDlg.h" +#include "VisuGUI_CacheDlg.h" #include "VISU_ScalarMap_i.hh" #include "VisuGUI_ScalarBarDlg.h" @@ -130,8 +133,6 @@ #include "VISU_Vectors_i.hh" #include "VisuGUI_VectorsDlg.h" -#include "VISU_ColoredPrs3dHolder_i.hh" - #include "VisuGUI_TableDlg.h" #include "SALOMEconfig.h" @@ -2297,6 +2298,10 @@ createActions() createAction( VISU_PLOT3D_FROM_CUTPLANE, tr("MEN_PLOT3D_FROM_CUTPLANE"), QIconSet(aPixmap), tr("MEN_PLOT3D_FROM_CUTPLANE"), "", 0, aParent, false, this, SLOT(OnPlot3dFromCutPlane())); + + createAction( VISU_CACHE_PROPERTIES, tr("MEN_CACHE_PROPERTIES"), QIconSet(), + tr("MEN_CACHE_PROPERTIES"), "", 0, aParent, false, + this, SLOT(OnCacheProperties())); } void @@ -2742,6 +2747,16 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q if (isOneCutPlane) action( VISU_PLOT3D_FROM_CUTPLANE )->addTo(theMenu); + Handle(SALOME_InteractiveObject) anIO; + VISU::Storable::TRestoringMap aMap; + CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap); + + if (!CORBA::is_nil(anObject)) { + VISU::Base_i* aBase = dynamic_cast(VISU::GetServant(anObject).in()); + if (aBase && aBase->GetType() == VISU::TCOLOREDPRS3DCACHE) + action( VISU_CACHE_PROPERTIES )->addTo(theMenu); + } + theMenu->insertSeparator(); // Check if some (nb > 0) removable objects selected @@ -2758,10 +2773,6 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q // Check single selection if (aListIO.Extent() != 1) return; - Handle(SALOME_InteractiveObject) anIO; - VISU::Storable::TRestoringMap aMap; - CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap); - _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry()); if ( !SO ) return; @@ -3350,3 +3361,30 @@ void VisuGUI::OnPlot3dFromCutPlane() application()->putInfo(QObject::tr("INF_DONE")); } } + +void VisuGUI::OnCacheProperties() +{ + CORBA::Object_var anObject = GetSelectedObj( this ); + if( CORBA::is_nil( anObject ) ) + return; + + VISU::ColoredPrs3dCache_i* aCache = dynamic_cast(VISU::GetServant(anObject).in()); + if( !aCache ) + return; + + VisuGUI_CacheDlg* aDlg = new VisuGUI_CacheDlg( this, + aCache->GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED, + aCache->GetLimitedMemory() ); + if( !aDlg->exec() ) + return; + + if( aDlg->isLimitedMemory() ) + { + aCache->SetMemoryMode( VISU::ColoredPrs3dCache::LIMITED ); + aCache->SetLimitedMemory( aDlg->getLimitedMemory() ); + } + else + aCache->SetMemoryMode( VISU::ColoredPrs3dCache::MINIMAL ); + + delete aDlg; +} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index e486ca10..a22dc200 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -160,6 +160,8 @@ protected slots: void OnArrangeActors(); void OnPlot3dFromCutPlane(); + void OnCacheProperties(); + protected: virtual LightApp_Selection* createSelection() const; diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 0eaa8676..ca414299 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -114,4 +114,6 @@ #define VISU_PLOT3D_FROM_CUTPLANE 4085 +#define VISU_CACHE_PROPERTIES 4090 + #endif diff --git a/src/VISUGUI/VisuGUI_CacheDlg.cxx b/src/VISUGUI/VisuGUI_CacheDlg.cxx new file mode 100644 index 00000000..0e7e434f --- /dev/null +++ b/src/VISUGUI/VisuGUI_CacheDlg.cxx @@ -0,0 +1,139 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VisuGUI_CacheDlg.cxx +// Author : Oleg UVAROV +// Module : VISU + +#include "VisuGUI_CacheDlg.h" + +#include "VisuGUI_Tools.h" + +#include "VISU_ColoredPrs3dCache_i.hh" + +#include "SUIT_Desktop.h" +#include "SUIT_MessageBox.h" +#include "SUIT_Session.h" + +#include "SalomeApp_Module.h" + +#include "LightApp_Application.h" + +#include +#include +#include +#include +#include +#include +#include + +VisuGUI_CacheDlg::VisuGUI_CacheDlg( SalomeApp_Module* theModule, bool theIsLimitedMemory, long theLimitedMemory ) + : QDialog( VISU::GetDesktop( theModule ), "VisuGUI_CacheDlg", true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "CACHE_TITLE" ) ); + + QVBoxLayout* aTopLayout = new QVBoxLayout( this ); + aTopLayout->setSpacing( 6 ); + aTopLayout->setMargin( 6 ); + aTopLayout->setAutoAdd( true ); + + // Settings + QButtonGroup* aMemoryGroup = new QButtonGroup( 2, Qt::Vertical, tr( "MEMORY_MODE" ), this ); + aMemoryGroup->setRadioButtonExclusive( true ); + + myLimitedMemoryButton = new QRadioButton( tr( "LIMITED_MEMORY" ), aMemoryGroup ); + myLimitedMemoryButton->setChecked( theIsLimitedMemory ); + + myMimimalMemoryButton = new QRadioButton( tr( "MINIMAL_MEMORY" ), aMemoryGroup ); + myMimimalMemoryButton->setChecked( !theIsLimitedMemory ); + + myLimitedMemory = new QSpinBox( 1, 5000, 1, aMemoryGroup ); + myLimitedMemory->setSuffix( " Mb" ); + myLimitedMemory->setValue( theLimitedMemory ); + myLimitedMemory->setEnabled( theIsLimitedMemory ); + + connect( myLimitedMemoryButton, SIGNAL( toggled( bool ) ), myLimitedMemory, SLOT( setEnabled( bool ) ) ); + + // Ok / Cancel + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" ); + buttonHelp->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonHelp, 0, 3 ); + + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); +} + +VisuGUI_CacheDlg::~VisuGUI_CacheDlg() +{ +} + +bool VisuGUI_CacheDlg::isLimitedMemory() +{ + return myLimitedMemoryButton->isChecked(); +} + +int VisuGUI_CacheDlg::getLimitedMemory() +{ + return myLimitedMemory->value(); +} + +void VisuGUI_CacheDlg::accept() +{ + QDialog::accept(); +} + +void VisuGUI_CacheDlg::onHelp() +{ + QString aHelpFileName;// = "types_of_gauss_points_presentations.htm"; + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(app->activeModule() ? + app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName); + else { + SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName), + QObject::tr("BUT_OK")); + } +} diff --git a/src/VISUGUI/VisuGUI_CacheDlg.h b/src/VISUGUI/VisuGUI_CacheDlg.h new file mode 100644 index 00000000..aea2afe6 --- /dev/null +++ b/src/VISUGUI/VisuGUI_CacheDlg.h @@ -0,0 +1,66 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VisuGUI_CacheDlg.h +// Author : Oleg UVAROV +// Module : VISU + +#ifndef VISUGUI_CACHEDLG_H +#define VISUGUI_CACHEDLG_H + +#include + +class QRadioButton; +class QSpinBox; + +class SalomeApp_Module; + +namespace VISU +{ + class ColoredPrs3dCache_i; +} + +class VisuGUI_CacheDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_CacheDlg( SalomeApp_Module* theModule, bool theIsLimitedMemory, long theLimitedMemory ); + virtual ~VisuGUI_CacheDlg(); + +public: + bool isLimitedMemory(); + int getLimitedMemory(); + +protected slots: + virtual void accept(); + + void onHelp(); + +private: + QRadioButton* myMimimalMemoryButton; + QRadioButton* myLimitedMemoryButton; + QSpinBox* myLimitedMemory; +}; + +#endif diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index ad632585..52670247 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -44,6 +44,8 @@ #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" +#include "SUIT_ResourceMgr.h" + #include "VVTK_ViewWindow.h" using namespace VISU; @@ -68,6 +70,15 @@ ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy): SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(theStudy); CORBA::String_var aFatherEntry = aSComponent->GetID(); CreateAttributes(GetStudyDocument(), aFatherEntry.in(), "", anIOR.in(), myName, "", "", true); + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + + bool anIsLimitedMemory = aResourceMgr->booleanValue( "VISU", "cache_is_limited_memory", true ); + SetMemoryMode( anIsLimitedMemory ? VISU::ColoredPrs3dCache::LIMITED : VISU::ColoredPrs3dCache::MINIMAL ); + + int aLimitedMemory = aResourceMgr->integerValue( "VISU", "cache_limited_memory", 10 ); + SetLimitedMemory( aLimitedMemory ); + } @@ -122,6 +133,26 @@ IsPossible(VISU::VISUType theType, } +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3dCache_i:: +SetMemoryMode(VISU::ColoredPrs3dCache::MemoryMode theMode) +{ + myMemoryMode = theMode; + cout << theMode << endl; +} + + +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3dCache_i:: +SetLimitedMemory(CORBA::Long theMemorySize) +{ + myLimitedMemory = theMemorySize; + cout << theMemorySize << endl; +} + + //---------------------------------------------------------------------------- VISU::ColoredPrs3dHolder_ptr VISU::ColoredPrs3dCache_i:: diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh index 0abd10bb..56a889a8 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh @@ -60,6 +60,18 @@ namespace VISU ~ColoredPrs3dCache_i(); //---------------------------------------------------------------------------- + /*! + * Sets a memory mode. + */ + void + SetMemoryMode(VISU::ColoredPrs3dCache::MemoryMode theMode); + + /*! + * Sets a memory size for limited mode. + */ + void + SetLimitedMemory(CORBA::Long theMemorySize); + /*! * Creates ColoredPrs3dHolder. */ @@ -68,6 +80,12 @@ namespace VISU const VISU::ColoredPrs3dHolder::BasicInput& theInput); //---------------------------------------------------------------------------- + VISU::ColoredPrs3dCache::MemoryMode + GetMemoryMode() const { return myMemoryMode; } + + long + GetLimitedMemory() const { return myLimitedMemory; } + virtual VISU::VISUType GetType() { return VISU::TCOLOREDPRS3DCACHE; } @@ -115,7 +133,10 @@ namespace VISU const VISU::ColoredPrs3dHolder::BasicInput& theInput); private: - TColoredPrs3dHolderMap myHolderMap; + VISU::ColoredPrs3dCache::MemoryMode myMemoryMode; + long myLimitedMemory; + + TColoredPrs3dHolderMap myHolderMap; }; } -- 2.39.2