# header files
EXPORT_HEADERS= SOCC.h \
SOCC_ViewModel.h \
- SOCC_Prs.h
+ SOCC_Prs.h \
+ SOCC_ViewWindow.h
# Libraries targets
LIB = libSOCC.la
LIB_SRC= SOCC_ViewModel.cxx \
- SOCC_Prs.cxx
+ SOCC_Prs.cxx \
+ SOCC_ViewWindow.cxx
-LIB_MOC = SOCC_ViewModel.h
+LIB_MOC = SOCC_ViewModel.h \
+ SOCC_ViewWindow.h
LIB_CLIENT_IDL = SALOMEDS.idl \
SALOME_Exception.idl \
#include "SOCC_ViewModel.h"
#include "SOCC_Prs.h"
+#include "SOCC_ViewWindow.h"
#include "SUIT_Session.h"
#include "SUIT_Application.h"
// onAdjustTrihedron();
getViewer3d()->Update();
}
+
+//=======================================================================
+// name : createView
+// Purpose : create SOCC_ViewWindow
+//=======================================================================
+SUIT_ViewWindow* SOCC_Viewer::createView( SUIT_Desktop* theDesktop )
+{
+ SOCC_ViewWindow* view = new SOCC_ViewWindow(theDesktop, this);
+ initView( view );
+ return view;
+}
void rename( const Handle(SALOME_InteractiveObject)&, const QString& );
+ virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
+
/* Reimplemented from SALOME_View */
virtual void Display( const SALOME_OCCPrs* );
virtual void Erase( const SALOME_OCCPrs*, const bool = false );
--- /dev/null
+#include "SOCC_ViewWindow.h"
+
+#include "OCCViewer_ViewPort3d.h"
+
+#include "SUIT_Accel.h"
+
+//----------------------------------------------------------------------------
+SOCC_ViewWindow
+::SOCC_ViewWindow( SUIT_Desktop* theDesktop,
+ OCCViewer_Viewer* theModel)
+ : OCCViewer_ViewWindow( theDesktop, theModel )
+{
+}
+
+//----------------------------------------------------------------------------
+SOCC_ViewWindow
+::~SOCC_ViewWindow()
+{
+}
+
+//----------------------------------------------------------------------------
+void
+SOCC_ViewWindow
+::action( const int theAction )
+{
+ const int inc = 10;
+ int cx, cy;
+ if ( theAction == SUIT_Accel::ZoomIn || theAction == SUIT_Accel::ZoomOut ||
+ theAction == SUIT_Accel::RotateLeft || theAction == SUIT_Accel::RotateRight ||
+ theAction == SUIT_Accel::RotateUp || theAction == SUIT_Accel::RotateDown ) {
+ cx = myViewPort->width() / 2;
+ cy = myViewPort->height() / 2;
+ }
+ switch ( theAction ) {
+ case SUIT_Accel::PanLeft :
+ myViewPort->pan( -inc, 0 );
+ break;
+ case SUIT_Accel::PanRight :
+ myViewPort->pan( inc, 0 );
+ break;
+ case SUIT_Accel::PanUp :
+ myViewPort->pan( 0, inc );
+ break;
+ case SUIT_Accel::PanDown :
+ myViewPort->pan( 0, -inc );
+ break;
+ case SUIT_Accel::ZoomIn :
+ myViewPort->zoom( cx, cy, cx + inc, cy + inc );
+ break;
+ case SUIT_Accel::ZoomOut :
+ myViewPort->zoom( cx, cy, cx - inc, cy - inc );
+ break;
+ case SUIT_Accel::ZoomFit :
+ myViewPort->fitAll();
+ break;
+ case SUIT_Accel::RotateLeft :
+ myViewPort->startRotation( cx, cy );
+ myViewPort->rotate( cx - inc, cy );
+ myViewPort->endRotation();
+ break;
+ case SUIT_Accel::RotateRight :
+ myViewPort->startRotation( cx, cy );
+ myViewPort->rotate( cx + inc, cy );
+ myViewPort->endRotation();
+ break;
+ case SUIT_Accel::RotateUp :
+ myViewPort->startRotation( cx, cy );
+ myViewPort->rotate( cx, cy - inc );
+ myViewPort->endRotation();
+ break;
+ case SUIT_Accel::RotateDown :
+ myViewPort->startRotation( cx, cy );
+ myViewPort->rotate( cx, cy + inc );
+ myViewPort->endRotation();
+ break;
+ }
+}
--- /dev/null
+#ifndef SOCC_VIEWWINDOW_H
+#define SOCC_VIEWWINDOW_H
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+#include "SOCC.h"
+#include "OCCViewer_ViewWindow.h"
+
+class SOCC_EXPORT SOCC_ViewWindow : public OCCViewer_ViewWindow
+{
+ Q_OBJECT;
+
+public:
+ SOCC_ViewWindow( SUIT_Desktop*, OCCViewer_Viewer* );
+ virtual ~SOCC_ViewWindow();
+
+protected:
+ virtual void action( const int );
+
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
SUIT_ViewManager.h \
SUIT_ViewModel.h \
SUIT_ViewWindow.h \
- SUIT_SelectionFilter.h
+ SUIT_SelectionFilter.h \
+ SUIT_Accel.h
# .po files to transform in .qm
PO_FILES = SUIT_images.po \
SUIT_ViewManager.cxx \
SUIT_ViewModel.cxx \
SUIT_ViewWindow.cxx \
- SUIT_SelectionFilter.cxx
+ SUIT_SelectionFilter.cxx \
+ SUIT_Accel.cxx
LIB_MOC = SUIT_ActionOperation.h \
SUIT_Application.h \
SUIT_ViewWindow.h \
SUIT_ViewManager.h \
SUIT_SelectionMgr.h \
- SUIT_Selector.h
+ SUIT_Selector.h \
+ SUIT_Accel.h
RESOURCES_FILES = \
cascade.png \
--- /dev/null
+// SUIT_Accel.cxx: implementation of the SUIT_Accel class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "SUIT_Accel.h"
+#include "SUIT_Desktop.h"
+#include "SUIT_ViewManager.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewModel.h"
+
+#include <qaccel.h>
+
+/*!\class SUIT_Accel
+ * Class handles keyboard accelerator bindings.
+ */
+
+/*! Constructor.*/
+SUIT_Accel::SUIT_Accel(SUIT_Desktop* theDesktop)
+ : QObject( theDesktop, "SUIT_Accel" ),
+ myDesktop( theDesktop )
+{
+ myAccel = new QAccel( theDesktop, "SUIT_Accel_interal_qaccel" );
+ connect( myAccel, SIGNAL( activated( int ) ), this, SLOT( onActivated( int ) ) );
+}
+
+/*! Destructor.*/
+SUIT_Accel::~SUIT_Accel()
+{
+}
+
+/*! setActionKey assign a ceratain action for a key accelerator */
+void SUIT_Accel::setActionKey( const int action, const int key, const QString& type )
+{
+ if ( myKeyActionMap.contains( key ) )
+ myAccel->removeItem( action );
+
+ myKeyActionMap[key] = action;
+ QStringList vTypes;
+ if ( myActionViewerTypesMap.contains( action ) )
+ vTypes = myActionViewerTypesMap[action];
+ if ( !vTypes.contains( type ) )
+ vTypes.append( type );
+ myActionViewerTypesMap[action] = vTypes;
+
+ myAccel->insertItem( key, action );
+}
+
+/*! onActivated slot called when a registered key accelerator was activated */
+void SUIT_Accel::onActivated( int action )
+{
+ if ( myDesktop ) {
+ if ( SUIT_ViewWindow* vw = myDesktop->activeWindow() ) {
+ QString type = vw->getViewManager()->getViewModel()->getType();
+ if ( myActionViewerTypesMap.contains( action ) ) {
+ QStringList vTypes = myActionViewerTypesMap[action];
+ if ( vTypes.contains( type ) ) {
+ vw->onAccelAction( action );
+ }
+ }
+ }
+ }
+}
+
--- /dev/null
+// SUIT_Accel.h: interface for the SUIT_Accel class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef SUIT_Accel_h
+#define SUIT_Accel_h
+
+#include "SUIT.h"
+
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qmap.h>
+
+class QAccel;
+class SUIT_Desktop;
+
+class SUIT_EXPORT SUIT_Accel: public QObject
+{
+ Q_OBJECT
+
+public:
+ SUIT_Accel( SUIT_Desktop* theDesktop );
+ virtual ~SUIT_Accel();
+
+ enum Actions { PanLeft = 1, PanRight, PanUp, PanDown, ZoomIn, ZoomOut, ZoomFit, RotateLeft, RotateRight, RotateUp, RotateDown, UserAction };
+ void setActionKey( const int action, const int key, const QString& type );
+
+protected slots:
+ void onActivated( int );
+
+private:
+ QAccel* myAccel;
+ SUIT_Desktop* myDesktop;
+
+ typedef QMap<int, int> KeyActionMap; // key-to-action map
+ typedef QMap<int, QStringList> ActionViewerTypesMap; // key=action id
+ KeyActionMap myKeyActionMap;
+ ActionViewerTypesMap myActionViewerTypesMap;
+};
+
+#endif
{
myDesktop = theDesktop;
}
+
/*! Destructor.*/
SUIT_ViewWindow::~SUIT_ViewWindow()
{
}
return QMainWindow::event( e );
}
+
+/*! Called by SUIT_Accel::onActivated() when a key accelerator was activated and this window was active
+*/
+void SUIT_ViewWindow::onAccelAction( int _action )
+{
+ action( _action );
+}
+
+/*! action handle standard action (zoom, pan) or custom action. to be redefined in successors.
+*/
+void SUIT_ViewWindow::action( const int )
+{
+}
bool event(QEvent*);
virtual QImage dumpView() { return QImage(); }
+ void onAccelAction( int );
public slots:
virtual void onDumpView();
void closeEvent(QCloseEvent* theEvent);
virtual void contextMenuEvent( QContextMenuEvent * e );
+ virtual void action( const int );
+
SUIT_Desktop* myDesktop;
SUIT_ViewManager* myManager;
};
#include "SUIT_Session.h"
#include "SUIT_ToolButton.h"
#include "SUIT_MessageBox.h"
+#include "SUIT_Accel.h"
#include "SUIT_Tools.h"
#include "SUIT_ResourceMgr.h"
QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() );
return px.convertToImage();
}
+
+//----------------------------------------------------------------------------
+void
+SVTK_ViewWindow
+::action( const int theAction )
+{
+ switch ( theAction ) {
+ case SUIT_Accel::PanLeft : onPanLeft(); break;
+ case SUIT_Accel::PanRight : onPanRight(); break;
+ case SUIT_Accel::PanUp : onPanUp(); break;
+ case SUIT_Accel::PanDown : onPanDown(); break;
+ case SUIT_Accel::ZoomIn : onZoomIn(); break;
+ case SUIT_Accel::ZoomOut : onZoomOut(); break;
+ case SUIT_Accel::ZoomFit : onFitAll(); break;
+ case SUIT_Accel::RotateLeft : onRotateLeft(); break;
+ case SUIT_Accel::RotateRight : onRotateRight(); break;
+ case SUIT_Accel::RotateUp : onRotateUp(); break;
+ case SUIT_Accel::RotateDown : onRotateDown(); break;
+ }
+}
protected:
QImage dumpView();
+ virtual void action( const int );
protected slots:
void onKeyPressed(QKeyEvent* event);