SVTK_ViewModelBase.h \
SVTK_SetRotationPointDlg.h \
SVTK_ViewParameterDlg.h \
+ SVTK_ComboAction.h \
SVTK_Extension.h
dist_libSVTK_la_SOURCES= \
SVTK_Selector.cxx \
SVTK_SetRotationPointDlg.cxx \
SVTK_ViewParameterDlg.cxx \
+ SVTK_ComboAction.cxx \
SVTK_Extension.cxx
EXTRA_DIST+= SVTK_SelectorDef.h SVTK_Trihedron.h
SVTK_ViewModel_moc.cxx \
SVTK_View_moc.cxx \
SVTK_SetRotationPointDlg_moc.cxx \
- SVTK_ViewParameterDlg_moc.cxx
+ SVTK_ViewParameterDlg_moc.cxx \
+ SVTK_ComboAction_moc.cxx
nodist_libSVTK_la_SOURCES= $(MOC_FILES)
dist_salomeres_DATA=\
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// 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 :
+// Author :
+// Module : SALOME
+// $Header:
+
+#include "SVTK_ComboAction.h"
+
+#include <QComboBox>
+#include <QHBoxLayout>
+
+SVTK_ComboAction::SVTK_ComboAction( QObject* parent )
+ : QWidgetAction( parent )
+{
+ myCurId = -1;
+}
+
+SVTK_ComboAction::SVTK_ComboAction( const QString& text, QObject* parent )
+ : QWidgetAction( parent )
+{
+ setToolTip( text );
+ myCurId = -1;
+}
+
+SVTK_ComboAction::~SVTK_ComboAction()
+{
+ myIcons.clear();
+}
+
+void SVTK_ComboAction::insertItem( const QIcon& icon, const int index )
+{
+ if ( index < 0 || index > myIcons.size() )
+ myIcons.append( icon );
+ else
+ myIcons.insert( index, icon );
+
+ update();
+}
+
+void SVTK_ComboAction::clear()
+{
+ myIcons.clear();
+ update();
+}
+
+void SVTK_ComboAction::setCurrentIndex( const int id )
+{
+ if ( myCurId != id )
+ {
+ myCurId = id;
+ update();
+ }
+}
+
+int SVTK_ComboAction::currentIndex() const
+{
+ return myCurId;
+}
+
+QWidget* SVTK_ComboAction::createWidget( QWidget* parent )
+{
+ QWidget* w = 0;
+ if ( parent->inherits("QToolBar") )
+ {
+ w = new QWidget( parent );
+ QHBoxLayout* l = new QHBoxLayout( w );
+ l->setSpacing(0); l->setMargin(0);
+ QComboBox* combo = new QComboBox( w );
+ combo->setFocusPolicy( Qt::NoFocus );
+ combo->setSizeAdjustPolicy( QComboBox::AdjustToContents );
+ l->addSpacing( 3 );
+ l->addWidget( combo );
+ l->addSpacing( 3 );
+
+ updateCombo( combo );
+ connect( combo, SIGNAL( activated( int ) ), this, SIGNAL( triggered( int ) ) );
+ }
+ return w;
+}
+
+void SVTK_ComboAction::update()
+{
+ QList<QWidget*> aList = createdWidgets();
+ for ( QList<QWidget*>::const_iterator it = aList.begin(); it != aList.end(); ++it )
+ updateCombo( qFindChild<QComboBox*>(*it) );
+}
+
+void SVTK_ComboAction::updateCombo( QComboBox* combo )
+{
+ if ( !combo ) return;
+
+ combo->clear();
+
+ for ( QList<QIcon>::const_iterator it = myIcons.begin(); it != myIcons.end(); ++it )
+ combo->addItem( *it, "" );
+
+ if ( combo->count() > 0 ) {
+ if ( myCurId < 0 ) myCurId = 0;
+ combo->setCurrentIndex( myCurId );
+ }
+}
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// 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 :
+// Author :
+// Module : SALOME
+// $Header:
+
+#ifndef SVTK_COMBOACTION_H
+#define SVTK_COMBOACTION_H
+
+#include "SVTK.h"
+
+#include <QWidgetAction>
+
+class QComboBox;
+class SVTK_EXPORT SVTK_ComboAction : public QWidgetAction
+{
+ Q_OBJECT
+
+public:
+ SVTK_ComboAction( QObject* = 0 );
+ SVTK_ComboAction( const QString&, QObject* = 0 );
+ virtual ~SVTK_ComboAction();
+
+ void insertItem( const QIcon&, const int = -1 );
+ void clear();
+
+ void setCurrentIndex( const int );
+ int currentIndex() const;
+
+signals:
+ void triggered( int );
+
+protected:
+ virtual QWidget* createWidget( QWidget* );
+
+ virtual void update();
+ virtual void updateCombo( QComboBox* );
+
+private:
+ QList<QIcon> myIcons;
+ int myCurId;
+};
+
+#endif // SVTK_COMBOACTION_H
#include <vtkGenericRenderWindowInteractor.h>
#include <vtkRenderer.h>
+#include <vtkCamera.h>
#include <QtxAction.h>
#include <QtxMultiAction.h>
#include "SVTK_RenderWindowInteractor.h"
#include "SVTK_InteractorStyle.h"
#include "SVTK_Selector.h"
+#include "SVTK_ComboAction.h"
/*!
Constructor
connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
mgr->registerAction( anAction, UpdateRate );
+ // Set projection mode
+ SVTK_ComboAction* aModeAction = new SVTK_ComboAction(tr("MNU_SVTK_PROJECTION_MODE"), this);
+ aModeAction->setStatusTip(tr("DSC_SVTK_PROJECTION_MODE"));
+ aModeAction->insertItem(theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ) );
+ aModeAction->insertItem(theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ) );
+ connect(aModeAction, SIGNAL(triggered(int)), this, SLOT(onProjectionMode(int)));
+ mgr->registerAction( aModeAction, ProjectionModeId );
+
// View Parameters
anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
mgr->append( NonIsometric, myToolBar );
mgr->append( GraduatedAxes, myToolBar );
+ mgr->append( ProjectionModeId, myToolBar );
mgr->append( ViewParametersId, myToolBar );
}
myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
}
+/*!
+ Set the view projection mode: orthogonal or perspective
+*/
+void
+SVTK_MainWindow
+::onProjectionMode(int mode)
+{
+ vtkCamera* aCamera = getRenderer()->GetActiveCamera();
+ aCamera->SetParallelProjection(mode==0);
+ GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+}
+
/*!
Modify view parameters
*/
myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
}
+void SVTK_MainWindow::activateProjectionMode(int mode)
+{
+ SVTK_ComboAction* a = ::qobject_cast<SVTK_ComboAction*>( action(ProjectionModeId) );
+ if ( a ) a->setCurrentIndex(mode);
+}
+
/*!
Starts global panning transformation
*/
void onViewParameters(bool theIsActivate);
+ void activateProjectionMode(int);
+
void activateSetFocalPointGravity();
void activateSetFocalPointSelected();
void activateStartFocalPointSelection();
void onAdjustTrihedron();
void onAdjustCubeAxes();
+ void onProjectionMode(int mode);
+
public:
QImage dumpView();
ChangeRotationPointId, RotationId,
FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId,
ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate,
- ViewParametersId };
+ ProjectionModeId, ViewParametersId };
SUIT_ViewWindow* myViewWindow;
int aParallel = aCamera->GetParallelProjection();
myProjectionMode->button(aParallel?0:1)->setChecked(true);
+ onProjectionModeChanged( myProjectionMode->checkedId() );
double focal[3], pos[3], vup[3], proj[3], dist, scale, angle;
vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera();
aCamera->SetParallelProjection(aBtn == 0);
+ myMainWindow->activateProjectionMode(aBtn);
+
// update view
myRWInteractor->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);