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;
/** \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!!
......
......@@ -164,7 +164,7 @@ Core() :
std::vector< Viewer::ViewerProperties* > viewerProperties;
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");
viewerProperties.push_back( viewerProperty );
}
......
......@@ -277,32 +277,24 @@ void Core::readApplicationOptions(INIFile& _ini) {
if( _ini.get_entry(viewerCount, "Options", "ViewerCount") ){
}
if ( _ini.section_exists("ViewerProperties") ){
for ( unsigned int i = 0 ; i < viewerCount; ++i ) {
if (OpenFlipper::Options::examinerWidgets() < i)
break;
// Load the animation setting
bool animation = false;
if ( _ini.get_entry( animation, "ViewerProperties" , "Animation" + QString::number(i) ) )
PluginFunctions::viewerProperties(i).animation(animation);
// Load the twoSidedLighting setting
bool twoSidedLighting = false;
if ( _ini.get_entry( twoSidedLighting, "ViewerProperties" , "TwoSidedLighting" + QString::number(i)) )
PluginFunctions::viewerProperties(i).twoSidedLighting(twoSidedLighting);
// Load the backface culling setting
bool backface_culling = false;
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) );
}
for ( unsigned int i = 0 ; i < viewerCount; ++i ) {
if (OpenFlipper::Options::examinerWidgets() < i)
break;
QString entryHeader = "Viewer" + QString::number(i) + "/";
// Load the animation setting
PluginFunctions::viewerProperties(i).animation(OpenFlipperSettings().value(entryHeader+"Animation",false).toBool());
// Load the twoSidedLighting setting
PluginFunctions::viewerProperties(i).twoSidedLighting(OpenFlipperSettings().value(entryHeader+"TwoSidedLighting",false).toBool());
// Load the backface culling setting
PluginFunctions::viewerProperties(i).backFaceCulling(OpenFlipperSettings().value(entryHeader+"BackfaceCulling",false).toBool());
// Load the setting for the background color option
PluginFunctions::viewerProperties(i).backgroundColor(OpenFlipperSettings().value(entryHeader+"BackgroundColor",QColor(0,0,0)).value< QColor >());
}
//============================================================================
......@@ -444,13 +436,13 @@ void Core::writeApplicationOptions(INIFile& _ini) {
_ini.add_section("ViewerProperties");
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
_ini.add_entry("ViewerProperties","Animation" + QString::number(i), PluginFunctions::viewerProperties(i).animation());
_ini.add_entry("ViewerProperties","BackfaceCulling" + QString::number(i), PluginFunctions::viewerProperties(i).backFaceCulling());
_ini.add_entry("ViewerProperties","TwoSidedLighting" + QString::number(i),PluginFunctions::viewerProperties(i).twoSidedLighting());
_ini.add_entry("ViewerProperties","BackgroundColor" + QString::number(i),
(uint)PluginFunctions::viewerProperties(i).backgroundColorRgb() );
QString entryHead = "Viewer" + QString::number(i) + "/";
OpenFlipperSettings().setValue(entryHead + "Animation", PluginFunctions::viewerProperties(i).animation());
OpenFlipperSettings().setValue(entryHead + "BackfaceCulling", PluginFunctions::viewerProperties(i).backFaceCulling());
OpenFlipperSettings().setValue(entryHead + "TwoSidedLighting", PluginFunctions::viewerProperties(i).twoSidedLighting());
OpenFlipperSettings().setValue(entryHead + "BackgroundColor", PluginFunctions::viewerProperties(i).backgroundQColor());
}
//============================================================================
// Save the current viewer properties
//============================================================================
......
......@@ -536,13 +536,13 @@ int defaultViewingDirection(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);
}
bool defaultLockRotation( int _viewer ) {
QString entry = "Viewer" + QString::number(_viewer) + "/lockRotation";
QString entry = "Viewer" + QString::number(_viewer) + "/defaultLockRotation";
switch (_viewer) {
case 0:
......
......@@ -106,8 +106,11 @@
* <b>User Interface Settings for each of the viewers</b>\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>/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
* * Core/CurrentDir The current Directory of the Application \n
......
......@@ -56,7 +56,7 @@
namespace Viewer {
ViewerProperties::ViewerProperties():
ViewerProperties::ViewerProperties(int _id):
currentDrawMode_(ACG::SceneGraph::DrawModes::NONE),
snapshotName_("snap"),
snapshotFileType_("png"),
......@@ -85,7 +85,7 @@ namespace Viewer {
trackballCenter_(ACG::Vec3d( 0.0, 0.0, 0.0 )),
trackballRadius_(1.0)
{
settingsSection_ = "Viewer" + QString::number(_id) + "/";
}
ViewerProperties::~ViewerProperties() {
......@@ -141,5 +141,14 @@ namespace Viewer {
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 {
Q_OBJECT
public:
ViewerProperties();
ViewerProperties(int _id);
~ViewerProperties();
//===========================================================================
......@@ -245,6 +245,14 @@ namespace Viewer {
c.setAlphaF(backgroundColor_[3]);
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.
*/
void backgroundColor( ACG::Vec4f _color ) { backgroundColor_ = _color; emit updated(); };
......@@ -258,6 +266,14 @@ namespace Viewer {
backgroundColor_[3] = c.alphaF();
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:
ACG::Vec4f backgroundColor_;
......@@ -549,6 +565,29 @@ namespace Viewer {
/// set active action mode
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 @@
SimpleViewer::SimpleViewer(QWidget* _parent) :
QGraphicsView (_parent),
props_(-1),
actionMode_ (Viewer::ExamineMode)
{
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