#include "VisuGUI_BuildProgressDlg.h"
#include "VisuGUI_TransparencyDlg.h"
-#include "VISU_ScalarMap_i.hh"
+#include "VISU_PrsMerger_i.hh"
#include "VisuGUI_ScalarBarDlg.h"
#include "VISU_DeformedShape_i.hh"
VisuGUI::
OnCreateScalarMap()
{
- CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
+ CreatePrs3d<VISU::PrsMerger_i,VisuGUI_ScalarBarDlg,1>(this);
}
{
Handle(SALOME_InteractiveObject) anIO;
if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
- EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg, 1>(this, anIO, aPrs3d);
+ EditPrs3d<VISU::PrsMerger_i, VisuGUI_ScalarBarDlg, 1>(this, anIO, aPrs3d);
}
void
aSameMesh->SameAs(aMeshPrs);
}
break;
- case VISU::TSCALARMAP:
+ case VISU::TPRSMERGER:
{
- VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
- VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
+ VISU::PrsMerger_i* aScalarPrs = dynamic_cast<VISU::PrsMerger_i*>(aPrsObject);
+ VISU::PrsMerger_i* aSameScalar = new VISU::PrsMerger_i(aScalarPrs->GetResult(),true);
aSameScalar->SameAs(aScalarPrs);
}
break;
// Rules
- QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
+ QString aPrsAll ("'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
"'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'");
// VISU root commands
// 3D presentations commands
QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
- QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
+ QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TPRSMERGER' 'VISU::TDEFORMEDSHAPE'}";
QString aSurfFrameType = " and $type in {'VISU::TMESH'}";
- QString aSurfType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
+ QString aSurfType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
" 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
- QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
+ QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' "
"'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
- QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
+ QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
"'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' }";
aRule = "selcount=1";
mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
mgr->setRule( action( VISU_EDIT_SCALARMAP ),
- "selcount=1 and type='VISU::TSCALARMAP'", true );
+ "selcount=1 and type='VISU::TPRSMERGER'", true );
mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ),
"selcount=1 and type='VISU::TDEFORMEDSHAPE'", true );
mgr->setRule( action( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE ),
aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
+ mgr->setRule( action( VISU_EDIT_PLOT3D ),
+ "selcount=1 and type='VISU::TPLOT3D'", true );
//aRule = "client='ObjectBrowser' and type='MEDFIELD'";
//mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
#include "VISU_ScalarMapPL.hxx"
#include "VISU_ScalarMap_i.hh"
#include "VISU_ScalarMapAct.h"
+#include "VISU_Result_i.hh"
#include "LightApp_Application.h"
#include <vtkTextProperty.h>
+using namespace VISU;
using namespace std;
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
+ myGroupPane = new VisuGUI_GroupSelectPane(this);
+ TopLayout->addWidget(myGroupPane);
+
myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
TopLayout->addWidget(myScalarPane);
connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
}
+/*!
+ Set values in the dialog from the presentation
+*/
+void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::PrsMerger_i* thePrs)
+{
+ myScalarPane->initFromPrsObject(thePrs);
+ myGroupPane->initFromPrsObject(thePrs);
+}
+
+/*!
+ Set values to presentation from the dialog
+*/
+int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::PrsMerger_i* thePrs)
+{
+ bool res1 = myScalarPane->storeToPrsObject(thePrs);
+ bool res2 = myGroupPane->storeToPrsObject(thePrs);
+ return (res1&&res2);
+}
+
/*!
Called when <OK> button is clicked, validates data and closes dialog
*/
onHelp();
}
}
+
+/*!
+ Constructor
+*/
+VisuGUI_GroupSelectPane::VisuGUI_GroupSelectPane(QWidget * parent):
+ QVBox(parent)
+{
+ // Main groupbox
+ myMainGroupBox = new QGroupBox(tr(""), this, "myMainGroupBox");
+ myMainGroupBox->setColumnLayout(0, Qt::Vertical );
+ myMainGroupBox->layout()->setSpacing( 0 );
+ myMainGroupBox->layout()->setMargin( 0 );
+ QGridLayout* aMainGroupBoxLayout = new QGridLayout( myMainGroupBox->layout() );
+ myMainGroupBox->setAlignment( Qt::AlignTop );
+ aMainGroupBoxLayout->setSpacing( 6 );
+ aMainGroupBoxLayout->setMargin( 11 );
+
+ myOnGroupsCB = new QCheckBox (tr("PRS_ON_GROUPS"), myMainGroupBox);
+ myOnGroupsCB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ // Lists of groups and add/remove buttons
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+ QPixmap addImage ( aResourceMgr->loadPixmap("VISU", tr("ICON_ADD")));
+ QPixmap removeImage ( aResourceMgr->loadPixmap("VISU", tr("ICON_REMOVE")));
+
+ myAllGroups = new VisuGUI_ListBox(myMainGroupBox, "myAllGroups");
+ myAllGroups->setSelectionMode(QListBox::Extended);
+
+ myAddButton = new QToolButton(myMainGroupBox);
+ myAddButton->setPixmap( addImage );
+
+ myRemoveButton = new QToolButton(myMainGroupBox);
+ myRemoveButton->setPixmap( removeImage );
+
+ mySelectedGroups = new VisuGUI_ListBox(myMainGroupBox, "mySelectedGroups");
+ mySelectedGroups->setSelectionMode(QListBox::Extended);
+
+ // Layouting
+ QVBoxLayout* buttonsLayout = new QVBoxLayout();
+ buttonsLayout->addWidget(myAddButton);
+ buttonsLayout->addSpacing(6);
+ buttonsLayout->addWidget(myRemoveButton);
+ buttonsLayout->addStretch();
+
+ aMainGroupBoxLayout->addMultiCellWidget( myOnGroupsCB, 0, 0, 0, 2);
+ aMainGroupBoxLayout->addWidget( myAllGroups, 1, 0 );
+ aMainGroupBoxLayout->addLayout( buttonsLayout, 1, 1 );
+ aMainGroupBoxLayout->addWidget( mySelectedGroups, 1, 2 );
+ aMainGroupBoxLayout->setRowStretch(1, 10);
+
+ // Connections
+
+ connect( myOnGroupsCB, SIGNAL( toggled( bool ) ), this, SLOT( onTypeChanged() ) );
+ connect( myAllGroups, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) );
+ connect( mySelectedGroups, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) );
+ connect( myAddButton, SIGNAL(clicked()), this, SLOT(onAdd()));
+ connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
+
+ mySelectedGroups->installEventFilter(this);
+
+ onTypeChanged();
+}
+
+/*!
+ Called when the checkbox is toggled
+*/
+void VisuGUI_GroupSelectPane::onTypeChanged( )
+{
+ bool toEnable = myOnGroupsCB->isChecked();
+ if (!toEnable)
+ {
+ myAllGroups->clearSelection();
+ mySelectedGroups->clearSelection();
+ }
+ myAllGroups->setEnabled( toEnable );
+ mySelectedGroups->setEnabled( toEnable );
+ myAddButton->setEnabled( toEnable );
+ myRemoveButton->setEnabled( toEnable );
+}
+
+/*!
+ Initialise the pane from presentation object
+ */
+void VisuGUI_GroupSelectPane::initFromPrsObject(VISU::PrsMerger_i* thePrs)
+{
+ VISU::Result_i* theResult = thePrs->GetResult();
+ VISU_Convertor* aInput = theResult->GetInput();
+
+ const VISU::TMeshMap& aMeshMap = aInput->GetMeshMap();
+
+ VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(thePrs->GetMeshName());
+ if(aMeshIter!=aMeshMap.end()){
+ const PMesh& aMesh = aMeshIter->second;
+ const TGroupMap& aGroupMap = aMesh->myGroupMap;
+ TGroupMap::const_iterator aGroupIter = aGroupMap.begin();
+ for(;aGroupIter!=aGroupMap.end();aGroupIter++)
+ {
+ const string& aGroupName = aGroupIter->first;
+ myAllGroups->insertItem( QString(aGroupName) );
+ }
+ }
+
+ if (myAllGroups->count() < 1)
+ {
+ myAllGroups->insertItem( tr("NO_GROUPS") );
+ myMainGroupBox->setEnabled(false);
+ }
+ else
+ {
+ // Get names of the groups
+ string_array_var aGroupNames = thePrs->getGroupNames();
+ for(int i=0; i<aGroupNames->length(); i++)
+ mySelectedGroups->insertItem( QString(aGroupNames[i]) );
+
+ if (mySelectedGroups->count() > 0)
+ myOnGroupsCB->setChecked(true);
+ }
+}
+
+/*!
+ Store values to presentation object
+ */
+int VisuGUI_GroupSelectPane::storeToPrsObject(VISU::PrsMerger_i* thePrs)
+{
+ thePrs->RemoveAllGeom();
+
+ if (myOnGroupsCB->isChecked())
+ {
+ QString aMeshName = thePrs->GetMeshName();
+ for (int i = 0; i < mySelectedGroups->count(); i++)
+ thePrs->AddMeshOnGroup( aMeshName , mySelectedGroups->text(i) );
+ }
+
+ return 1;
+}
+
+/*!
+ Called when add button is clicked, adds item to choosen groups
+*/
+void VisuGUI_GroupSelectPane::onAdd()
+{
+ QStringList aList;
+
+ for (int i = 0; i < myAllGroups->count(); i++)
+ if (myAllGroups->isSelected(i))
+ aList.append(myAllGroups->text(i));
+
+ for (int i = 0; i < mySelectedGroups->count(); i++)
+ aList.remove(mySelectedGroups->text(i));
+
+ mySelectedGroups->insertStringList(aList);
+}
+
+/*!
+ Called when remove button is clicked, remove selected items from choosen
+*/
+void VisuGUI_GroupSelectPane::onRemove()
+{
+ QPtrList<QListBoxItem> aList;
+ aList.setAutoDelete(false);
+ for (int i = 0; i < mySelectedGroups->count(); i++)
+ if (mySelectedGroups->isSelected(i))
+ aList.append(mySelectedGroups->item(i));
+
+ for (int i = 0; i < aList.count(); i++)
+ delete aList.at(i);
+}
+
+/*!
+ Called when an item of listbox is double-clicked
+*/
+void VisuGUI_GroupSelectPane::onListDoubleClicked( QListBoxItem* theItem )
+{
+ QListBox* aListBox = theItem->listBox();
+
+ if (aListBox == myAllGroups)
+ {
+ if (!mySelectedGroups->findItem( theItem->text(), Qt::ExactMatch ))
+ mySelectedGroups->insertItem(theItem->text());
+ }
+ else if (aListBox == mySelectedGroups)
+ delete theItem;
+}
+
+/*!
+ Event filter
+*/
+bool VisuGUI_GroupSelectPane::eventFilter (QObject* object, QEvent* event)
+{
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent* aKeyEvent = (QKeyEvent*)event;
+ if (object == mySelectedGroups && aKeyEvent->key() == Key_Delete)
+ onRemove();
+ }
+ return QObject::eventFilter(object, event);
+}
#include <qtoolbutton.h>
#include "QtxDblSpinBox.h"
+#include "QtxListBox.h"
#include "VISU_ScalarMap_i.hh"
+#include "VISU_PrsMerger_i.hh"
class QButtonGroup;
class QGroupBox;
class QVBox;
class QToolButton;
-class QtxDblSpinBox;
+class QListBoxItem;
class SalomeApp_Module;
class SVTK_FontWidget;
class VISU_ScalarMapAct;
};
+class VisuGUI_ListBox: public QtxListBox
+{
+ Q_OBJECT;
+
+ public:
+ VisuGUI_ListBox( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )
+ : QtxListBox(parent, name, f) {};
+ ~VisuGUI_ListBox() {};
+
+ virtual QSize sizeHint() const { return minimumSizeHint(); };
+};
+
+class VisuGUI_GroupSelectPane : public QVBox
+{
+ Q_OBJECT;
+
+ public:
+ VisuGUI_GroupSelectPane(QWidget* parent);
+ ~VisuGUI_GroupSelectPane() {};
+
+ void initFromPrsObject(VISU::PrsMerger_i* thePrs);
+ int storeToPrsObject(VISU::PrsMerger_i* thePrs);
+
+ bool eventFilter (QObject* object, QEvent* event);
+
+ private slots:
+ void onTypeChanged();
+ void onListDoubleClicked( QListBoxItem* theItem );
+ void onAdd();
+ void onRemove();
+
+ private:
+ QGroupBox* myMainGroupBox;
+
+ QCheckBox* myOnGroupsCB;
+
+ VisuGUI_ListBox* myAllGroups;
+ VisuGUI_ListBox* mySelectedGroups;
+
+ QToolButton* myAddButton;
+ QToolButton* myRemoveButton;
+};
+
+
class VisuGUI_ScalarBarDlg : public QDialog
{
Q_OBJECT;
void initFromResources() {myScalarPane->initFromResources();}
void storeToResources() {myScalarPane->storeToResources();}
- void initFromPrsObject(VISU::ScalarMap_i* thePrs) {myScalarPane->initFromPrsObject(thePrs);}
- int storeToPrsObject(VISU::ScalarMap_i* thePrs) {return myScalarPane->storeToPrsObject(thePrs);}
+ void initFromPrsObject(VISU::PrsMerger_i* thePrs);
+ int storeToPrsObject(VISU::PrsMerger_i* thePrs);
private:
void keyPressEvent( QKeyEvent* e );
protected:
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_GroupSelectPane* myGroupPane;
};
#endif // VISUGUI_SCALARBARDLG_H