Commit cfeefffa authored by Jan Möbius's avatar Jan Möbius

Make ViewerProperties aware of the viewer id it belongs to

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11411 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6f335be5
...@@ -107,7 +107,7 @@ static SeparatorNode* sceneGraphRootNode_ = 0; ...@@ -107,7 +107,7 @@ static SeparatorNode* sceneGraphRootNode_ = 0;
/** \brief a dummy properties object returned as a reference if the real object does not exist /** \brief a dummy properties object returned as a reference if the real object does not exist
* *
*/ */
static Viewer::ViewerProperties dummyProperties; static Viewer::ViewerProperties dummyProperties(-1);
/** \brief DONT USE DIRECTLY!! /** \brief DONT USE DIRECTLY!!
......
...@@ -164,7 +164,7 @@ Core() : ...@@ -164,7 +164,7 @@ Core() :
std::vector< Viewer::ViewerProperties* > viewerProperties; std::vector< Viewer::ViewerProperties* > viewerProperties;
for (int i=0; i < 4; i++) { for (int i=0; i < 4; i++) {
Viewer::ViewerProperties* viewerProperty = new Viewer::ViewerProperties(); Viewer::ViewerProperties* viewerProperty = new Viewer::ViewerProperties(i);
viewerProperty->snapshotBaseFileName("snap-Viewer-" + QString::number(i) + ".png"); viewerProperty->snapshotBaseFileName("snap-Viewer-" + QString::number(i) + ".png");
viewerProperties.push_back( viewerProperty ); viewerProperties.push_back( viewerProperty );
} }
......
...@@ -277,32 +277,24 @@ void Core::readApplicationOptions(INIFile& _ini) { ...@@ -277,32 +277,24 @@ void Core::readApplicationOptions(INIFile& _ini) {
if( _ini.get_entry(viewerCount, "Options", "ViewerCount") ){ if( _ini.get_entry(viewerCount, "Options", "ViewerCount") ){
} }
if ( _ini.section_exists("ViewerProperties") ){ for ( unsigned int i = 0 ; i < viewerCount; ++i ) {
for ( unsigned int i = 0 ; i < viewerCount; ++i ) {
if (OpenFlipper::Options::examinerWidgets() < i)
if (OpenFlipper::Options::examinerWidgets() < i) break;
break;
QString entryHeader = "Viewer" + QString::number(i) + "/";
// Load the animation setting
bool animation = false; // Load the animation setting
if ( _ini.get_entry( animation, "ViewerProperties" , "Animation" + QString::number(i) ) ) PluginFunctions::viewerProperties(i).animation(OpenFlipperSettings().value(entryHeader+"Animation",false).toBool());
PluginFunctions::viewerProperties(i).animation(animation);
// Load the twoSidedLighting setting
// Load the twoSidedLighting setting PluginFunctions::viewerProperties(i).twoSidedLighting(OpenFlipperSettings().value(entryHeader+"TwoSidedLighting",false).toBool());
bool twoSidedLighting = false;
if ( _ini.get_entry( twoSidedLighting, "ViewerProperties" , "TwoSidedLighting" + QString::number(i)) ) // Load the backface culling setting
PluginFunctions::viewerProperties(i).twoSidedLighting(twoSidedLighting); PluginFunctions::viewerProperties(i).backFaceCulling(OpenFlipperSettings().value(entryHeader+"BackfaceCulling",false).toBool());
// Load the backface culling setting // Load the setting for the background color option
bool backface_culling = false; PluginFunctions::viewerProperties(i).backgroundColor(OpenFlipperSettings().value(entryHeader+"BackgroundColor",QColor(0,0,0)).value< QColor >());
if ( _ini.get_entry( backface_culling, "ViewerProperties" , "BackfaceCulling" + QString::number(i)) )
PluginFunctions::viewerProperties(i).backFaceCulling(backface_culling);
// Load the setting for the background color option
uint viewerBackground = 0;
if ( _ini.get_entry( viewerBackground, "ViewerProperties" , "BackgroundColor" + QString::number(i)) )
PluginFunctions::viewerProperties(i).backgroundColor( QRgb(viewerBackground) );
}
} }
//============================================================================ //============================================================================
...@@ -444,13 +436,13 @@ void Core::writeApplicationOptions(INIFile& _ini) { ...@@ -444,13 +436,13 @@ void Core::writeApplicationOptions(INIFile& _ini) {
_ini.add_section("ViewerProperties"); _ini.add_section("ViewerProperties");
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) { for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
QString entryHead = "Viewer" + QString::number(i) + "/";
_ini.add_entry("ViewerProperties","Animation" + QString::number(i), PluginFunctions::viewerProperties(i).animation()); OpenFlipperSettings().setValue(entryHead + "Animation", PluginFunctions::viewerProperties(i).animation());
_ini.add_entry("ViewerProperties","BackfaceCulling" + QString::number(i), PluginFunctions::viewerProperties(i).backFaceCulling()); OpenFlipperSettings().setValue(entryHead + "BackfaceCulling", PluginFunctions::viewerProperties(i).backFaceCulling());
_ini.add_entry("ViewerProperties","TwoSidedLighting" + QString::number(i),PluginFunctions::viewerProperties(i).twoSidedLighting()); OpenFlipperSettings().setValue(entryHead + "TwoSidedLighting", PluginFunctions::viewerProperties(i).twoSidedLighting());
_ini.add_entry("ViewerProperties","BackgroundColor" + QString::number(i), OpenFlipperSettings().setValue(entryHead + "BackgroundColor", PluginFunctions::viewerProperties(i).backgroundQColor());
(uint)PluginFunctions::viewerProperties(i).backgroundColorRgb() );
} }
//============================================================================ //============================================================================
// Save the current viewer properties // Save the current viewer properties
//============================================================================ //============================================================================
......
...@@ -536,13 +536,13 @@ int defaultViewingDirection(int _viewer){ ...@@ -536,13 +536,13 @@ int defaultViewingDirection(int _viewer){
} }
void defaultLockRotation( bool _lock, int _viewer ) { void defaultLockRotation( bool _lock, int _viewer ) {
QString entry = "Viewer" + QString::number(_viewer) + "/lockRotation"; QString entry = "Viewer" + QString::number(_viewer) + "/defaultLockRotation";
OpenFlipperSettings().setValue(entry,_lock); OpenFlipperSettings().setValue(entry,_lock);
} }
bool defaultLockRotation( int _viewer ) { bool defaultLockRotation( int _viewer ) {
QString entry = "Viewer" + QString::number(_viewer) + "/lockRotation"; QString entry = "Viewer" + QString::number(_viewer) + "/defaultLockRotation";
switch (_viewer) { switch (_viewer) {
case 0: case 0:
......
...@@ -106,8 +106,11 @@ ...@@ -106,8 +106,11 @@
* <b>User Interface Settings for each of the viewers</b>\n * <b>User Interface Settings for each of the viewers</b>\n
* * Viewer<viewer>/perspectiveProjection Orthogonal = false,Perspective = true (bool)\n * * Viewer<viewer>/perspectiveProjection Orthogonal = false,Perspective = true (bool)\n
* * Viewer<viewer>/defaultViewingDirection 0:VIEW_FREE; 1:VIEW_TOP; 2:VIEW_BOTTOM; 3:VIEW_LEFT; 4:VIEW_RIGHT; 5:VIEW_FRONT; 6:VIEW_BACK (int)\n * * Viewer<viewer>/defaultViewingDirection 0:VIEW_FREE; 1:VIEW_TOP; 2:VIEW_BOTTOM; 3:VIEW_LEFT; 4:VIEW_RIGHT; 5:VIEW_FRONT; 6:VIEW_BACK (int)\n
* * Viewer<viewer>/lockRotation true: locked, false: unlocked (bool)\n * * Viewer<viewer>/defaultLockRotation true: locked , false: unlocked (bool)\n
* * * Viewer<viewer>/Animation true: enabled, false: disabled (bool)\n
* * Viewer<viewer>/BackfaceCulling true: enabled, false: disabled (bool)\n
* * Viewer<viewer>/TwoSidedLighting true: enabled, false: disabled (bool)\n
* * Viewer<viewer>/BackgroundColor Color of the viewer background (QColor)\n
* *
* <b>File Handling</b>\n * <b>File Handling</b>\n
* * Core/CurrentDir The current Directory of the Application \n * * Core/CurrentDir The current Directory of the Application \n
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
namespace Viewer { namespace Viewer {
ViewerProperties::ViewerProperties(): ViewerProperties::ViewerProperties(int _id):
currentDrawMode_(ACG::SceneGraph::DrawModes::NONE), currentDrawMode_(ACG::SceneGraph::DrawModes::NONE),
snapshotName_("snap"), snapshotName_("snap"),
snapshotFileType_("png"), snapshotFileType_("png"),
...@@ -85,7 +85,7 @@ namespace Viewer { ...@@ -85,7 +85,7 @@ namespace Viewer {
trackballCenter_(ACG::Vec3d( 0.0, 0.0, 0.0 )), trackballCenter_(ACG::Vec3d( 0.0, 0.0, 0.0 )),
trackballRadius_(1.0) trackballRadius_(1.0)
{ {
settingsSection_ = "Viewer" + QString::number(_id) + "/";
} }
ViewerProperties::~ViewerProperties() { ViewerProperties::~ViewerProperties() {
...@@ -141,5 +141,14 @@ namespace Viewer { ...@@ -141,5 +141,14 @@ namespace Viewer {
rotationLocked_ = _locked; rotationLocked_ = _locked;
} }
int ViewerProperties::viewerId() {
return viewerId_;
};
void ViewerProperties::viewerId(int _id) {
viewerId_ = _id;
settingsSection_ = "Viewer" + QString::number(_id) + "/";
};
} }
...@@ -113,7 +113,7 @@ namespace Viewer { ...@@ -113,7 +113,7 @@ namespace Viewer {
Q_OBJECT Q_OBJECT
public: public:
ViewerProperties(); ViewerProperties(int _id);
~ViewerProperties(); ~ViewerProperties();
//=========================================================================== //===========================================================================
...@@ -245,6 +245,14 @@ namespace Viewer { ...@@ -245,6 +245,14 @@ namespace Viewer {
c.setAlphaF(backgroundColor_[3]); c.setAlphaF(backgroundColor_[3]);
return c.rgba(); }; return c.rgba(); };
/// Get current background color
QColor backgroundQColor(){ QColor c;
c.setRedF( backgroundColor_[0]);
c.setGreenF(backgroundColor_[1]);
c.setBlueF( backgroundColor_[2]);
c.setAlphaF(backgroundColor_[3]);
return c; }
/** Set background color. /** Set background color.
*/ */
void backgroundColor( ACG::Vec4f _color ) { backgroundColor_ = _color; emit updated(); }; void backgroundColor( ACG::Vec4f _color ) { backgroundColor_ = _color; emit updated(); };
...@@ -258,6 +266,14 @@ namespace Viewer { ...@@ -258,6 +266,14 @@ namespace Viewer {
backgroundColor_[3] = c.alphaF(); backgroundColor_[3] = c.alphaF();
emit updated(); }; emit updated(); };
/** Set background color.
*/
void backgroundColor( QColor _color ) { backgroundColor_[0] = _color.redF();
backgroundColor_[1] = _color.greenF();
backgroundColor_[2] = _color.blueF();
backgroundColor_[3] = _color.alphaF();
emit updated(); };
private: private:
ACG::Vec4f backgroundColor_; ACG::Vec4f backgroundColor_;
...@@ -549,6 +565,29 @@ namespace Viewer { ...@@ -549,6 +565,29 @@ namespace Viewer {
/// set active action mode /// set active action mode
void actionMode(const Viewer::ActionMode _am); void actionMode(const Viewer::ActionMode _am);
//===========================================================================
//===========================================================================
/** @name Viewer id handling
* @{ */
//===========================================================================
//===========================================================================
/// Get the id of the viewer this viewerproperties belongs to
int viewerId();
/// Set the id of the viewer this viewerproperties belongs to
void viewerId(int _id);
private:
/// Stores the id of the viewer this property belongs to
int viewerId_;
/// String for the Settings storage
QString settingsSection_;
/** @} */
}; };
} }
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
SimpleViewer::SimpleViewer(QWidget* _parent) : SimpleViewer::SimpleViewer(QWidget* _parent) :
QGraphicsView (_parent), QGraphicsView (_parent),
props_(-1),
actionMode_ (Viewer::ExamineMode) actionMode_ (Viewer::ExamineMode)
{ {
QGLWidget *share = PluginFunctions::shareGLWidget (); QGLWidget *share = PluginFunctions::shareGLWidget ();
......
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