Commit efab96c0 authored by Dirk Wilden's avatar Dirk Wilden

improved ini loading

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4819 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c788286a
......@@ -57,6 +57,12 @@ static BaseObject* objectRoot_;
*/
static std::vector< glViewer* > examiner_widgets_;
/** \brief DONT USE DIRECTLY!!
*
* This vector is used internally to access properties of all viewers
*/
static std::vector< Viewer::ViewerProperties* > viewerProperties_;
/// TODO : Remove this variable and implement multiView correctly here
static glViewer* examiner_widget_;
......@@ -81,6 +87,10 @@ void setViewers( std::vector< glViewer* > _examiner_widgets ) {
PluginFunctions::examiner_widget_ = examiner_widgets_[0];
}
void setViewerProperties( std::vector< Viewer::ViewerProperties* > _viewerProperties ) {
PluginFunctions::viewerProperties_ = _viewerProperties;
}
void setActiveExaminer( const unsigned int _id ) {
activeExaminer_ = _id;
}
......@@ -361,7 +371,7 @@ Viewer::ActionMode actionMode() {
}
Viewer::ViewerProperties& viewerProperties(int _id) {
if ( _id >= (int)examiner_widgets_.size() ) {
if ( _id >= (int)viewerProperties_.size() ) {
std::cerr << " Error, requested properties for non-existing Viewer!" << std::endl;
return dummyProperties;
}
......@@ -369,7 +379,7 @@ Viewer::ViewerProperties& viewerProperties(int _id) {
if ( _id == -1 )
_id = activeExaminer_;
return (*examiner_widgets_[_id]->properties());
return ( *viewerProperties_[_id] );
}
......
......@@ -51,6 +51,7 @@
#include <OpenFlipper/common/GlobalDefines.hh>
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <OpenFlipper/common/ViewerProperties.hh>
namespace PluginFunctions {
......@@ -63,6 +64,10 @@ namespace PluginFunctions {
DLLEXPORT
void setViewers( std::vector< glViewer* > _examiner_widgets );
/// Set the internal viewerProperties pointer ( DO NOT USE!! )
DLLEXPORT
void setViewerProperties( std::vector< Viewer::ViewerProperties* > _viewerProperties );
/// Set the internal scenegraph root node pointer ( DO NOT USE!! )
DLLEXPORT
void setSceneGraphRootNode( SeparatorNode* _root_node );
......
......@@ -123,6 +123,14 @@ Core() :
viewModes_.push_front(vm);
//init ViewerProperties (always for 4 Viewers!)
std::vector< Viewer::ViewerProperties* > viewerProperties;
for (int i=0; i < 4; i++)
viewerProperties.push_back( new Viewer::ViewerProperties() );
PluginFunctions::setViewerProperties(viewerProperties);
// Get all relevant Paths and Options from option files
setupOptions();
......
......@@ -270,33 +270,6 @@ void Core::readApplicationOptions(INIFile& _ini) {
if( _ini.get_entry(renderPicking, "Options", "PickingRenderMode") )
OpenFlipper::Options::pickingRenderMode(pickingRenderMode);
//============================================================================
// Update information
//============================================================================
QString updateUrl = "";
if( _ini.get_entry(updateUrl, "Options", "UpdateURL") )
OpenFlipper::Options::updateUrl(updateUrl);
QString updateUsername = "";
if( _ini.get_entry(updateUsername, "Options", "UpdateUsername") )
OpenFlipper::Options::updateUsername(updateUsername);
QString updatePassword = "";
if( _ini.get_entry(updatePassword, "Options", "UpdatePassword") )
OpenFlipper::Options::updatePassword(updatePassword);
}
}
/// Read Options that needs the GUI to be set up completely
void Core::readGUIOptions(INIFile& _ini) {
if ( !OpenFlipper::Options::gui() )
return;
uint viewerCount = 0;
if ( _ini.section_exists("Options") ) {
//============================================================================
// ViewerProperties
//============================================================================
......@@ -305,36 +278,52 @@ void Core::readGUIOptions(INIFile& _ini) {
if( _ini.get_entry(multiView, "Options", "MultiView") )
OpenFlipper::Options::multiView(multiView);
uint viewerCount = 0;
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);
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) );
}
}
// Load the twoSidedLighting setting
bool twoSidedLighting = false;
if ( _ini.get_entry( twoSidedLighting, "ViewerProperties" , "TwoSidedLighting" + QString::number(i)) )
PluginFunctions::viewerProperties(i).twoSidedLighting(twoSidedLighting);
//============================================================================
// Update information
//============================================================================
QString updateUrl = "";
if( _ini.get_entry(updateUrl, "Options", "UpdateURL") )
OpenFlipper::Options::updateUrl(updateUrl);
// 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);
QString updateUsername = "";
if( _ini.get_entry(updateUsername, "Options", "UpdateUsername") )
OpenFlipper::Options::updateUsername(updateUsername);
// 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) );
}
QString updatePassword = "";
if( _ini.get_entry(updatePassword, "Options", "UpdatePassword") )
OpenFlipper::Options::updatePassword(updatePassword);
}
}
......@@ -516,8 +505,6 @@ void Core::openIniFile( QString _filename,
if ( _coreSettings )
readApplicationOptions(ini);
readGUIOptions(ini);
// if requested load per Plugin settings from the settings file
if ( _perPluginSettings )
emit iniLoadOptions( ini );
......
Doxygen/pics/startupProcess.jpg

49.6 KB | W: | H:

Doxygen/pics/startupProcess.jpg

46.2 KB | W: | H:

Doxygen/pics/startupProcess.jpg
Doxygen/pics/startupProcess.jpg
Doxygen/pics/startupProcess.jpg
Doxygen/pics/startupProcess.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -207,27 +207,10 @@ void segfaultHandling (int) {
std::abort();
}
int main(int argc, char **argv)
{
OpenFlipper::Options::argc(&argc);
OpenFlipper::Options::argv(&argv);
// Only Install signal handler if not running in debug version, otherwise gdb will get confused
// #ifndef DEBUG
// Set a handler for segfaults
std::signal(SIGSEGV, segfaultHandling);
// #endif
OpenFlipper::Options::windowTitle("OpenFlipper v" + OpenFlipper::Options::coreVersion());
bool openPolyMeshes = false;
bool remoteControl = false;
//======================================================
// Parse command line Options
//======================================================
bool openPolyMeshes = false;
bool remoteControl = false;
CSimpleOpt args(argc, argv, g_rgOptions);
bool parseCommandLineOptions(CSimpleOpt& args){
// while there are arguments left to process
while (args.Next()) {
......@@ -270,9 +253,26 @@ int main(int argc, char **argv)
} else {
std::cerr << "Invalid argument: " << args.OptionText() << std::endl;
showHelp();
return 1;
return false;
}
}
return true;
}
int main(int argc, char **argv)
{
OpenFlipper::Options::argc(&argc);
OpenFlipper::Options::argv(&argv);
CSimpleOpt args(argc, argv, g_rgOptions);
// Only Install signal handler if not running in debug version, otherwise gdb will get confused
// #ifndef DEBUG
// Set a handler for segfaults
std::signal(SIGSEGV, segfaultHandling);
// #endif
OpenFlipper::Options::windowTitle("OpenFlipper v" + OpenFlipper::Options::coreVersion());
if ( !OpenFlipper::Options::nogui() ) {
......@@ -290,6 +290,9 @@ int main(int argc, char **argv)
// create core ( this also reads the ini files )
Core * w = new Core( );
if ( !parseCommandLineOptions(args) )
return 1;
// After setting all Options from command line, build the real gui
w->init();
......@@ -312,6 +315,9 @@ int main(int argc, char **argv)
// create widget ( this also reads the ini files )
Core * w = new Core( );
if ( !parseCommandLineOptions(args) )
return 1;
// After setting all Options from command line, build the real gui
w->init();
......
......@@ -305,7 +305,7 @@ namespace Viewer {
public slots:
/// set 2-sided lighting on/off
void twoSidedLighting(bool _state ) { twoSidedLighting_ = _state; glState_->set_twosided_lighting( _state ); emit updated(); }
void twoSidedLighting(bool _state ) { twoSidedLighting_ = _state; emit updated(); }
/// is 2-sided lighing enabled?
bool twoSidedLighting() { return twoSidedLighting_; };
......
......@@ -164,6 +164,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
glViewer* examinerWidget = new glViewer(glScene_,
glWidget_,
PluginFunctions::viewerProperties(0),
centerWidget_,
"Examiner Widget",
statusBar_);
......@@ -181,9 +182,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
glViewer* newWidget = new glViewer(glScene_,
glWidget_,
PluginFunctions::viewerProperties(i),
centerWidget_,
"Examiner Widget",
statusBar_ );
statusBar_);
examiner_widgets_.push_back(newWidget);
}
......
......@@ -115,6 +115,7 @@ static const char VIEW_MAGIC[] =
glViewer::glViewer( QtGLGraphicsScene* _scene,
QGLWidget* _glWidget,
Viewer::ViewerProperties& _properties,
QGraphicsWidget* _parent,
const char* /* _name */ ,
QStatusBar *_statusBar) :
......@@ -127,6 +128,7 @@ glViewer::glViewer( QtGLGraphicsScene* _scene,
glWidget_(_glWidget),
pick_mode_name_(""),
pick_mode_idx_(-1),
properties_(_properties),
glstate_(0)
{
......@@ -191,6 +193,9 @@ glViewer::glViewer( QtGLGraphicsScene* _scene,
properties_.setExamineMode();
//check for updated properties once
slotPropertiesUpdated();
setAcceptDrops(true);
}
......@@ -1991,6 +1996,9 @@ void glViewer::slotAnimation()
}
void glViewer::applyProperties() {
glstate_->set_twosided_lighting( properties_.twoSidedLighting() );
glstate_->set_clear_color( properties_.backgroundColor() );
if (properties_.isCCWFront() )
......
......@@ -122,12 +122,14 @@ public:
/** Create a glViewer.
\param _parent parent widget
\param _name name (qt internal, qt debugging)
\param _properties viewerOptions controlled by PluginFunctions
\param _statusBar pointer to an existing status bar for this widget,
if \c statusBar==0 then a \a private status bar will be created
\param _format OpenGL context settings, will be passed to glarea()
*/
glViewer( QtGLGraphicsScene* _scene,
QGLWidget* _glWidget,
Viewer::ViewerProperties& _properties,
QGraphicsWidget* _parent=0,
const char* _name=0,
QStatusBar *_statusBar=0);
......@@ -871,7 +873,7 @@ private:
private:
/// All properties for this viewer
Viewer::ViewerProperties properties_;
Viewer::ViewerProperties& properties_;
/// Gl State
ACG::GLState *glstate_;
......
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