#include "VISUConfig.hh"
#include "VISU_Convertor.hxx"
-#include "VISU_ScalarMapPL.hxx"
-#include "VISU_ScalarMap_i.hh"
#include "VISU_ScalarMapAct.h"
#include "VISU_Result_i.hh"
setSpacing(6);
//setMargin(11);
+ // Presentation type ================================================
+ 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
+ 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);
+
+ mySelectedGroups->installEventFilter(this);
+
// Range ============================================================
RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
RangeGroup->setColumnLayout(0, Qt::Vertical );
CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 );
// signals and slots 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()));
connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
+ onTypeChanged();
changeRange( 0 );
changeDefaults( 0 );
myIsStoreTextProp = false;
/**
* Initialise dialog box from presentation object
*/
-void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
+void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::PrsMerger_i* thePrs) {
initFromResources();
myScalarMap = thePrs;
+
+ // type of presentation and groups
+ VISU::Result_i* theResult = myScalarMap->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);
+ }
+
+ //
myTitle = thePrs->GetTitle();
setPosAndSize( thePrs->GetPosX(),
thePrs->GetPosY(),
setLogarithmic(false);
}
vtkFloatingPointType aRange[2];
- thePrs->GetScalarMapPL()->GetSourceRange(aRange);
+ thePrs->GetPrsMergerPL()->GetSourceRange(aRange);
Rmin = aRange[0]; Rmax = aRange[1];
setRange( thePrs->GetMin(), thePrs->GetMax(),
/*0.0, 0.0,*/ thePrs->IsRangeFixed() );
if (myScalarMap == NULL) return;
if (!check()) return;
- myScalarMapPL = VISU_ScalarMapPL::New();
- if(myScalarMap->GetScalarMapPL())
- myScalarMapPL->ShallowCopy(myScalarMap->GetScalarMapPL());
+ myScalarMapPL = VISU_PrsMergerPL::New();
+ if(myScalarMap->GetPrsMergerPL())
+ myScalarMapPL->ShallowCopy(myScalarMap->GetPrsMergerPL());
if ( myBusy ) return;
if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
vf->Repaint();
}
+
+/*!
+ Event filter
+*/
+bool VisuGUI_ScalarBarPane::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);
+}
+
/**
* Store values to presentation object
*/
-int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
+int VisuGUI_ScalarBarPane::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) );
+ }
+
thePrs->SetScalarMode(myModeCombo->currentItem());
thePrs->SetPosition(XSpin->value(), YSpin->value());
thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
return 1;
}
+/*!
+ Called when the checkbox is toggled
+*/
+void VisuGUI_ScalarBarPane::onTypeChanged( )
+{
+ bool toEnable = myOnGroupsCB->isChecked();
+ if (!toEnable)
+ {
+ myAllGroups->clearSelection();
+ mySelectedGroups->clearSelection();
+ }
+ myAllGroups->setEnabled( toEnable );
+ mySelectedGroups->setEnabled( toEnable );
+ myAddButton->setEnabled( toEnable );
+ myRemoveButton->setEnabled( toEnable );
+}
+
+/*!
+ Called when add button is clicked, adds item to choosen groups
+*/
+void VisuGUI_ScalarBarPane::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_ScalarBarPane::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_ScalarBarPane::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;
+}
+
/*!
Called when orientation is changed
*/
vtkFloatingPointType aRange[2];
int aMode = myScalarMap->GetScalarMode();
myScalarMap->SetScalarMode(theMode);
- myScalarMap->GetScalarMapPL()->GetSourceRange(aRange);
+ myScalarMap->GetPrsMergerPL()->GetSourceRange(aRange);
MinEdit->setText( QString::number( aRange[0] ) );
MaxEdit->setText( QString::number( aRange[1] ) );
myScalarMap->SetScalarMode(aMode);
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
- myGroupPane = new VisuGUI_GroupSelectPane(this);
- TopLayout->addWidget(myGroupPane);
-
myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
TopLayout->addWidget(myScalarPane);
void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::PrsMerger_i* thePrs)
{
myScalarPane->initFromPrsObject(thePrs);
- myGroupPane->initFromPrsObject(thePrs);
}
/*!
*/
int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::PrsMerger_i* thePrs)
{
- bool res1 = myScalarPane->storeToPrsObject(thePrs);
- bool res2 = myGroupPane->storeToPrsObject(thePrs);
- return (res1&&res2);
+ return myScalarPane->storeToPrsObject(thePrs);
}
/*!
}
}
-/*!
- 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);
-}