-// Copyright (C) 2005 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.
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// 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
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// 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
//
-
#include "VisuGUI_OffsetDlg.h"
#include "VisuGUI.h"
#include "VISU_Actor.h"
#include "LightApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "SALOME_ListIteratorOfListIO.hxx"
#include "SalomeApp_Application.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_ViewModel.h"
+#include "SUIT_ViewManager.h"
#include "SUIT_Desktop.h"
#include "SUIT_Session.h"
#include "SUIT_MessageBox.h"
#include "SUIT_ResourceMgr.h"
-#include "QtxDblSpinBox.h"
+#include "QtxDoubleSpinBox.h"
// VTK Includes
#include "vtkRenderer.h"
// QT Includes
-#include <qhbox.h>
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qcheckbox.h>
-#include <qgroupbox.h>
-#include <qpushbutton.h>
+#include <QLabel>
+#include <QLayout>
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QPushButton>
+#include <QKeyEvent>
#define MAXVAL 1e10
VisuGUI_OffsetDlg::VisuGUI_OffsetDlg (VisuGUI* theModule)
-: QDialog(VISU::GetDesktop(theModule), 0, false, WStyle_Customize |
- WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
-myModule(theModule)
+: QDialog(VISU::GetDesktop(theModule), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+ myModule(theModule),
+ mySelectionMgr(VISU::GetSelectionMgr(theModule))
{
- myPrsList.setAutoDelete(false);
+ //myPrsList.setAutoDelete(false);
+ //myPointMapList.setAutoDelete(false);
- setName("VisuGUI_OffsetDlg");
- setCaption(tr("TIT_OFFSETDLG"));
+ setWindowTitle(tr("TIT_OFFSETDLG"));
setSizeGripEnabled(TRUE);
QVBoxLayout* TopLayout = new QVBoxLayout (this);
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
- QHBox* anOffsetsPane = new QHBox (this);
- anOffsetsPane->setSpacing(6);
+ QWidget* anOffsetsPane = new QWidget (this);
+ QHBoxLayout* aHBLay = new QHBoxLayout( anOffsetsPane );
+ aHBLay->setSpacing(6);
- new QLabel ("dX:", anOffsetsPane);
- myDxEdt = new QtxDblSpinBox (anOffsetsPane, "myDxEdt");
+ aHBLay->addWidget( new QLabel ("dX:", anOffsetsPane) );
+ aHBLay->addWidget( myDxEdt = new QtxDoubleSpinBox (anOffsetsPane) );
myDxEdt->setRange(-MAXVAL, MAXVAL);
- new QLabel("dY:", anOffsetsPane);
- myDyEdt = new QtxDblSpinBox (anOffsetsPane, "myDyEdt");
+ aHBLay->addWidget( new QLabel("dY:", anOffsetsPane) );;
+ aHBLay->addWidget( myDyEdt = new QtxDoubleSpinBox (anOffsetsPane) );
myDyEdt->setRange(-MAXVAL, MAXVAL);
- new QLabel("dZ:", anOffsetsPane);
- myDzEdt = new QtxDblSpinBox (anOffsetsPane, "myDzEdt");
+ aHBLay->addWidget( new QLabel("dZ:", anOffsetsPane) );
+ aHBLay->addWidget( myDzEdt = new QtxDoubleSpinBox (anOffsetsPane) );
myDzEdt->setRange(-MAXVAL, MAXVAL);
QPushButton* aResetBtn = new QPushButton(tr("BTN_RESET"), anOffsetsPane);
+ aHBLay->addWidget( aResetBtn );
connect(aResetBtn, SIGNAL(clicked()), this, SLOT(onReset()));
TopLayout->addWidget(anOffsetsPane);
}
// Common buttons ===========================================================
- 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());
+ QGroupBox* GroupButtons = new QGroupBox(this);
+ //GroupButtons->setColumnLayout(0, Qt::Vertical);
+ //GroupButtons->layout()->setSpacing(0);
+ //GroupButtons->layout()->setMargin(0);
+ QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons);
GroupButtonsLayout->setAlignment(Qt::AlignTop);
GroupButtonsLayout->setSpacing(6);
GroupButtonsLayout->setMargin(11);
- QPushButton* buttonOk = new QPushButton(tr("&OK"), GroupButtons, "buttonOk");
+ QPushButton* buttonOk = new QPushButton(tr("&OK"), GroupButtons);
buttonOk->setAutoDefault(TRUE);
buttonOk->setDefault(TRUE);
GroupButtonsLayout->addWidget(buttonOk, 0, 0);
GroupButtonsLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
- QPushButton* buttonApply = new QPushButton(tr("&Apply"), GroupButtons, "buttonApply");
+ QPushButton* buttonApply = new QPushButton(tr("&Apply"), GroupButtons);
buttonOk->setAutoDefault(TRUE);
GroupButtonsLayout->addWidget(buttonApply, 0, 2);
GroupButtonsLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 3);
- QPushButton* buttonCancel = new QPushButton(tr("&Cancel") , GroupButtons, "buttonCancel");
+ QPushButton* buttonCancel = new QPushButton(tr("&Cancel") , GroupButtons);
buttonCancel->setAutoDefault(TRUE);
GroupButtonsLayout->addWidget(buttonCancel, 0, 4);
GroupButtonsLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 5);
- QPushButton* buttonHelp = new QPushButton(tr("&Help") , GroupButtons, "buttonHelp");
+ QPushButton* buttonHelp = new QPushButton(tr("&Help") , GroupButtons );
buttonHelp->setAutoDefault(TRUE);
GroupButtonsLayout->addWidget(buttonHelp, 0, 6);
connect(buttonApply, SIGNAL(clicked()), this, SLOT(onApply()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
+ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged()));
+
+ onSelectionChanged();
+ show();
+}
+
+void VisuGUI_OffsetDlg::setVisible(bool show){
+ if ( show && getPrsCount() > 0 )
+ QDialog::setVisible( show );
+ else
+ QDialog::setVisible( show );
+}
+
+void VisuGUI_OffsetDlg::onSelectionChanged(){
+ if(!mySelectionMgr)
+ return;
+
+ //Clear old selection
+ clearPresentations();
+
+ SALOME_ListIO aListIO;
+ mySelectionMgr->selectedObjects(aListIO);
+
+ SalomeApp_Study* aStudy = VISU::GetAppStudy(myModule);
+ SALOME_ListIteratorOfListIO anIter(aListIO);
+ for (; anIter.More(); anIter.Next()) {
+ Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+ if (anIO->hasEntry()) {
+ QString anEntry(anIO->getEntry());
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anEntry.toLatin1().constData());
+ if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase))
+ addPresentation(aPrsObject);
+ else if (VISU::PointMap3d_i* aPrs = dynamic_cast<VISU::PointMap3d_i*>(anObjectInfo.myBase)) {
+ addPointMapPresentation(aPrs);
+ }
+ }
+ }
+}
+
+void VisuGUI_OffsetDlg::clearPresentations(){
+ myPrsList.clear();
+ myPointMapList.clear();
+ myOldOffsets.clear();
+ myOldPointMapOffsets.clear();
}
void VisuGUI_OffsetDlg::addPresentation (VISU::Prs3d_i* thePrs)
}
}
+void VisuGUI_OffsetDlg::addPointMapPresentation (VISU::PointMap3d_i* thePrs)
+{
+ myPointMapList.append(thePrs);
+
+ CORBA::Float anOffset[3];
+ thePrs->GetOffset(anOffset[0],anOffset[1],anOffset[2]);
+ OffsetStruct anOffs(anOffset[0],anOffset[1],anOffset[2]);
+ myOldPointMapOffsets.append(anOffs);
+ if (myPointMapList.count() == 1) {
+ setOffset(anOffs.myOffset);
+ } else if (myPointMapList.count() == 2) {
+ OffsetStruct anOffs;
+ setOffset(anOffs.myOffset);
+ }
+}
+
void VisuGUI_OffsetDlg::setOffset (const vtkFloatingPointType* theOffset)
{
myDxEdt->setValue(theOffset[0]);
if (myPrsList.count() == 0)
return;
- if (isToSave())
+ if (isToSave()) {
+ thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]);
+ thePrs->UpdateActors();
+ return;
+ }
+
+ ViewManagerList aViewManagerList;
+ SalomeApp_Application* anApp = myModule->getApp();
+ anApp->viewManagers(aViewManagerList);
+ QList<SUIT_ViewManager*>::Iterator anVMIter = aViewManagerList.begin();
+ for (; anVMIter != aViewManagerList.end(); anVMIter++ ) {
+ QVector<SUIT_ViewWindow*> aViews = (*anVMIter)->getViews();
+ for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+ if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+ if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
+ if (VISU_Actor* anActor = VISU::FindActor(vw, thePrs)) {
+ anActor->SetPosition(theOffset);
+ vw->onAdjustTrihedron();
+ vw->getRenderer()->ResetCameraClippingRange();
+ vw->Repaint();
+ }
+ }
+ }
+ }
+ }
+}
+
+void VisuGUI_OffsetDlg::updatePointMapOffset (VISU::PointMap3d_i* thePrs, vtkFloatingPointType* theOffset)
+{
+ if (myPointMapList.count() == 0)
+ return;
+
+ if (isToSave())
thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]);
ViewManagerList aViewManagerList;
SalomeApp_Application* anApp = myModule->getApp();
anApp->viewManagers(aViewManagerList);
- QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
- for (; anVMIter.current(); ++anVMIter) {
- SUIT_ViewManager* aViewManager = anVMIter.current();
- QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
+ SUIT_ViewManager* aViewManager;
+ foreach( aViewManager, aViewManagerList ) {
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
vw->onAdjustTrihedron();
- if (VISU_Actor* anActor = VISU::FindActor(vw, thePrs)) {
+ if (VISU_ActorBase* anActor = VISU::FindActorBase(vw, thePrs)) {
anActor->SetPosition(theOffset);
vw->highlight(thePrs->GetIO(), 1);
vw->getRenderer()->ResetCameraClippingRange();
for (int i = 0; i < myPrsList.count(); i++) {
updateOffset(myPrsList.at(i), anOffset);
}
+ for (int i = 0; i < myPointMapList.count(); i++) {
+ updatePointMapOffset(myPointMapList.at(i), anOffset);
+ }
QDialog::accept();
}
for (int i = 0; i < myPrsList.count(); i++) {
updateOffset(myPrsList.at(i), myOldOffsets[i].myOffset);
}
+ for (int i = 0; i < myPointMapList.count(); i++) {
+ updatePointMapOffset(myPointMapList.at(i), myOldOffsets[i].myOffset);
+ }
QDialog::reject();
}
{
vtkFloatingPointType anOffset[3];
getOffset(anOffset);
+
for (int i = 0; i < myPrsList.count(); i++) {
updateOffset(myPrsList.at(i), anOffset);
}
+ for (int i = 0; i < myPointMapList.count(); i++) {
+ updatePointMapOffset(myPointMapList.at(i), anOffset);
+ }
}
void VisuGUI_OffsetDlg::onHelp()
#else
platform = "application";
#endif
- SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
- QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
- arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
- QObject::tr("BUT_OK"));
+ SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
+ QObject::tr("BUT_OK"));
}
}
if ( e->isAccepted() )
return;
- if ( e->key() == Key_F1 )
+ if ( e->key() == Qt::Key_F1 )
{
e->accept();
onHelp();