Commit 121f9089 authored by Marlin Frickenschmidt's avatar Marlin Frickenschmidt

ViewControl now has a viewing direction toolbar with which the viewing...

ViewControl now has a viewing direction toolbar with which the viewing cirection can quickly be set. Comes with six custom-made, awesome, axis-colored icons!

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10397 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8ebb6d0f
......@@ -4,4 +4,4 @@ if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/TSplineMesh)
add_definitions (-DENABLE_TSPLINEMESH_SUPPORT)
endif ()
openflipper_plugin (DIRS TSplineMesh)
openflipper_plugin (DIRS TSplineMesh INSTALLDATA Icons)
......@@ -99,7 +99,28 @@ void ViewControlPlugin::pluginsInitialized() {
connect( viewControlMenu_, SIGNAL( triggered(QAction*) ), this, SLOT( contextMenuTriggered(QAction*) ));
setDescriptions();
// TOOLBAR
toolbar_ = new QToolBar(tr("Viewing Directions"));
emit addToolbar(toolbar_);
toolbarViewingDirections_ = new QActionGroup(toolbar_);
QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
viewTop_ = new QAction( QIcon(iconPath + "viewcontrol_top.png"), tr("View from top") , toolbarViewingDirections_);
toolbar_->addAction( viewTop_ );
viewBottom_ = new QAction( QIcon(iconPath + "viewcontrol_bottom.png"), tr("View from bottom") , toolbarViewingDirections_);
toolbar_->addAction( viewBottom_ );
viewLeft_ = new QAction( QIcon(iconPath + "viewcontrol_left.png"), tr("View from left") , toolbarViewingDirections_);
toolbar_->addAction( viewLeft_ );
viewRight_ = new QAction( QIcon(iconPath + "viewcontrol_right.png"), tr("View from right") , toolbarViewingDirections_);
toolbar_->addAction( viewRight_ );
viewFront_ = new QAction( QIcon(iconPath + "viewcontrol_front.png"), tr("View from front") , toolbarViewingDirections_);
toolbar_->addAction( viewFront_ );
viewBack_ = new QAction( QIcon(iconPath + "viewcontrol_back.png"), tr("View from back") , toolbarViewingDirections_);
toolbar_->addAction( viewBack_ );
connect( toolbarViewingDirections_, SIGNAL( triggered(QAction*) ), this, SLOT(setView(QAction*)) );
}
void ViewControlPlugin::updateShaderList() {
......@@ -1151,6 +1172,51 @@ Vector ViewControlPlugin::sceneCenter( int _viewer ) {
//-----------------------------------------------------------------------------
void ViewControlPlugin::setView(int _mode, int _viewer ) {
switch ( _mode ){
case PluginFunctions::VIEW_TOP : //TOP
setViewingDirection( ACG::Vec3d(0.0, -1.0, 0.0), ACG::Vec3d(0.0, 0.0, -1.0), _viewer );
break;
case PluginFunctions::VIEW_BOTTOM : //BOTTOM
setViewingDirection( ACG::Vec3d(0.0, 1.0, 0.0), ACG::Vec3d(0.0, 0.0, -1.0), _viewer );
break;
case PluginFunctions::VIEW_LEFT : //LEFT
setViewingDirection( ACG::Vec3d(1.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
break;
case PluginFunctions::VIEW_RIGHT : //RIGHT
setViewingDirection( ACG::Vec3d(-1.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
break;
case PluginFunctions::VIEW_FRONT : //FRONT
setViewingDirection( ACG::Vec3d(0.0, 0.0, -1.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
break;
case PluginFunctions::VIEW_BACK : //BACK
setViewingDirection( ACG::Vec3d(0.0, 0.0, 1.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
break;
default :
emit log(LOGERR, "ViewControl: Unknown view mode: " + QString::number(_mode));
break;
}
PluginFunctions::allowRotation(true, _viewer);
updateView();
}
//-----------------------------------------------------------------------------
void ViewControlPlugin::setView(QAction* _action) {
if ( _action == viewTop_) setView (PluginFunctions::VIEW_TOP, PluginFunctions::ACTIVE_VIEWER);
else if ( _action == viewBottom_) setView (PluginFunctions::VIEW_BOTTOM, PluginFunctions::ACTIVE_VIEWER);
else if ( _action == viewLeft_) setView (PluginFunctions::VIEW_LEFT, PluginFunctions::ACTIVE_VIEWER);
else if ( _action == viewRight_) setView (PluginFunctions::VIEW_RIGHT, PluginFunctions::ACTIVE_VIEWER);
else if ( _action == viewFront_) setView (PluginFunctions::VIEW_FRONT, PluginFunctions::ACTIVE_VIEWER);
else if ( _action == viewBack_) setView (PluginFunctions::VIEW_BACK, PluginFunctions::ACTIVE_VIEWER);
else emit log(LOGERR, "ViewControl: Unknown view mode action!");
}
//-----------------------------------------------------------------------------
void ViewControlPlugin::setEyePosition(Vector _eye){
emit log(LOGERR, "not yet implemented");
}
......
......@@ -50,6 +50,7 @@
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/PickingInterface.hh>
#include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
#include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
......@@ -79,21 +80,29 @@ struct ShaderInfo {
QStringList uniformsMin;
};
class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, LoggingInterface, ContextMenuInterface
class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, LoggingInterface, ToolbarInterface, ContextMenuInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(PickingInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(ToolbarInterface)
Q_INTERFACES(ContextMenuInterface)
signals:
//BaseInterface
void updateView();
//PickingInterface
void addHiddenPickMode( const std::string _mode );
//LoggingInterface
void log(Logtype _type, QString _message);
void log(QString _message);
//ToolbarInterface
void addToolbar(QToolBar* _toolbar);
void getToolBar(QString _name, QToolBar*& _toolbar);
// ContextMenuInterface
void addContextMenuItem(QAction* _action , ContextMenuType _type);
......@@ -139,6 +148,15 @@ class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, Logg
/** List of available shaders
*/
std::vector <ShaderInfo> shaderList_;
QToolBar* toolbar_;
QActionGroup* toolbarViewingDirections_;
QAction* viewTop_;
QAction* viewBottom_;
QAction* viewLeft_;
QAction* viewRight_;
QAction* viewFront_;
QAction* viewBack_;
private slots:
QString version() { return QString("1.0"); };
......@@ -157,6 +175,12 @@ class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, Logg
// slot is called when the data of the uniforms-table changes
void itemChanged(QTableWidgetItem* item);
// Set the view to one of the six possible look-at directions
void setView(int _mode, int _viewer = PluginFunctions::ACTIVE_VIEWER );
// Set the view mode using the defined actions
void setView(QAction* _action);
private:
// Update the list of available shaders
......
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