From: vsr Date: Tue, 18 Aug 2009 07:28:56 +0000 (+0000) Subject: Issue 20189: EDF 972 VISU : Shrink coef X-Git-Tag: V5_1_main_20090820 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a46f24d18dca062f3e5f2d984765bd5e725a1174;p=modules%2Fvisu.git Issue 20189: EDF 972 VISU : Shrink coef --- diff --git a/doc/salome/gui/VISU/images/line_width.png b/doc/salome/gui/VISU/images/line_width.png new file mode 100644 index 00000000..15e40a7d Binary files /dev/null and b/doc/salome/gui/VISU/images/line_width.png differ diff --git a/doc/salome/gui/VISU/images/shrink_factor.png b/doc/salome/gui/VISU/images/shrink_factor.png new file mode 100644 index 00000000..cbc4f953 Binary files /dev/null and b/doc/salome/gui/VISU/images/shrink_factor.png differ diff --git a/doc/salome/gui/VISU/input/viewing_3d_presentations.doc b/doc/salome/gui/VISU/input/viewing_3d_presentations.doc index 36c13e88..a82e5eb5 100644 --- a/doc/salome/gui/VISU/input/viewing_3d_presentations.doc +++ b/doc/salome/gui/VISU/input/viewing_3d_presentations.doc @@ -105,7 +105,6 @@ arcs.
  • \b Properties
  • -\image html viewing13.png diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 3aee730b..f35f3f11 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -39,6 +39,7 @@ + diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index 5a39eccf..86a1d09d 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -65,6 +65,7 @@ salomeinclude_HEADERS= \ VisuGUI_SetupPlot2dDlg.h \ VisuGUI_BuildProgressDlg.h \ VisuGUI_TransparencyDlg.h \ + VisuGUI_ShrinkFactorDlg.h \ VisuGUI_Timer.h \ VisuGUI_Slider.h \ VisuGUI_InputPane.h \ @@ -112,6 +113,7 @@ dist_libVISU_la_SOURCES= \ VisuGUI_BuildProgressDlg.cxx \ VisuGUI_Table3dDlg.cxx \ VisuGUI_TransparencyDlg.cxx \ + VisuGUI_ShrinkFactorDlg.cxx \ VisuGUI_Timer.cxx \ VisuGUI_Slider.cxx \ VisuGUI_Sweep.cxx \ @@ -159,6 +161,7 @@ MOC_FILES= \ VisuGUI_BuildProgressDlg_moc.cxx \ VisuGUI_Table3dDlg_moc.cxx \ VisuGUI_TransparencyDlg_moc.cxx \ + VisuGUI_ShrinkFactorDlg_moc.cxx \ VisuGUI_Slider_moc.cxx \ VisuGUI_Sweep_moc.cxx \ VisuGUI_InputPane_moc.cxx \ diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 1d07e3b4..986a8221 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -409,6 +409,10 @@ number of time stamps or number of components is not the same! MAX_ARC_ANGLE Maximum angle + + VISU_SHRINK_FACTOR + Shrink Factor + VISU_USE_SHADING Use Shading @@ -1173,6 +1177,10 @@ Please, refer to the documentation. MEN_LINE_WIDTH Line Width + + MEN_SHRINK_FACTOR + Shrink Factor + MEN_MERGE_SCALAR_BARS Merge Scalar Range @@ -4125,4 +4133,15 @@ Please, refer to the QT documentation. Color + + VisuGUI_ShrinkFactorDlg + + SHRINKFACTOR_TITLE + Change Shrink Factor + + + SHRINKFACTOR_VALUE + Shrink Factor: + + diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 8c724922..8ea7c889 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -116,6 +116,7 @@ #include "VisuGUI_Displayer.h" #include "VisuGUI_BuildProgressDlg.h" #include "VisuGUI_TransparencyDlg.h" +#include "VisuGUI_ShrinkFactorDlg.h" #include "VisuGUI_CacheDlg.h" #include "VisuGUI_Table3dDlg.h" #include "VisuGUI_ClippingPanel.h" @@ -1391,6 +1392,15 @@ VisuGUI delete CursorDlg; } +//---------------------------------------------------------------------------- +void +VisuGUI +::OnChangeShrinkFactor() +{ + VisuGUI_ShrinkFactorDlg* aDialog = new VisuGUI_ShrinkFactorDlg( this ); + aDialog->show(); +} + //---------------------------------------------------------------------------- void VisuGUI @@ -2622,6 +2632,10 @@ VisuGUI tr("MEN_LINE_WIDTH"), "", 0, aParent, false, this, SLOT(OnChangeLines())); + createAction( VISU_SHRINK_FACTOR, tr("MEN_SHRINK_FACTOR"), QIcon(), + tr("MEN_SHRINK_FACTOR"), "", 0, aParent, false, + this, SLOT(OnChangeShrinkFactor())); + createAction( VISU_EDIT_SCALARMAP, tr("MEN_EDIT_PRS"), QIcon(), tr("MEN_EDIT_PRS"), "", 0, aParent, false, @@ -2958,11 +2972,12 @@ VisuGUI // "Properties" submenu parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 ); - mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color - mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color - mgr->insert( action( VISU_COLOR ) , parentId, -1, -1 ); // color - mgr->insert( action( VISU_OPACITY ) , parentId, -1, -1 ); // opacity - mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width + mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color + mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color + mgr->insert( action( VISU_COLOR ) , parentId, -1, -1 ); // color + mgr->insert( action( VISU_OPACITY ) , parentId, -1, -1 ); // opacity + mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width + mgr->insert( action( VISU_SHRINK_FACTOR ), parentId, -1, -1 ); // shrink factor mgr->insert( separator(), -1, -1, -1 ); @@ -3139,6 +3154,7 @@ VisuGUI "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))" ); mgr->setRule( action( VISU_OPACITY ), aRule + " and hasActor=1" ); mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1" ); + mgr->setRule( action( VISU_SHRINK_FACTOR ), aRule + aShrinkType + " and isShrunk=1" ); // rename command QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER' 'VISU::POINTMAP3D'"; @@ -3977,11 +3993,16 @@ void VisuGUI::createPreferences() setPreferenceProperty( maxAngle, "min", 1 ); setPreferenceProperty( maxAngle, "max", 90 ); + int shrFac = addPreference( tr( "VISU_SHRINK_FACTOR" ), representGr, LightApp_Preferences::IntSpin, "VISU", "shrink_factor" ); + setPreferenceProperty( shrFac, "min", 20 ); + setPreferenceProperty( shrFac, "max", 100 ); + sp = addPreference( "", representGr, LightApp_Preferences::Space ); + setPreferenceProperty( sp, "hstretch", 0 ); + setPreferenceProperty( sp, "vstretch", 0 ); addPreference( tr( "VISU_EDGE_COLOR" ), representGr, LightApp_Preferences::Color, "VISU", "edge_color" ); addPreference( "", representGr, LightApp_Preferences::Space ); - addPreference( tr( "VISU_USE_SHADING" ), representGr, LightApp_Preferences::Bool, "VISU", "represent_shading" ); sp = addPreference( "", representGr, LightApp_Preferences::Space ); setPreferenceProperty( sp, "hstretch", 0 ); diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index dff83e2f..e5fa4866 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -153,6 +153,7 @@ protected slots: void OnChangeWireframeColor(); void OnChangeOpacity(); void OnChangeLines(); + void OnChangeShrinkFactor(); void OnShowTable(); void OnShowTablePlot(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index e0bc6e7b..be51141e 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -92,6 +92,7 @@ #define VISU_EDGE_COLOR 4059 #define VISU_OPACITY 4060 #define VISU_LINE_WIDTH 4061 +#define VISU_SHRINK_FACTOR 40629 #define VISU_EDIT_SCALARMAP 40620 #define VISU_EDIT_DEFORMEDSHAPE 40621 diff --git a/src/VISUGUI/VisuGUI_ShrinkFactorDlg.cxx b/src/VISUGUI/VisuGUI_ShrinkFactorDlg.cxx new file mode 100644 index 00000000..32f2b0fc --- /dev/null +++ b/src/VISUGUI/VisuGUI_ShrinkFactorDlg.cxx @@ -0,0 +1,255 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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_ShrinkFactorDlg.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#include "VisuGUI_ShrinkFactorDlg.h" + +#include "VisuGUI.h" +#include "VisuGUI_ViewTools.h" +#include "VisuGUI_Tools.h" +#include "VISU_Actor.h" + +#include "SUIT_Desktop.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" +#include "SUIT_ResourceMgr.h" + +#include "SALOME_ListIO.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_InteractiveObject.hxx" + +#include "LightApp_Study.h" +#include "LightApp_SelectionMgr.h" +#include "LightApp_Application.h" + +#include "SVTK_ViewWindow.h" + +// QT Includes +#include +#include +#include +#include +#include +#include + +const int DEFAULT_SHRINK = 80; + +//================================================================================= +// class : VisuGUI_ShrinkFactorDlg() +// purpose : +// +//================================================================================= +VisuGUI_ShrinkFactorDlg::VisuGUI_ShrinkFactorDlg( VisuGUI* theModule, bool modal ) + : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + myModule(theModule), + mySelectionMgr( VISU::GetSelectionMgr( theModule ) ), + myViewWindow( VISU::GetActiveViewWindow(theModule) ) +{ + setModal( modal ); + setAttribute( Qt::WA_DeleteOnClose ); + + setWindowTitle( tr( "SHRINKFACTOR_TITLE" ) ); + setSizeGripEnabled( true ); + QVBoxLayout* topLayout = new QVBoxLayout( this ); + topLayout->setSpacing( 6 ); + topLayout->setMargin( 11 ); + + /*************************************************************************/ + GroupC1 = new QGroupBox( this ); + QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1 ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + ValueLab = new QLabel( tr( "SHRINKFACTOR_VALUE" ), GroupC1 ); + ValueSpin = new QSpinBox( GroupC1 ); + ValueSpin->setRange( 20, 100 ); + ValueSpin->setSingleStep( 10 ); + ValueSpin->setMinimumWidth( 70 ); + + GroupC1Layout->addWidget( ValueLab ); + GroupC1Layout->addWidget( ValueSpin ); + + /*************************************************************************/ + QGroupBox* GroupButtons = new QGroupBox( this ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "BUT_CLOSE" ), GroupButtons ); + buttonOk->setAutoDefault( true ); + buttonOk->setDefault( true ); + + buttonHelp = new QPushButton( tr( "BUT_HELP" ), GroupButtons); + buttonHelp->setAutoDefault( true ); + + GroupButtonsLayout->addWidget( buttonOk ); + GroupButtonsLayout->addSpacing( 10 ); + GroupButtonsLayout->addStretch(); + GroupButtonsLayout->addWidget( buttonHelp ); + + topLayout->addWidget( GroupC1 ); + topLayout->addWidget( GroupButtons ); + + // Initial state + onSelectionChanged(); + + // signals and slots connections : after ValueHasChanged() + connect(buttonOk, SIGNAL( clicked() ), this, SLOT( close() ) ); + connect(buttonHelp, SIGNAL( clicked() ), this, SLOT( help() ) ); + connect(ValueSpin, SIGNAL( valueChanged( int ) ), this, SLOT( setShrinkFactor() ) ); + connect(mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); +} + +//================================================================================= +// function : ~VisuGUI_ShrinkFactorDlg() +// purpose : +//================================================================================= +VisuGUI_ShrinkFactorDlg::~VisuGUI_ShrinkFactorDlg() +{ +} + +//======================================================================= +// function : help() +// purpose : +//======================================================================= +void VisuGUI_ShrinkFactorDlg::help() +{ + QString aHelpFileName = "viewing_3d_presentations_page.html#width_shrink_factor_anchor"; + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) { + VisuGUI* aVisuGUI = dynamic_cast( app->activeModule() ); + app->onHelpContextModule( aVisuGUI ? app->moduleName( aVisuGUI->moduleName() ) : QString(""), aHelpFileName ); + } + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning( this, + tr( "WRN_WARNING" ), + tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ). + arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( aHelpFileName ), + tr( "BUT_OK" ) ); + } +} + +//================================================================================= +// function : setShrinkFactor() +// purpose : Called when value of spin box is changed +// : or the first time as initilisation +//================================================================================= +void VisuGUI_ShrinkFactorDlg::setShrinkFactor() +{ + if ( myViewWindow ) { + SUIT_OverrideCursor wc; + float shrink = ValueSpin->value() / 100.; + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + + SALOME_ListIteratorOfListIO anIter( aList ); + for ( ; anIter.More(); anIter.Next() ) { + Handle(SALOME_InteractiveObject) anIO = anIter.Value(); + VISU_Actor* anActor = VISU::FindActor( VISU::GetAppStudy( myModule ), myViewWindow, anIO->getEntry() ); + if ( anActor && anActor->IsShrunkable() ) + anActor->SetShrinkFactor( shrink ); + } + myViewWindow->Repaint(); + } +} + +//================================================================================= +// function : onSelectionChanged() +// purpose : Called when selection is changed +//================================================================================= +void VisuGUI_ShrinkFactorDlg::onSelectionChanged() +{ + bool shrinkable = false; + if ( myViewWindow ) { + int shrink = DEFAULT_SHRINK; + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + + if ( aList.Extent() == 1 ) { + Handle(SALOME_InteractiveObject) FirstIOS = aList.First(); + if ( !FirstIOS.IsNull() ) { + VISU_Actor* anActor = VISU::FindActor( VISU::GetAppStudy( myModule ), myViewWindow, FirstIOS->getEntry() ); + if ( anActor ) { + shrinkable = anActor->IsShrunkable(); + if ( shrinkable ) + shrink = int( anActor->GetShrinkFactor() * 100. + 0.5 ); + } + } + } + else if ( aList.Extent() > 1 ) { + SALOME_ListIteratorOfListIO It( aList ); + int setShr = -1; + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IO = It.Value(); + if (!IO.IsNull()) { + VISU_Actor* anActor = VISU::FindActor( VISU::GetAppStudy( myModule ), myViewWindow, IO->getEntry() ); + if ( anActor ) { + bool lshrinkable = anActor->IsShrunkable(); + shrinkable = shrinkable || lshrinkable; + if ( lshrinkable ) { + int shr = int( anActor->GetShrinkFactor() * 100. + 0.5 ); + if ( setShr < 0 ) + setShr = shr; + else if ( setShr != shr ) { + setShr = DEFAULT_SHRINK; + break; + } + } + } + } + } + if ( setShr >= 0 ) + shrink = setShr; + } + ValueSpin->blockSignals( true ); + ValueSpin->setValue( shrink ); + ValueSpin->blockSignals( false ); + } + GroupC1->setEnabled( shrinkable ); +} + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void VisuGUI_ShrinkFactorDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + help(); + } +} diff --git a/src/VISUGUI/VisuGUI_ShrinkFactorDlg.h b/src/VISUGUI/VisuGUI_ShrinkFactorDlg.h new file mode 100644 index 00000000..b4bf4b55 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ShrinkFactorDlg.h @@ -0,0 +1,76 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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_ShrinkFactorDlg.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#ifndef VISUGUI_SHRINKFACTORDLG_H +#define VISUGUI_SHRINKFACTORDLG_H + +// QT Includes +#include + +class QLabel; +class QPushButton; +class QSpinBox; +class QGroupBox; +class LightApp_SelectionMgr; +class SalomeApp_Module; +class SVTK_Selector; +class SVTK_ViewWindow; +class VisuGUI; + +//================================================================================= +// class : VisuGUI_ShrinkFactorDlg +// purpose : +//================================================================================= +class VisuGUI_ShrinkFactorDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_ShrinkFactorDlg( VisuGUI* = 0, + bool modal = false ); + + ~VisuGUI_ShrinkFactorDlg(); + +private: + void keyPressEvent( QKeyEvent* ); + +private : + LightApp_SelectionMgr* mySelectionMgr; + SVTK_ViewWindow* myViewWindow; + const SalomeApp_Module* myModule; + + QGroupBox* GroupC1; + QPushButton* buttonOk; + QPushButton* buttonHelp; + QLabel* ValueLab; + QSpinBox* ValueSpin; + +public slots: + void help(); + void setShrinkFactor(); + void onSelectionChanged(); +}; + +#endif // VISUGUI_SHRINKFACTORDLG_H diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 7b010add..fdc4ef08 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -32,6 +32,7 @@ #include "VISU_Actor.h" #include "SALOME_Event.h" +#include "SUIT_ResourceMgr.h" #include #include @@ -485,6 +486,8 @@ VISU::Prs3d_i ::CreateActor(VISU_Actor* theActor) { try{ + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + Handle(SALOME_InteractiveObject) anIO = GetIO(); if(!anIO.IsNull() && anIO->hasEntry()){ theActor->setIO(anIO); @@ -494,7 +497,7 @@ VISU::Prs3d_i CheckDataSet(); theActor->SetPrs3d(this); - theActor->SetShrinkFactor(); + theActor->SetShrinkFactor(aResourceMgr->integerValue("VISU", "shrink_factor", 80)/100.); theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]); theActor->SetPipeLine(GetActorPipeLine()); if(theActor->GetPipeLine() != GetPipeLine()){