60 #include <OpenFlipper/common/RecentFiles.hh> 64 #include <OpenFlipper/ACGHelper/DrawModeConverter.hh> 78 if (_ini.
get_entry(viewModeCount,
"Options",
"ViewModeCount") )
79 for (
int i=0; i < viewModeCount; i++){
81 QString entryToolbars;
82 QString entryToolboxes;
83 QString entryContextMenus;
86 QString keyToolbars =
"ViewModeToolbars" + QString::number(i);
87 QString keyToolboxes =
"ViewModeToolboxes" + QString::number(i);
88 QString keyContextMenus =
"ViewModeContextMenus" + QString::number(i);
89 QString keyIcon =
"ViewModeIcon" + QString::number(i);
92 if ( !_ini.
get_entry( entryToolbars ,
"Options" , keyToolbars ) )
continue;
93 if ( !_ini.
get_entry( entryToolboxes ,
"Options" , keyToolboxes ) )
continue;
94 if ( !_ini.
get_entry( entryContextMenus ,
"Options" , keyContextMenus ) )
continue;
95 if ( !_ini.
get_entry( entryIcon ,
"Options" , keyIcon ) )
continue;
97 QStringList toolBars = entryToolbars.split(
";");
98 QStringList toolBoxes = entryToolboxes.split(
";");
99 QStringList contextMenus = entryContextMenus.split(
";");
102 QString mode = toolBoxes.first();
105 toolBoxes.removeFirst();
106 toolBars.removeFirst();
107 contextMenus.removeFirst();
111 for (
int modeNr = 0; modeNr <
viewModes_.size(); modeNr++)
122 vm->
icon = entryIcon;
130 if (_ini.
get_entry(type,
"Options" ,
"default_DataType" ))
131 OpenFlipper::Options::lastDataType(type);
137 if( _ini.
get_entry(startup_dir,
"Options",
"StartupDir") )
144 if( _ini.
get_entry(script_dir,
"Options",
"CurrentScriptDir") )
145 OpenFlipper::Options::currentScriptDir(script_dir);
150 QString current_texture_dir;
151 if( _ini.
get_entry(current_texture_dir,
"Options",
"CurrentTextureDir") )
152 OpenFlipper::Options::currentTextureDir(current_texture_dir);
157 bool random_default_color =
false;
158 if ( _ini.
get_entry( random_default_color,
"Options" ,
"RandomDefaultColor") )
159 OpenFlipper::Options::randomDefaultColor( random_default_color );
164 bool synchronization =
false;
165 if ( _ini.
get_entry( synchronization,
"Options" ,
"Synchronization") )
166 OpenFlipper::Options::synchronization(synchronization);
179 if ( _ini.
get_entry( stereoMode,
"Options" ,
"StereoMode") )
180 OpenFlipper::Options::stereoMode(static_cast<OpenFlipper::Options::StereoMode> (stereoMode));
185 std::vector<float> mat;
186 if ( _ini.
get_entry( mat,
"Options" ,
"CustomAnaglyphLeftEye") && mat.size () == 9)
188 OpenFlipper::Options::anaglyphLeftEyeColorMatrix(mat);
192 std::vector<float>
set (9,0.0);
196 OpenFlipper::Options::anaglyphLeftEyeColorMatrix(
set);
199 if ( _ini.
get_entry( mat,
"Options" ,
"CustomAnaglyphRightEye") && mat.size () == 9)
201 OpenFlipper::Options::anaglyphRightEyeColorMatrix(mat);
205 std::vector<float>
set (9,0.0);
208 OpenFlipper::Options::anaglyphRightEyeColorMatrix(
set);
214 unsigned int defaultColor = 0;
215 if ( _ini.
get_entry( defaultColor,
"Options" ,
"DefaultColor") )
216 OpenFlipper::Options::defaultColor(QRgb(defaultColor));
221 QString viewmode =
"";
222 if ( _ini.
get_entry( viewmode,
"Options" ,
"CurrentViewMode") )
223 OpenFlipper::Options::currentViewMode(viewmode);
228 int viewerLayout = 0;
229 if ( _ini.
get_entry( viewerLayout,
"Options" ,
"DefaultViewerLayout") )
230 OpenFlipper::Options::defaultViewerLayout(viewerLayout);
235 std::vector< QString > draw_modes;
237 for (
int i=0; i < 4; i++ ){
239 if( _ini.
get_entry(draw_modes,
"Options",
"DefaultDrawModes" + QString::number(i) ) )
240 OpenFlipper::Options::defaultDrawMode( listToDrawMode(draw_modes), i );
247 bool doSlotDebugging =
false;
248 if( _ini.
get_entry(doSlotDebugging,
"Options",
"SlotDebugging") )
249 OpenFlipper::Options::doSlotDebugging(doSlotDebugging);
255 unsigned int viewerCount = 0;
256 if( _ini.
get_entry(viewerCount,
"Options",
"ViewerCount") ){
259 for (
unsigned int i = 0 ; i < viewerCount; ++i ) {
261 if (OpenFlipper::Options::examinerWidgets() < i)
264 QString entryHeader =
"Viewer" + QString::number(i) +
"/";
288 QVector< QString > toolboxes;
289 QVector< QString > toolbars;
290 QVector< QString > contextmenus;
291 QVector< QString > icons;
293 if ( OpenFlipper::Options::gui() )
304 toolboxes.push_back(entryToolboxes);
313 toolbars.push_back(entryToolbars);
321 contextmenus.push_back(entryContextMenus);
327 _ini.
add_entry(
"Options",
"ViewModeCount" ,toolboxes.size());
328 for (
int i=0; i < toolboxes.size(); i++) {
329 _ini.
add_entry(
"Options",
"ViewModeToolboxes" + QString::number(i) ,toolboxes[i]);
330 _ini.
add_entry(
"Options",
"ViewModeToolbars" + QString::number(i) ,toolbars[i] );
331 _ini.
add_entry(
"Options",
"ViewModeContextMenus" + QString::number(i) ,contextmenus[i] );
332 _ini.
add_entry(
"Options",
"ViewModeIcon" + QString::number(i) ,icons[i] );
336 if ( OpenFlipper::Options::gui() )
340 _ini.
add_entry(
"Options" ,
"default_DataType" , OpenFlipper::Options::lastDataType() );
343 _ini.
add_entry(
"Options",
"CurrentViewMode",OpenFlipper::Options::currentViewMode() );
348 _ini.
add_entry(
"Options",
"SlotDebugging",OpenFlipper::Options::doSlotDebugging() );
351 _ini.
add_entry(
"Options",
"StartupDir",dir);
353 QString scriptDir = OpenFlipper::Options::currentScriptDirStr().toUtf8();
354 _ini.
add_entry(
"Options",
"CurrentScriptDir",scriptDir);
356 QString current_texture_dir = OpenFlipper::Options::currentTextureDirStr().toUtf8();
357 _ini.
add_entry(
"Options",
"CurrentTextureDir",current_texture_dir);
359 _ini.
add_entry(
"Options",
"RandomDefaultColor", OpenFlipper::Options::randomDefaultColor() );
361 if ( OpenFlipper::Options::gui() ) {
363 _ini.
add_entry(
"Options",
"DefaultViewerLayout", OpenFlipper::Options::defaultViewerLayout() );
365 _ini.
add_entry(
"Options",
"ViewerCount", OpenFlipper::Options::examinerWidgets() );
367 for (
unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
368 QString entryHead =
"Viewer" + QString::number(i) +
"/";
378 std::vector< QString > draw_modes;
382 draw_modes = drawModeToList( OpenFlipper::Options::defaultDrawMode(i) );
383 _ini.
add_entry(
"Options",
"DefaultDrawModes" + QString::number(i), draw_modes);
387 _ini.
add_entry(
"Options",
"DefaultColor", (uint)OpenFlipper::Options::defaultColor().rgba () );
389 _ini.
add_entry(
"Options",
"StereoMode",OpenFlipper::Options::stereoMode() );
391 _ini.
add_entry(
"Options" ,
"CustomAnaglyphLeftEye", OpenFlipper::Options::anaglyphLeftEyeColorMatrix() );
392 _ini.
add_entry(
"Options" ,
"CustomAnaglyphRightEye", OpenFlipper::Options::anaglyphRightEyeColorMatrix() );
402 bool _perPluginSettings,
406 if ( ! ini.
connect(_filename,
false) ) {
407 emit
log(
LOGERR,tr(
"Failed to connect to ini file") + _filename);
411 if ( OpenFlipper::Options::gui() ) {
412 coreWidget_->statusMessage( tr(
"Loading ini File ") + _filename +
" ...");
417 OpenFlipper::Options::blockSceneGraphUpdates();
424 if ( _perPluginSettings )
427 if ( _loadObjects ) {
429 QStringList openFiles;
434 for (
int i = 0 ; i < openFiles.size(); ++i ) {
436 QString sectionName = openFiles[i];
440 if ( sectionName.isEmpty() ) {
441 emit
log(
LOGWARN,tr(
"Warning from ini file parser: OpenFiles list contains empty string.") );
447 emit
log(
LOGERR,tr(
"Error parsing ini file. OpenFiles section %1 not found in File!").arg(sectionName));
453 if ( !ini.
get_entry( path, sectionName ,
"path" ) ) {
454 emit
log(
LOGERR,tr(
"Error parsing ini file. Section %1 contains no path description!").arg(sectionName));
459 if (path.startsWith(
"." + OpenFlipper::Options::dirSeparator() )){
462 if (_filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) !=
""){
464 path = _filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) + path;
473 if ( ini.
get_entry( tmpType, sectionName ,
"type" )) {
475 emit
log(
LOGWARN, tr(
"This ini file uses old int style ObjectType fields!") );
476 emit
log(
LOGWARN, tr(
"Please convert it to new format! ( ... just save it )") );
481 if ( ini.
get_entry( typeName, sectionName ,
"type" )) {
484 emit
log(
LOGWARN, tr(
"Unable to get DataType for object %1 assuming Triangle Mesh!").arg(sectionName) );
493 emit
log(
LOGERR,tr(
"Unable to open Object ") + path);
499 if ( ini.
get_entry( flag, sectionName ,
"target" ) )
503 if ( ini.
get_entry( flag, sectionName ,
"source" ) )
515 if ( _perPluginSettings )
522 OpenFlipper::Options::unblockSceneGraphUpdates();
528 if ( OpenFlipper::Options::gui() ){
529 for (
unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
534 coreWidget_->statusMessage( tr(
"Loading ini File ") + _filename + tr(
" ... Done"), 4000);
543 bool _saveSystemSettings,
544 bool _savePluginSettings ,
545 bool _saveObjectInfo,
546 std::map<int,QString>& _fileMapping) {
550 if ( ! ini.
connect(_filename,
true) ) {
551 emit
log(
LOGERR,tr(
"Failed to connect to _ini file") + _filename);
555 if ( OpenFlipper::Options::gui() ) {
556 coreWidget_->statusMessage( tr(
"Saving ini File ") + _filename +
" ...");
561 if ( _saveSystemSettings )
564 if ( _savePluginSettings )
567 if ( _saveObjectInfo ) {
569 QStringList openFiles;
584 std::map<int,QString>::iterator f = _fileMapping.find(o_it->id());
585 if(f == _fileMapping.end()) {
586 file = o_it->path() + OpenFlipper::Options::dirSeparator() + o_it->name();
600 if (QFile(file).exists()){
602 sectionName = o_it->name();
603 openFiles.push_back( sectionName );
607 int prefixLen = _filename.section(OpenFlipper::Options::dirSeparator(),0,-2).length();
608 file.remove(0, prefixLen);
612 ini.
add_entry( sectionName ,
"path" , file );
614 ini.
add_entry( sectionName ,
"target" , o_it->target() );
615 ini.
add_entry( sectionName ,
"source" , o_it->source() );
620 ini.
add_entry(
"OpenFiles",
"open",openFiles);
635 emit
iniSave( ini , o_it->id() );
643 if ( OpenFlipper::Options::gui() ) {
644 coreWidget_->statusMessage( tr(
"Saving ini File ") + _filename + tr(
" ... Done"), 4000);
void animation(bool _state)
set 2-sided lighting on/off
void saveOnExit(INIFile &_ini)
This signal is emitted before the core deletes its data and exits.
Status is ready (green light)
void writeApplicationOptions(INIFile &_ini)
Write Application options to ini file.
void iniSave(INIFile &_ini, int _id)
This signal is used to tell the plugins to save the data of _id to the given file.
QStringList visibleContextMenus
List of context Menus in this view mode.
ViewMode struct This struct contains a ViewMode and its status information such as used widgets...
void twoSidedLighting(bool _state)
set 2-sided lighting on/off
void disconnect()
Remove connection of this object to a file.
BaseObject * objectRoot_
Pointer to the data rootNode;.
void openIniFile(QString _filename, bool _coreSettings, bool _perPluginSettings, bool _loadObjects)
Load information from an ini file.
void add_entry(const QString &_section, const QString &_key, const QString &_value)
Addition / modification of a string entry.
void writeIniFile(QString _filename, bool _relativePaths, bool _targetOnly, bool _saveSystemSettings, bool _savePluginSettings, bool _saveObjectInfo, std::map< int, QString > &_fileMapping)
Write current status to ini file (Application and File Options)
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
void iniSaveOptions(INIFile &_ini)
This signal is used to tell the plugins to save their current status.
const QStringList ALL_OBJECTS
Iterable object range.
bool get_entry(QString &_val, const QString &_section, const QString &_key) const
Access to a string entry.
void log(Logtype _type, QString _message)
Logg with OUT,WARN or ERR as type.
bool backFaceCulling()
Get current state of backface culling.
BaseObject * childExists(int _objectId)
Check if the element exists in the subtree of this element.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
void iniLoadOptions(INIFile &_ini)
This signal is used to tell the plugins to load their new status.
CoreWidget * coreWidget_
The main applications widget ( only created in gui mode )
void iniLoadOptionsLast(INIFile &_ini)
This signal is used to tell the plugins to load their new status after objects are loaded...
int viewers()
Get the number of viewers.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void iniLoad(INIFile &, int)
If an ini File is opened, this signal is send to Plugins capable of handling ini files.
ACG::Vec4f backgroundColor()
Get current background color.
QStringList IteratorRestriction
Iterable object range.
QVector< ViewMode * > viewModes_
List of available draw modes.
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
QString name
Name of the View Mode.
Status is processing and blocked system will not allow interaction (red light)
void readApplicationOptions(INIFile &_ini)
Get and set Application options from ini file.
QStringList visibleToolboxes
List of Visible Toolboxes in this view mode.
Class for the handling of simple configuration files.
QStringList visibleToolbars
List of Toolbars in this view mode.
bool connect(const QString &name, const bool create)
Connect INIFile object with given filename.
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
void loadObject()
Open Load Widget.
bool custom
Is this a user defined custom view mode or a plugin generated one.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
bool section_exists(const QString &_section) const
Check if given section exists in the current INI file.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
void resetScenegraph(bool _resetTrackBall)
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.