Commit efab96c0 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

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_; ...@@ -57,6 +57,12 @@ static BaseObject* objectRoot_;
*/ */
static std::vector< glViewer* > examiner_widgets_; 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 /// TODO : Remove this variable and implement multiView correctly here
static glViewer* examiner_widget_; static glViewer* examiner_widget_;
...@@ -81,6 +87,10 @@ void setViewers( std::vector< glViewer* > _examiner_widgets ) { ...@@ -81,6 +87,10 @@ void setViewers( std::vector< glViewer* > _examiner_widgets ) {
PluginFunctions::examiner_widget_ = examiner_widgets_[0]; PluginFunctions::examiner_widget_ = examiner_widgets_[0];
} }
void setViewerProperties( std::vector< Viewer::ViewerProperties* > _viewerProperties ) {
PluginFunctions::viewerProperties_ = _viewerProperties;
}
void setActiveExaminer( const unsigned int _id ) { void setActiveExaminer( const unsigned int _id ) {
activeExaminer_ = _id; activeExaminer_ = _id;
} }
...@@ -361,7 +371,7 @@ Viewer::ActionMode actionMode() { ...@@ -361,7 +371,7 @@ Viewer::ActionMode actionMode() {
} }
Viewer::ViewerProperties& viewerProperties(int _id) { 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; std::cerr << " Error, requested properties for non-existing Viewer!" << std::endl;
return dummyProperties; return dummyProperties;
} }
...@@ -369,7 +379,7 @@ Viewer::ViewerProperties& viewerProperties(int _id) { ...@@ -369,7 +379,7 @@ Viewer::ViewerProperties& viewerProperties(int _id) {
if ( _id == -1 ) if ( _id == -1 )
_id = activeExaminer_; _id = activeExaminer_;
return (*examiner_widgets_[_id]->properties()); return ( *viewerProperties_[_id] );
} }
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <OpenFlipper/common/GlobalDefines.hh> #include <OpenFlipper/common/GlobalDefines.hh>
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh> #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <OpenFlipper/common/ViewerProperties.hh>
namespace PluginFunctions { namespace PluginFunctions {
...@@ -63,6 +64,10 @@ namespace PluginFunctions { ...@@ -63,6 +64,10 @@ namespace PluginFunctions {
DLLEXPORT DLLEXPORT
void setViewers( std::vector< glViewer* > _examiner_widgets ); 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!! ) /// Set the internal scenegraph root node pointer ( DO NOT USE!! )
DLLEXPORT DLLEXPORT
void setSceneGraphRootNode( SeparatorNode* _root_node ); void setSceneGraphRootNode( SeparatorNode* _root_node );
......
...@@ -123,6 +123,14 @@ Core() : ...@@ -123,6 +123,14 @@ Core() :
viewModes_.push_front(vm); 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 // Get all relevant Paths and Options from option files
setupOptions(); setupOptions();
......
...@@ -270,33 +270,6 @@ void Core::readApplicationOptions(INIFile& _ini) { ...@@ -270,33 +270,6 @@ void Core::readApplicationOptions(INIFile& _ini) {
if( _ini.get_entry(renderPicking, "Options", "PickingRenderMode") ) if( _ini.get_entry(renderPicking, "Options", "PickingRenderMode") )
OpenFlipper::Options::pickingRenderMode(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 // ViewerProperties
//============================================================================ //============================================================================
...@@ -305,36 +278,52 @@ void Core::readGUIOptions(INIFile& _ini) { ...@@ -305,36 +278,52 @@ void Core::readGUIOptions(INIFile& _ini) {
if( _ini.get_entry(multiView, "Options", "MultiView") ) if( _ini.get_entry(multiView, "Options", "MultiView") )
OpenFlipper::Options::multiView(multiView); OpenFlipper::Options::multiView(multiView);
uint viewerCount = 0;
if( _ini.get_entry(viewerCount, "Options", "ViewerCount") ){ if( _ini.get_entry(viewerCount, "Options", "ViewerCount") ){
} }
}
if ( _ini.section_exists("ViewerProperties") ){ 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;
// Load the animation setting // Load the animation setting
bool animation = false; bool animation = false;
if ( _ini.get_entry( animation, "ViewerProperties" , "Animation" + QString::number(i) ) ) if ( _ini.get_entry( animation, "ViewerProperties" , "Animation" + QString::number(i) ) )
PluginFunctions::viewerProperties(i).animation(animation); 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; // Update information
if ( _ini.get_entry( twoSidedLighting, "ViewerProperties" , "TwoSidedLighting" + QString::number(i)) ) //============================================================================
PluginFunctions::viewerProperties(i).twoSidedLighting(twoSidedLighting); QString updateUrl = "";
if( _ini.get_entry(updateUrl, "Options", "UpdateURL") )
OpenFlipper::Options::updateUrl(updateUrl);
// Load the backface culling setting QString updateUsername = "";
bool backface_culling = false; if( _ini.get_entry(updateUsername, "Options", "UpdateUsername") )
if ( _ini.get_entry( backface_culling, "ViewerProperties" , "BackfaceCulling" + QString::number(i)) ) OpenFlipper::Options::updateUsername(updateUsername);
PluginFunctions::viewerProperties(i).backFaceCulling(backface_culling);
// Load the setting for the background color option QString updatePassword = "";
uint viewerBackground = 0; if( _ini.get_entry(updatePassword, "Options", "UpdatePassword") )
if ( _ini.get_entry( viewerBackground, "ViewerProperties" , "BackgroundColor" + QString::number(i)) ) OpenFlipper::Options::updatePassword(updatePassword);
PluginFunctions::viewerProperties(i).backgroundColor( QRgb(viewerBackground) );
}
} }
} }
...@@ -516,8 +505,6 @@ void Core::openIniFile( QString _filename, ...@@ -516,8 +505,6 @@ void Core::openIniFile( QString _filename,
if ( _coreSettings ) if ( _coreSettings )
readApplicationOptions(ini); readApplicationOptions(ini);
readGUIOptions(ini);
// if requested load per Plugin settings from the settings file // if requested load per Plugin settings from the settings file
if ( _perPluginSettings ) if ( _perPluginSettings )
emit iniLoadOptions( ini ); 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) { ...@@ -207,27 +207,10 @@ void segfaultHandling (int) {
std::abort(); std::abort();
} }
int main(int argc, char **argv) bool openPolyMeshes = false;
{ bool remoteControl = false;
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 parseCommandLineOptions(CSimpleOpt& args){
// Parse command line Options
//======================================================
bool openPolyMeshes = false;
bool remoteControl = false;
CSimpleOpt args(argc, argv, g_rgOptions);
// while there are arguments left to process // while there are arguments left to process
while (args.Next()) { while (args.Next()) {
...@@ -270,9 +253,26 @@ int main(int argc, char **argv) ...@@ -270,9 +253,26 @@ int main(int argc, char **argv)
} else { } else {
std::cerr << "Invalid argument: " << args.OptionText() << std::endl; std::cerr << "Invalid argument: " << args.OptionText() << std::endl;
showHelp(); 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() ) { if ( !OpenFlipper::Options::nogui() ) {
...@@ -290,6 +290,9 @@ int main(int argc, char **argv) ...@@ -290,6 +290,9 @@ int main(int argc, char **argv)
// create core ( this also reads the ini files ) // create core ( this also reads the ini files )
Core * w = new Core( ); Core * w = new Core( );
if ( !parseCommandLineOptions(args) )
return 1;
// After setting all Options from command line, build the real gui // After setting all Options from command line, build the real gui
w->init(); w->init();
...@@ -312,6 +315,9 @@ int main(int argc, char **argv) ...@@ -312,6 +315,9 @@ int main(int argc, char **argv)
// create widget ( this also reads the ini files ) // create widget ( this also reads the ini files )
Core * w = new Core( ); Core * w = new Core( );
if ( !parseCommandLineOptions(args) )
return 1;
// After setting all Options from command line, build the real gui // After setting all Options from command line, build the real gui
w->init(); w->init();
......
...@@ -305,7 +305,7 @@ namespace Viewer { ...@@ -305,7 +305,7 @@ namespace Viewer {
public slots: public slots:
/// set 2-sided lighting on/off /// 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? /// is 2-sided lighing enabled?
bool twoSidedLighting() { return twoSidedLighting_; }; bool twoSidedLighting() { return twoSidedLighting_; };
......
...@@ -164,6 +164,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -164,6 +164,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
glViewer* examinerWidget = new glViewer(glScene_, glViewer* examinerWidget = new glViewer(glScene_,
glWidget_, glWidget_,
PluginFunctions::viewerProperties(0),
centerWidget_, centerWidget_,
"Examiner Widget", "Examiner Widget",
statusBar_); statusBar_);
...@@ -181,9 +182,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -181,9 +182,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
glViewer* newWidget = new glViewer(glScene_, glViewer* newWidget = new glViewer(glScene_,
glWidget_, glWidget_,
PluginFunctions::viewerProperties(i),
centerWidget_, centerWidget_,
"Examiner Widget", "Examiner Widget",
statusBar_ ); statusBar_);
examiner_widgets_.push_back(newWidget); examiner_widgets_.push_back(newWidget);
} }
......
...@@ -115,6 +115,7 @@ static const char VIEW_MAGIC[] = ...@@ -115,6 +115,7 @@ static const char VIEW_MAGIC[] =
glViewer::glViewer( QtGLGraphicsScene* _scene, glViewer::glViewer( QtGLGraphicsScene* _scene,
QGLWidget* _glWidget, QGLWidget* _glWidget,
Viewer::ViewerProperties& _properties,
QGraphicsWidget* _parent, QGraphicsWidget* _parent,
const char* /* _name */ , const char* /* _name */ ,
QStatusBar *_statusBar) : QStatusBar *_statusBar) :
...@@ -127,6 +128,7 @@ glViewer::glViewer( QtGLGraphicsScene* _scene, ...@@ -127,6 +128,7 @@ glViewer::glViewer( QtGLGraphicsScene* _scene,
glWidget_(_glWidget), glWidget_(_glWidget),
pick_mode_name_(""), pick_mode_name_(""),
pick_mode_idx_(-1), pick_mode_idx_(-1),
properties_(_properties),
glstate_(0) glstate_(0)
{ {
...@@ -191,6 +193,9 @@ glViewer::glViewer( QtGLGraphicsScene* _scene, ...@@ -191,6 +193,9 @@ glViewer::glViewer( QtGLGraphicsScene* _scene,
properties_.setExamineMode(); properties_.setExamineMode();
//check for updated properties once
slotPropertiesUpdated();
setAcceptDrops(true); setAcceptDrops(true);
} }
...@@ -1991,6 +1996,9 @@ void glViewer::slotAnimation() ...@@ -1991,6 +1996,9 @@ void glViewer::slotAnimation()
} }
void glViewer::applyProperties() { void glViewer::applyProperties() {
glstate_->set_twosided_lighting( properties_.twoSidedLighting() );
glstate_->set_clear_color( properties_.backgroundColor() ); glstate_->set_clear_color( properties_.backgroundColor() );
if (properties_.isCCWFront() ) if (properties_.isCCWFront() )
......
...@@ -122,12 +122,14 @@ public: ...@@ -122,12 +122,14 @@ public:
/** Create a glViewer. /** Create a glViewer.
\param _parent parent widget \param _parent parent widget
\param _name name (qt internal, qt debugging) \param _name name (qt internal, qt debugging)
\param _properties viewerOptions controlled by PluginFunctions
\param _statusBar pointer to an existing status bar for this widget, \param _statusBar pointer to an existing status bar for this widget,
if \c statusBar==0 then a \a private status bar will be created if \c statusBar==0 then a \a private status bar will be created
\param _format OpenGL context settings, will be passed to glarea() \param _format OpenGL context settings, will be passed to glarea()
*/ */
glViewer( QtGLGraphicsScene* _scene, glViewer( QtGLGraphicsScene* _scene,
QGLWidget* _glWidget, QGLWidget* _glWidget,
Viewer::ViewerProperties& _properties,
QGraphicsWidget* _parent=0, QGraphicsWidget* _parent=0,
const char* _name=0, const char* _name=0,
QStatusBar *_statusBar=0); QStatusBar *_statusBar=0);
...@@ -871,7 +873,7 @@ private: ...@@ -871,7 +873,7 @@ private:
private: private:
/// All properties for this viewer /// All properties for this viewer
Viewer::ViewerProperties properties_; Viewer::ViewerProperties& properties_;
/// Gl State /// Gl State
ACG::GLState *glstate_; 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