Commit 08a3e745 authored by Dirk Wilden's avatar Dirk Wilden

moved the contextmenu to toolbar

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5104 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 29347067
......@@ -16,6 +16,12 @@
#include <OpenMesh/Core/System/omstream.hh>
#include <float.h>
//******************************************************************************
/** \brief initialize the Plugin
*
*/
void TopologyPlugin::pluginsInitialized() {
emit addHiddenPickMode(EDGE_FLIP_POPUP);
emit addHiddenPickMode(EDGE_SPLIT_POPUP);
......@@ -23,59 +29,49 @@ void TopologyPlugin::pluginsInitialized() {
emit addHiddenPickMode(FACE_ADD_POPUP);
emit addHiddenPickMode(FACE_SPLIT_POPUP);
emit addHiddenPickMode(FACE_DELETE_POPUP);
// emit addPickMode("Add Face" );
//create Topology Menu
// Add context Menus for vertices
trimeshMenu_ = new QMenu("Topology");
// icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"selectVertices.png");
// topologyMenu->setIcon(icon);
toolbar_ = new QToolBar("Topology");
QActionGroup* group = new QActionGroup(0);
QAction* act;
act = trimeshMenu_->addAction( EDGE_FLIP_POPUP );
act = toolbar_->addAction( EDGE_FLIP_POPUP );
act->setCheckable( true);
act->setActionGroup(group);
act = trimeshMenu_->addAction( EDGE_SPLIT_POPUP );
act = toolbar_->addAction( EDGE_SPLIT_POPUP );
act->setCheckable( true);
act->setActionGroup(group);
act = trimeshMenu_->addAction( EDGE_COLLAPSE_POPUP );
act = toolbar_->addAction( EDGE_COLLAPSE_POPUP );
act->setCheckable( true);
act->setActionGroup(group);
trimeshMenu_->addSeparator();
act = trimeshMenu_->addAction( FACE_ADD_POPUP );
toolbar_->addSeparator();
act = toolbar_->addAction( FACE_ADD_POPUP );
act->setCheckable( true);
act->setActionGroup(group);
act = trimeshMenu_->addAction( FACE_SPLIT_POPUP );
act = toolbar_->addAction( FACE_SPLIT_POPUP );
act->setCheckable( true);
act->setActionGroup(group);
act = trimeshMenu_->addAction( FACE_DELETE_POPUP );
act = toolbar_->addAction( FACE_DELETE_POPUP );
act->setCheckable( true);
act->setActionGroup(group);
group->setExclusive(true);
QActionGroup* group2 = new QActionGroup(0);
polymeshMenu_ = new QMenu("Topology");
act = polymeshMenu_->addAction( FACE_ADD_POPUP );
act->setCheckable( true);
act->setActionGroup(group2);
act = polymeshMenu_->addAction( FACE_DELETE_POPUP );
act->setCheckable( true);
act->setActionGroup(group2);
connect( toolbar_, SIGNAL( actionTriggered(QAction*) ), this, SLOT( toolBarTriggered(QAction*) ));
group2->setExclusive(true);
emit addToolbar( toolbar_ );
}
emit addContextMenu(trimeshMenu_ , DATA_TRIANGLE_MESH , CONTEXTTOPLEVELMENU );
emit addContextMenu(polymeshMenu_ , DATA_POLY_MESH , CONTEXTTOPLEVELMENU );
connect( trimeshMenu_, SIGNAL( triggered(QAction*) ), this, SLOT( contextMenuTriggered(QAction*) ));
connect( polymeshMenu_, SIGNAL( triggered(QAction*) ), this, SLOT( contextMenuTriggered(QAction*) ));
//******************************************************************************
}
void TopologyPlugin::contextMenuTriggered(QAction* _action){
/** \brief Toolbar action was triggered
*
* @param _action the action that was triggered
*/
void TopologyPlugin::toolBarTriggered(QAction* _action){
if ( _action->text() == EDGE_FLIP_POPUP)
PluginFunctions::pickMode(EDGE_FLIP_POPUP);
else if ( _action->text() == EDGE_SPLIT_POPUP)
......@@ -92,24 +88,13 @@ void TopologyPlugin::contextMenuTriggered(QAction* _action){
PluginFunctions::actionMode(Viewer::PickingMode);
}
void TopologyPlugin::slotUpdateContextMenu( int /*_objectId*/ ){
//update trimesh checkstate
for (int i=0; i < trimeshMenu_->actions().count(); i++)
if ( (trimeshMenu_->actions()[i])->text().toStdString() == PluginFunctions::pickMode())
(trimeshMenu_->actions()[i])->setChecked( true );
else
(trimeshMenu_->actions()[i])->setChecked( false );
//update polymesh checkstate
for (int i=0; i < polymeshMenu_->actions().count(); i++)
if ( (polymeshMenu_->actions()[i])->text().toStdString() == PluginFunctions::pickMode())
(polymeshMenu_->actions()[i])->setChecked( true );
else
(polymeshMenu_->actions()[i])->setChecked( false );
}
//******************************************************************************
/** \brief this is called when a mouse event occurred
*
* @param _event the event that occurred
*/
void TopologyPlugin::slotMouseEvent( QMouseEvent* _event ) {
if ( _event->buttons() == Qt::RightButton )
return;
......@@ -122,6 +107,12 @@ void TopologyPlugin::slotMouseEvent( QMouseEvent* _event ) {
if ( PluginFunctions::pickMode() == FACE_DELETE_POPUP ) { delete_face(_event); }
}
//******************************************************************************
/** \brief Deselect the vertices from AddFace mode
*
*/
void TopologyPlugin::clearAddFaceVertices() {
for ( uint i = 0 ; i < addFaceVertices_.size() ; ++i ) {
BaseObjectData* object;
......@@ -152,6 +143,13 @@ void TopologyPlugin::clearAddFaceVertices() {
emit updateView();
}
//******************************************************************************
/** \brief Add a face
*
* @param _event mouse position where one of the vertices is picked
*/
void TopologyPlugin::add_face(QMouseEvent* _event) {
if (( _event->type() != QEvent::MouseButtonPress) && (_event->type() != QEvent::MouseButtonDblClick))
return;
......@@ -376,9 +374,15 @@ void TopologyPlugin::add_face(QMouseEvent* _event) {
}
}
}
}
//******************************************************************************
/** \brief Split a face at the given point
*
* @param _event mouse position where the face is picked
*/
void TopologyPlugin::split_face(QMouseEvent* _event) {
if ( _event->type() != QEvent::MouseButtonPress )
return;
......@@ -416,6 +420,13 @@ void TopologyPlugin::split_face(QMouseEvent* _event) {
}
}
//******************************************************************************
/** \brief Delete a face at the given position
*
* @param _event mouse position where the face is picked
*/
void TopologyPlugin::delete_face(QMouseEvent* _event) {
if ( _event->type() != QEvent::MouseButtonPress )
return;
......@@ -459,6 +470,13 @@ void TopologyPlugin::delete_face(QMouseEvent* _event) {
}
}
//******************************************************************************
/** \brief Flip an edge at the given position
*
* @param _event mouse position where the edge is picked
*/
void TopologyPlugin::flip_edge(QMouseEvent* _event) {
if ( _event->type() != QEvent::MouseButtonPress )
return;
......@@ -516,6 +534,13 @@ void TopologyPlugin::flip_edge(QMouseEvent* _event) {
}
}
//******************************************************************************
/** \brief Collapse an edge at the given position
*
* @param _event mouse position where the edge is picked
*/
void TopologyPlugin::collapse_edge(QMouseEvent* _event) {
if ( _event->type() != QEvent::MouseButtonPress )
return;
......@@ -581,6 +606,13 @@ void TopologyPlugin::collapse_edge(QMouseEvent* _event) {
}
}
//******************************************************************************
/** \brief Split an edge at the given position
*
* @param _event mouse position where the edge is picked
*/
void TopologyPlugin::split_edge(QMouseEvent* _event) {
if ( _event->type() != QEvent::MouseButtonPress )
return;
......
#ifndef TOPOLOGYPLUGIN_HH
#define TOPOLOGYPLUGIN_HH
#include <QObject>
#include <QMenuBar>
#include <QGroupBox>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/MouseInterface.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/PickingInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
#include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
class TopologyPlugin : public QObject, BaseInterface , MouseInterface, KeyInterface, PickingInterface, BackupInterface, LoggingInterface, ContextMenuInterface
class TopologyPlugin : public QObject, BaseInterface , MouseInterface, KeyInterface, PickingInterface, BackupInterface, LoggingInterface, ToolbarInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
......@@ -25,34 +21,42 @@ class TopologyPlugin : public QObject, BaseInterface , MouseInterface, KeyInterf
Q_INTERFACES(PickingInterface)
Q_INTERFACES(BackupInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(ContextMenuInterface)
Q_INTERFACES(ToolbarInterface)
signals:
// BaseInterface
void updateView();
void updatedObject(int);
// PickingInterface
void addHiddenPickMode( const std::string _mode );
// BackupInterface
void createBackup( int _id , QString _name );
// LoggingInterface
void log(Logtype _type, QString _message);
void log(QString _message);
void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type );
// ToolbarInterface
void addToolbar(QToolBar* _toolbar);
private slots:
void slotMouseEvent( QMouseEvent* _event );
void slotKeyEvent( QKeyEvent* /*_event*/ ){};
// BaseInterface
void pluginsInitialized();
void contextMenuTriggered(QAction* _action);
// MouseInterface
void slotMouseEvent( QMouseEvent* _event );
private slots:
void slotUpdateContextMenu( int _objectId );
/// called when an action on the toolbar was triggered
void toolBarTriggered(QAction* _action);
public :
/// Destructor
~TopologyPlugin() {};
......@@ -83,9 +87,10 @@ class TopologyPlugin : public QObject, BaseInterface , MouseInterface, KeyInterf
void split_edge(QMouseEvent* _event);
private:
std::vector< std::pair<int,int> > addFaceVertices_;
QMenu* trimeshMenu_;
QMenu* polymeshMenu_;
QToolBar* toolbar_;
public slots:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment