66 #include <OpenFlipper/common/RecentFiles.hh>
70 #include <OpenFlipper/ACGHelper/DrawModeConverter.hh>
84 if (_ini.
get_entry(viewModeCount,
"Options",
"ViewModeCount") )
85 for (
int i=0; i < viewModeCount; i++){
87 QString entryToolbars;
88 QString entryToolboxes;
89 QString entryContextMenus;
92 QString keyToolbars =
"ViewModeToolbars" + QString::number(i);
93 QString keyToolboxes =
"ViewModeToolboxes" + QString::number(i);
94 QString keyContextMenus =
"ViewModeContextMenus" + QString::number(i);
95 QString keyIcon =
"ViewModeIcon" + QString::number(i);
98 if ( !_ini.
get_entry( entryToolbars ,
"Options" , keyToolbars ) )
continue;
99 if ( !_ini.
get_entry( entryToolboxes ,
"Options" , keyToolboxes ) )
continue;
100 if ( !_ini.
get_entry( entryContextMenus ,
"Options" , keyContextMenus ) )
continue;
101 if ( !_ini.
get_entry( entryIcon ,
"Options" , keyIcon ) )
continue;
103 QStringList toolBars = entryToolbars.split(
";");
104 QStringList toolBoxes = entryToolboxes.split(
";");
105 QStringList contextMenus = entryContextMenus.split(
";");
108 QString mode = toolBoxes.first();
111 toolBoxes.removeFirst();
112 toolBars.removeFirst();
113 contextMenus.removeFirst();
128 vm->
icon = entryIcon;
136 if (_ini.
get_entry(type,
"Options" ,
"default_DataType" ))
137 OpenFlipper::Options::lastDataType(type);
143 if( _ini.
get_entry(startup_dir,
"Options",
"StartupDir") )
150 if( _ini.
get_entry(script_dir,
"Options",
"CurrentScriptDir") )
151 OpenFlipper::Options::currentScriptDir(script_dir);
156 QString current_texture_dir;
157 if( _ini.
get_entry(current_texture_dir,
"Options",
"CurrentTextureDir") )
158 OpenFlipper::Options::currentTextureDir(current_texture_dir);
163 bool random_default_color =
false;
164 if ( _ini.
get_entry( random_default_color,
"Options" ,
"RandomDefaultColor") )
165 OpenFlipper::Options::randomDefaultColor( random_default_color );
170 bool synchronization =
false;
171 if ( _ini.
get_entry( synchronization,
"Options" ,
"Synchronization") )
172 OpenFlipper::Options::synchronization(synchronization);
185 if ( _ini.
get_entry( stereoMode,
"Options" ,
"StereoMode") )
186 OpenFlipper::Options::stereoMode(static_cast<OpenFlipper::Options::StereoMode> (stereoMode));
191 std::vector<float> mat;
192 if ( _ini.
get_entry( mat,
"Options" ,
"CustomAnaglyphLeftEye") && mat.size () == 9)
194 OpenFlipper::Options::anaglyphLeftEyeColorMatrix(mat);
198 std::vector<float> set (9,0.0);
202 OpenFlipper::Options::anaglyphLeftEyeColorMatrix(set);
205 if ( _ini.
get_entry( mat,
"Options" ,
"CustomAnaglyphRightEye") && mat.size () == 9)
207 OpenFlipper::Options::anaglyphRightEyeColorMatrix(mat);
211 std::vector<float> set (9,0.0);
214 OpenFlipper::Options::anaglyphRightEyeColorMatrix(set);
220 unsigned int defaultColor = 0;
221 if ( _ini.
get_entry( defaultColor,
"Options" ,
"DefaultColor") )
222 OpenFlipper::Options::defaultColor(QRgb(defaultColor));
227 QString viewmode =
"";
228 if ( _ini.
get_entry( viewmode,
"Options" ,
"CurrentViewMode") )
229 OpenFlipper::Options::currentViewMode(viewmode);
234 int viewerLayout = 0;
235 if ( _ini.
get_entry( viewerLayout,
"Options" ,
"DefaultViewerLayout") )
236 OpenFlipper::Options::defaultViewerLayout(viewerLayout);
241 std::vector< QString > draw_modes;
243 for (
int i=0; i < 4; i++ ){
245 if( _ini.
get_entry(draw_modes,
"Options",
"DefaultDrawModes" + QString::number(i) ) )
246 OpenFlipper::Options::defaultDrawMode( listToDrawMode(draw_modes), i );
253 bool doSlotDebugging =
false;
254 if( _ini.
get_entry(doSlotDebugging,
"Options",
"SlotDebugging") )
255 OpenFlipper::Options::doSlotDebugging(doSlotDebugging);
261 unsigned int viewerCount = 0;
262 if( _ini.
get_entry(viewerCount,
"Options",
"ViewerCount") ){
265 for (
unsigned int i = 0 ; i < viewerCount; ++i ) {
267 if (OpenFlipper::Options::examinerWidgets() < i)
270 QString entryHeader =
"Viewer" + QString::number(i) +
"/";
294 QVector< QString > toolboxes;
295 QVector< QString > toolbars;
296 QVector< QString > contextmenus;
297 QVector< QString > icons;
299 if ( OpenFlipper::Options::gui() )
310 toolboxes.push_back(entryToolboxes);
319 toolbars.push_back(entryToolbars);
327 contextmenus.push_back(entryContextMenus);
333 _ini.
add_entry(
"Options",
"ViewModeCount" ,toolboxes.size());
334 for (
int i=0; i < toolboxes.size(); i++) {
335 _ini.
add_entry(
"Options",
"ViewModeToolboxes" + QString::number(i) ,toolboxes[i]);
336 _ini.
add_entry(
"Options",
"ViewModeToolbars" + QString::number(i) ,toolbars[i] );
337 _ini.
add_entry(
"Options",
"ViewModeContextMenus" + QString::number(i) ,contextmenus[i] );
338 _ini.
add_entry(
"Options",
"ViewModeIcon" + QString::number(i) ,icons[i] );
342 if ( OpenFlipper::Options::gui() )
346 _ini.
add_entry(
"Options" ,
"default_DataType" , OpenFlipper::Options::lastDataType() );
349 _ini.
add_entry(
"Options",
"CurrentViewMode",OpenFlipper::Options::currentViewMode() );
354 _ini.
add_entry(
"Options",
"SlotDebugging",OpenFlipper::Options::doSlotDebugging() );
357 _ini.
add_entry(
"Options",
"StartupDir",dir);
359 QString scriptDir = OpenFlipper::Options::currentScriptDirStr().toUtf8();
360 _ini.
add_entry(
"Options",
"CurrentScriptDir",scriptDir);
362 QString current_texture_dir = OpenFlipper::Options::currentTextureDirStr().toUtf8();
363 _ini.
add_entry(
"Options",
"CurrentTextureDir",current_texture_dir);
365 _ini.
add_entry(
"Options",
"RandomDefaultColor", OpenFlipper::Options::randomDefaultColor() );
367 if ( OpenFlipper::Options::gui() ) {
369 _ini.
add_entry(
"Options",
"DefaultViewerLayout", OpenFlipper::Options::defaultViewerLayout() );
371 _ini.
add_entry(
"Options",
"ViewerCount", OpenFlipper::Options::examinerWidgets() );
373 for (
unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
374 QString entryHead =
"Viewer" + QString::number(i) +
"/";
384 std::vector< QString > draw_modes;
388 draw_modes = drawModeToList( OpenFlipper::Options::defaultDrawMode(i) );
389 _ini.
add_entry(
"Options",
"DefaultDrawModes" + QString::number(i), draw_modes);
393 _ini.
add_entry(
"Options",
"DefaultColor", (uint)OpenFlipper::Options::defaultColor().rgba () );
395 _ini.
add_entry(
"Options",
"StereoMode",OpenFlipper::Options::stereoMode() );
397 _ini.
add_entry(
"Options" ,
"CustomAnaglyphLeftEye", OpenFlipper::Options::anaglyphLeftEyeColorMatrix() );
398 _ini.
add_entry(
"Options" ,
"CustomAnaglyphRightEye", OpenFlipper::Options::anaglyphRightEyeColorMatrix() );
408 bool _perPluginSettings,
412 if ( ! ini.
connect(_filename,
false) ) {
413 emit
log(
LOGERR,tr(
"Failed to connect to ini file") + _filename);
417 if ( OpenFlipper::Options::gui() ) {
418 coreWidget_->statusMessage( tr(
"Loading ini File ") + _filename +
" ...");
423 OpenFlipper::Options::blockSceneGraphUpdates();
430 if ( _perPluginSettings )
433 if ( _loadObjects ) {
435 QStringList openFiles;
440 for (
int i = 0 ; i < openFiles.size(); ++i ) {
442 QString sectionName = openFiles[i];
446 if ( sectionName.isEmpty() ) {
447 emit
log(
LOGWARN,tr(
"Warning from ini file parser: OpenFiles list contains empty string.") );
453 emit
log(
LOGERR,tr(
"Error parsing ini file. OpenFiles section %1 not found in File!").arg(sectionName));
459 if ( !ini.
get_entry( path, sectionName ,
"path" ) ) {
460 emit
log(
LOGERR,tr(
"Error parsing ini file. Section %1 contains no path description!").arg(sectionName));
465 if (path.startsWith(
"." + OpenFlipper::Options::dirSeparator() )){
468 if (_filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) !=
""){
470 path = _filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) + path;
479 if ( ini.
get_entry( tmpType, sectionName ,
"type" )) {
481 emit
log(
LOGWARN, tr(
"This ini file uses old int style ObjectType fields!") );
482 emit
log(
LOGWARN, tr(
"Please convert it to new format! ( ... just save it )") );
487 if ( ini.
get_entry( typeName, sectionName ,
"type" )) {
490 emit
log(
LOGWARN, tr(
"Unable to get DataType for object %1 assuming Triangle Mesh!").arg(sectionName) );
499 emit
log(
LOGERR,tr(
"Unable to open Object ") + path);
505 if ( ini.
get_entry( flag, sectionName ,
"target" ) )
509 if ( ini.
get_entry( flag, sectionName ,
"source" ) )
521 if ( _perPluginSettings )
528 OpenFlipper::Options::unblockSceneGraphUpdates();
534 if ( OpenFlipper::Options::gui() ){
535 for (
unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
540 coreWidget_->statusMessage( tr(
"Loading ini File ") + _filename + tr(
" ... Done"), 4000);
549 bool _saveSystemSettings,
550 bool _savePluginSettings ,
551 bool _saveObjectInfo,
552 std::map<int,QString>& _fileMapping) {
556 if ( ! ini.
connect(_filename,
true) ) {
557 emit
log(
LOGERR,tr(
"Failed to connect to _ini file") + _filename);
561 if ( OpenFlipper::Options::gui() ) {
562 coreWidget_->statusMessage( tr(
"Saving ini File ") + _filename +
" ...");
567 if ( _saveSystemSettings )
570 if ( _savePluginSettings )
573 if ( _saveObjectInfo ) {
575 QStringList openFiles;
590 std::map<int,QString>::iterator f = _fileMapping.find(o_it->id());
591 if(f == _fileMapping.end()) {
592 file = o_it->path() + OpenFlipper::Options::dirSeparator() + o_it->name();
604 if (QFile(file).exists()){
606 sectionName = o_it->name();
607 openFiles.push_back( sectionName );
611 int prefixLen = _filename.section(OpenFlipper::Options::dirSeparator(),0,-2).length();
612 file.remove(0, prefixLen);
616 ini.
add_entry( sectionName ,
"path" , file );
618 ini.
add_entry( sectionName ,
"target" , o_it->target() );
619 ini.
add_entry( sectionName ,
"source" , o_it->source() );
624 ini.
add_entry(
"OpenFiles",
"open",openFiles);
636 emit
iniSave( ini , o_it->id() );
644 if ( OpenFlipper::Options::gui() ) {
645 coreWidget_->statusMessage( tr(
"Saving ini File ") + _filename + tr(
" ... Done"), 4000);
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
void iniLoadOptionsLast(INIFile &_ini)
This signal is used to tell the plugins to load their new status after objects are loaded...
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
const QStringList ALL_OBJECTS
Iterable object range.
void disconnect()
Remove connection of this object to a file.
QVector< ViewMode * > viewModes_
List of available draw modes.
void twoSidedLighting(bool _state)
set 2-sided lighting on/off
void iniSave(INIFile &_ini, int _id)
This signal is used to tell the plugins to save the data of _id to the given file.
void iniLoadOptions(INIFile &_ini)
This signal is used to tell the plugins to load their new status.
bool getObject(int _identifier, BSplineCurveObject *&_object)
BaseObject * objectRoot_
Pointer to the data rootNode;.
bool connect(const QString &name, const bool create)
Connect INIFile object with given filename.
bool defaultLight() const
Is light default light source?
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void loadObject()
Open Load Widget.
bool get_entry(QString &_val, const QString &_section, const QString &_key) const
Access to a string entry.
void add_entry(const QString &_section, const QString &_key, const QString &_value)
Addition / modification of a string entry.
QStringList visibleContextMenus
List of context Menus in this view mode.
void saveKeyBindings(INIFile &_ini)
Store current key assignments to a given INI file.
void resetScenegraph(bool _resetTrackBall)
Class for the handling of simple configuration files.
bool custom
Is this a user defined custom view mode or a plugin generated one.
void log(Logtype _type, QString _message)
Logg with OUT,WARN or ERR as type.
QString name
Name of the View Mode.
Status is processing and blocked system will not allow interaction (red light)
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
QStringList visibleToolboxes
List of Visible Toolboxes in this view mode.
void saveOnExit(INIFile &_ini)
This signal is emitted before the core deletes its data and exits.
BaseObject * childExists(int _objectId)
Check if the element exists in the subtree of this element.
int viewers()
Get the number of viewers.
void readApplicationOptions(INIFile &_ini)
Get and set Application options from ini file.
bool backFaceCulling()
Get current state of backface culling.
ViewMode struct This struct contains a ViewMode and its status information such as used widgets...
void iniSaveOptions(INIFile &_ini)
This signal is used to tell the plugins to save their current status.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void animation(bool _state)
set 2-sided lighting on/off
CoreWidget * coreWidget_
The main applications widget ( only created in gui mode )
QStringList IteratorRestriction
Iterable object range.
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)
Status is ready (green light)
QStringList visibleToolbars
List of Toolbars in this view mode.
bool section_exists(const QString &_section) const
Check if given section exists in the current INI file.
QVector< ViewMode * > & viewModes_
List of currently available viewModes.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void writeApplicationOptions(INIFile &_ini)
Write Application options to ini file.
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.
void openIniFile(QString _filename, bool _coreSettings, bool _perPluginSettings, bool _loadObjects)
Load information from an ini file.
std::vector< glViewer * > examiner_widgets_
Examiner Widget.