Commit 2b582282 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

set fixed view directions via context menu or options

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6694 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b8bb0db3
...@@ -249,6 +249,49 @@ void setBackColor( OpenMesh::Vec4f _color) { ...@@ -249,6 +249,49 @@ void setBackColor( OpenMesh::Vec4f _color) {
PluginFunctions::viewerProperties(i).backgroundColor(_color); PluginFunctions::viewerProperties(i).backgroundColor(_color);
} }
void setFixedView(int _mode, int _viewer ) {
if ( (_viewer != ACTIVE_VIEWER ) && ( ( _viewer < 0 ) || _viewer >= (int)examiner_widgets_.size()) ){
std::cerr << "Unable to set fixed view. Wrong viewer id (" << _viewer << ")" << std::endl;
return;
}
switch ( _mode ){
case VIEW_TOP : //TOP
PluginFunctions::viewingDirection( ACG::Vec3d(0.0, -1.0, 0.0), ACG::Vec3d(0.0, 0.0, -1.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
case VIEW_BOTTOM : //BOTTOM
PluginFunctions::viewingDirection( ACG::Vec3d(0.0, 1.0, 0.0), ACG::Vec3d(0.0, 0.0, -1.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
case VIEW_LEFT : //LEFT
PluginFunctions::viewingDirection( ACG::Vec3d(1.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
case VIEW_RIGHT : //RIGHT
PluginFunctions::viewingDirection( ACG::Vec3d(-1.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
case VIEW_FRONT : //FRONT
PluginFunctions::viewingDirection( ACG::Vec3d(0.0, 0.0, -1.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
case VIEW_BACK : //BACK
PluginFunctions::viewingDirection( ACG::Vec3d(0.0, 0.0, 1.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
default : //Free View
PluginFunctions::allowRotation(true, _viewer);
break;
}
if ( _viewer == ACTIVE_VIEWER )
viewerProperties(activeExaminer()).currentViewingDirection( _mode );
else
viewerProperties( _viewer ).currentViewingDirection( _mode );
}
QPoint mapToGlobal(const QPoint _point ) { QPoint mapToGlobal(const QPoint _point ) {
return examiner_widgets_[activeExaminer_]->glMapToGlobal(_point); return examiner_widgets_[activeExaminer_]->glMapToGlobal(_point);
} }
...@@ -413,8 +456,27 @@ void orthographicProjection( int _viewer ) { ...@@ -413,8 +456,27 @@ void orthographicProjection( int _viewer ) {
std::cerr << "Requested illegal viewer for orthographicProjection()!!" << std::endl; std::cerr << "Requested illegal viewer for orthographicProjection()!!" << std::endl;
} }
void allowRotation(bool _mode) { void allowRotation(bool _mode, int _viewer ) {
examiner_widget_->allowRotation(_mode); if ( _viewer == ACTIVE_VIEWER ) {
examiner_widgets_[activeExaminer_]->allowRotation(_mode);
} else if ( _viewer == ALL_VIEWERS )
for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
examiner_widgets_[i]->allowRotation(_mode);
else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
examiner_widgets_[_viewer]->allowRotation(_mode);
else
std::cerr << "Requested illegal viewer for allowRotation!!" << std::endl;
}
bool allowRotation( int _viewer ) {
if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
return examiner_widgets_[_viewer]->allowRotation();
else {
std::cerr << "Requested illegal viewer for isRotationAllowed!!" << std::endl;
return false;
}
} }
void setMainGLContext() { void setMainGLContext() {
...@@ -563,6 +625,21 @@ ACG::Vec3d viewingDirection(int _viewer) { ...@@ -563,6 +625,21 @@ ACG::Vec3d viewingDirection(int _viewer) {
return viewerProperties().glState().viewing_direction(); return viewerProperties().glState().viewing_direction();
} }
bool isProjectionOrthographic( int _viewer ) {
if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() ){
if ( examiner_widgets_[_viewer]->projectionMode() == 0) //ORTHOGRAPHIC_PROJECTION
return true;
else
return false;
} else
std::cerr << "Requested illegal viewer for isProjectionOrthographic!!" << std::endl;
return false;
}
ACG::Vec3d eyePos(int _viewer) { ACG::Vec3d eyePos(int _viewer) {
if ( _viewer == ACTIVE_VIEWER ) { if ( _viewer == ACTIVE_VIEWER ) {
return viewerProperties(activeExaminer_).glState().eye(); return viewerProperties(activeExaminer_).glState().eye();
......
...@@ -60,6 +60,14 @@ namespace PluginFunctions { ...@@ -60,6 +60,14 @@ namespace PluginFunctions {
const int ALL_VIEWERS = -2; const int ALL_VIEWERS = -2;
const int ACTIVE_VIEWER = -1; const int ACTIVE_VIEWER = -1;
const int VIEW_FREE = 0;
const int VIEW_TOP = 1;
const int VIEW_BOTTOM = 2;
const int VIEW_LEFT = 3;
const int VIEW_RIGHT = 4;
const int VIEW_FRONT = 5;
const int VIEW_BACK = 6;
//======================================= //=======================================
// Get/set status of viewers // Get/set status of viewers
/** @name Viewer Status and properties /** @name Viewer Status and properties
...@@ -86,9 +94,23 @@ Viewer::ViewerProperties& viewerProperties(int _id = -1); ...@@ -86,9 +94,23 @@ Viewer::ViewerProperties& viewerProperties(int _id = -1);
/** Lock scene rotation via mouse /** Lock scene rotation via mouse
* *
* @param _mode allow or disallow rotation * @param _mode allow or disallow rotation
* @param _viewer Id of the viewer to use.
* ALL_VIEWERS will set all viewers (Default)
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/ */
DLLEXPORT DLLEXPORT
void allowRotation(bool _mode); void allowRotation(bool _mode, int _viewer = ACTIVE_VIEWER);
/** is scene rotation locked
*
* @param _viewer Id of the viewer to use.
* ALL_VIEWERS will set all viewers (Default)
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
bool allowRotation(int _viewer = ACTIVE_VIEWER);
/** \brief Set current GL Context to main context /** \brief Set current GL Context to main context
*/ */
...@@ -203,6 +225,15 @@ void viewAll(int _viewer = ALL_VIEWERS); ...@@ -203,6 +225,15 @@ void viewAll(int _viewer = ALL_VIEWERS);
DLLEXPORT DLLEXPORT
ACG::Vec3d viewingDirection(int _viewer = ALL_VIEWERS); ACG::Vec3d viewingDirection(int _viewer = ALL_VIEWERS);
/** \brief Check if the projection is orthographic
* @param _viewer Id of the viewer to use.
* ALL_VIEWERS will set all viewers (Default)
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
bool isProjectionOrthographic( int _viewer = ACTIVE_VIEWER );
/** \brief Get the current viewer position /** \brief Get the current viewer position
* *
* @param _viewer Id of the viewer to use. * @param _viewer Id of the viewer to use.
...@@ -268,6 +299,18 @@ unsigned int drawMode( int _viewer = ACTIVE_VIEWER ); ...@@ -268,6 +299,18 @@ unsigned int drawMode( int _viewer = ACTIVE_VIEWER );
DLLEXPORT DLLEXPORT
void setBackColor( OpenMesh::Vec4f _color); void setBackColor( OpenMesh::Vec4f _color);
/** \brief Set a fixed View for a viewer
*
*
* @param _mode id for the mode
* @param _viewer Id of the viewer to use.
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
void setFixedView(int _mode, int _viewer = ACTIVE_VIEWER );
/** @} */ /** @} */
......
...@@ -236,11 +236,22 @@ void Core::readApplicationOptions(INIFile& _ini) { ...@@ -236,11 +236,22 @@ void Core::readApplicationOptions(INIFile& _ini) {
OpenFlipper::Options::defaultToolboxMode(toolboxMode); OpenFlipper::Options::defaultToolboxMode(toolboxMode);
//============================================================================ //============================================================================
// Load the drawmodes // Load the viewer settings
//============================================================================ //============================================================================
std::vector< QString > draw_modes; std::vector< QString > draw_modes;
if( _ini.get_entry(draw_modes, "Options", "StandardDrawModes") ) int mode;
OpenFlipper::Options::standardDrawMode( ListToDrawMode(draw_modes) );
for (int i=0; i < 4/*PluginFunctions::viewers()*/; i++ ){
if( _ini.get_entry(draw_modes, "Options", "DefaultDrawModes" + QString::number(i) ) )
OpenFlipper::Options::defaultDrawMode( ListToDrawMode(draw_modes), i );
if( _ini.get_entry(mode, "Options", "DefaultProjectionMode" + QString::number(i) ) )
OpenFlipper::Options::defaultProjectionMode( mode, i );
if( _ini.get_entry(mode, "Options", "DefaultViewingDirection" + QString::number(i) ) )
OpenFlipper::Options::defaultViewingDirection( mode, i );
}
//============================================================================ //============================================================================
// Load logFile status // Load logFile status
...@@ -547,11 +558,20 @@ void Core::writeApplicationOptions(INIFile& _ini) { ...@@ -547,11 +558,20 @@ void Core::writeApplicationOptions(INIFile& _ini) {
(uint)PluginFunctions::viewerProperties(i).backgroundColorRgb() ); (uint)PluginFunctions::viewerProperties(i).backgroundColorRgb() );
} }
//============================================================================ //============================================================================
// Save the current draw modes // Save the current viewer properties
//============================================================================ //============================================================================
std::vector< QString > draw_modes; std::vector< QString > draw_modes;
draw_modes = drawModeToList( OpenFlipper::Options::standardDrawMode() ); int mode;
_ini.add_entry("Options","StandardDrawModes",draw_modes);
for (int i=0; i < PluginFunctions::viewers(); i++ ){
draw_modes = drawModeToList( OpenFlipper::Options::defaultDrawMode(i) );
_ini.add_entry("Options","DefaultDrawModes" + QString::number(i), draw_modes);
_ini.add_entry("Options","DefaultProjectionMode" + QString::number(i), OpenFlipper::Options::defaultProjectionMode(i) );
_ini.add_entry("Options","DefaultViewingDirection" + QString::number(i), OpenFlipper::Options::defaultViewingDirection(i) );
}
_ini.add_entry("Options","LoggerState", OpenFlipper::Options::loggerState() ); _ini.add_entry("Options","LoggerState", OpenFlipper::Options::loggerState() );
_ini.add_entry("Options","HideToolbox", OpenFlipper::Options::hideToolbox() ); _ini.add_entry("Options","HideToolbox", OpenFlipper::Options::hideToolbox() );
...@@ -679,7 +699,7 @@ void Core::openIniFile( QString _filename, ...@@ -679,7 +699,7 @@ void Core::openIniFile( QString _filename,
if ( OpenFlipper::Options::gui() ){ if ( OpenFlipper::Options::gui() ){
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
PluginFunctions::viewerProperties(i).drawMode( OpenFlipper::Options::standardDrawMode() ); PluginFunctions::viewerProperties(i).drawMode( OpenFlipper::Options::defaultDrawMode(i) );
coreWidget_->examiner_widgets_[i]->viewAll(); coreWidget_->examiner_widgets_[i]->viewAll();
} }
......
...@@ -318,12 +318,20 @@ void Core::slotObjectOpened ( int _id ) { ...@@ -318,12 +318,20 @@ void Core::slotObjectOpened ( int _id ) {
object->setBaseColor( colorV ); object->setBaseColor( colorV );
// ================================================================================ // ================================================================================
// Set standard draw mode if this is the first opened object // Set defaults for DrawMode, ViewingDirection and Projection if this is the first opened object
// If a plugin changes the drawmode later, this setting will be overridden! // If a plugin changes the drawmode later, this setting will be overridden!
// ================================================================================ // ================================================================================
if ( PluginFunctions::objectCount() == 1 && OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() ) if ( PluginFunctions::objectCount() == 1 && OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() )
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ){
PluginFunctions::viewerProperties(i).drawMode( OpenFlipper::Options::standardDrawMode() ); PluginFunctions::viewerProperties(i).drawMode( OpenFlipper::Options::defaultDrawMode(i) );
if ( OpenFlipper::Options::defaultProjectionMode(i) == 0 )
PluginFunctions::orthographicProjection(i);
else
PluginFunctions::perspectiveProjection(i);
PluginFunctions::setFixedView(OpenFlipper::Options::defaultViewingDirection(i), i );
}
// ================================================================================ // ================================================================================
// Recompute bounding box and scenegraph info // Recompute bounding box and scenegraph info
......
...@@ -89,6 +89,18 @@ void Core::applyOptions(){ ...@@ -89,6 +89,18 @@ void Core::applyOptions(){
target = ACG::SceneGraph::PICK_ANYTHING; target = ACG::SceneGraph::PICK_ANYTHING;
} }
//set viewer properties
for (int i=0; i < PluginFunctions::viewers(); i++){
PluginFunctions::setDrawMode( OpenFlipper::Options::defaultDrawMode(i), i );
PluginFunctions::setFixedView(OpenFlipper::Options::defaultViewingDirection(i), i );
if ( OpenFlipper::Options::defaultProjectionMode(i) == 0 )
PluginFunctions::orthographicProjection(i);
else
PluginFunctions::perspectiveProjection(i);
}
//set defaultBackgroundColor //set defaultBackgroundColor
QColor c = OpenFlipper::Options::defaultBackgroundColor() ; QColor c = OpenFlipper::Options::defaultBackgroundColor() ;
......
...@@ -119,8 +119,8 @@ static float eyeDistance_ = 0.07f; ...@@ -119,8 +119,8 @@ static float eyeDistance_ = 0.07f;
static float focalDistance_ = 0.5; static float focalDistance_ = 0.5;
/// vectroy containing left/right color matrices for custom anaglyph mode /// vectroy containing left/right color matrices for custom anaglyph mode
std::vector<float> anaglyphLeftEyeColors_ = std::vector<float> (9, 0.0); static std::vector<float> anaglyphLeftEyeColors_ = std::vector<float> (9, 0.0);
std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0); static std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0);
/// Store the synchronization mode /// Store the synchronization mode
static bool synchronization_ = false; static bool synchronization_ = false;
...@@ -140,8 +140,14 @@ static bool showWheelsAtStartup_ = false; ...@@ -140,8 +140,14 @@ static bool showWheelsAtStartup_ = false;
/// Store the maxFrameRate_ mode /// Store the maxFrameRate_ mode
static int maxFrameRate_ = 35; static int maxFrameRate_ = 35;
/// Store the standardDrawMode_ mode /// Store the defaultDrawMode_ mode
static uint standardDrawMode_ = ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED; static std::vector<uint> defaultDrawMode_ = std::vector<uint> (4, ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED);
/// Store the defaultProjectionMode_ mode
static std::vector<int> defaultProjectionMode_ = std::vector<int> (4, 0);
/// Store the defaultViewingDirection_ mode
static std::vector<int> defaultViewingDirection_ = std::vector<int> (4, 0);
/// Store the disableRedraw_ mode /// Store the disableRedraw_ mode
static int redrawDisabled_ = 0; static int redrawDisabled_ = 0;
...@@ -629,12 +635,28 @@ int maxFrameRate(){ ...@@ -629,12 +635,28 @@ int maxFrameRate(){
return maxFrameRate_; return maxFrameRate_;
} }
void standardDrawMode( uint _mode ){ void defaultDrawMode( uint _mode, int _viewer){
standardDrawMode_ = _mode; defaultDrawMode_[_viewer] = _mode;
}
uint defaultDrawMode(int _viewer){
return defaultDrawMode_[_viewer];
}
void defaultProjectionMode( int _mode, int _viewer){
defaultProjectionMode_[_viewer] = _mode;
}
int defaultProjectionMode(int _viewer){
return defaultProjectionMode_[_viewer];
}
void defaultViewingDirection( int _mode, int _viewer){
defaultViewingDirection_[_viewer] = _mode;
} }
uint standardDrawMode(){ int defaultViewingDirection(int _viewer){
return standardDrawMode_; return defaultViewingDirection_[_viewer];
} }
void redrawDisabled( bool disable ){ void redrawDisabled( bool disable ){
......
...@@ -500,13 +500,29 @@ bool dataDir(QString _dir); ...@@ -500,13 +500,29 @@ bool dataDir(QString _dir);
DLLEXPORT DLLEXPORT
int maxFrameRate( ); int maxFrameRate( );
/// Store standardDrawMode setting /// Store defaultDrawMode setting
DLLEXPORT DLLEXPORT
void standardDrawMode( uint _mode ); void defaultDrawMode( uint _mode, int _viewer );
/// get standardDrawMode setting /// get defaultDrawMode setting
DLLEXPORT DLLEXPORT
uint standardDrawMode( ); uint defaultDrawMode( int _viewer );
/// Store defaultProjectionMode setting
DLLEXPORT
void defaultProjectionMode( int _mode, int _viewer );
/// get defaultProjectionMode setting
DLLEXPORT
int defaultProjectionMode( int _viewer );
/// Store defaultViewingDirection setting
DLLEXPORT
void defaultViewingDirection( int _mode, int _viewer );
/// get defaultViewingDirection setting
DLLEXPORT
int defaultViewingDirection( int _viewer );
/// Store disableRedraw setting /// Store disableRedraw setting
DLLEXPORT DLLEXPORT
......
...@@ -99,5 +99,13 @@ namespace Viewer { ...@@ -99,5 +99,13 @@ namespace Viewer {
emit setActionMode(_am); emit setActionMode(_am);
} }
int ViewerProperties::currentViewingDirection(){
return currentViewingDirection_;
}
void ViewerProperties::currentViewingDirection(int _dir){
currentViewingDirection_ = _dir;
}
} }
...@@ -352,6 +352,15 @@ namespace Viewer { ...@@ -352,6 +352,15 @@ namespace Viewer {
private: private:
ViewObjectMarker *objectMarker_; ViewObjectMarker *objectMarker_;
//===========================================================================
public:
int currentViewingDirection();
void currentViewingDirection(int _dir);
private:
int currentViewingDirection_;
//=========================================================================== //===========================================================================
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@