void dmz::QtPluginIconPalletTool::_init (Config &local) { RuntimeContext *context (get_plugin_runtime_context ()); _showMsg = config_create_message ( "show.name", local, "DMZ_Show_Icon_Pallet_Tool", context); subscribe_to_message (_showMsg); _useSession = config_to_boolean ("use-session.value", local, _useSession); if (_useSession && context) { Config session (get_session_config (get_plugin_name (), context)); QByteArray geometry (config_to_qbytearray ("geometry", session, saveGeometry ())); restoreGeometry (geometry); if (config_to_boolean ("window.visible", session, False)) { show (); } } _ui.iconView->setModel (&_model); _add_type (Definitions (context).get_root_object_type ()); }
void dmz::QtPluginAppUpdater::_init (Config &local) { setObjectName (get_plugin_name ().get_buffer ()); RuntimeContext *context (get_plugin_runtime_context ()); _mainWindowModuleName = config_to_string ("module.mainWindow.name", local); _forceUpdate = config_to_boolean ("force-update.value", local, _forceUpdate); _downloadToTemp = config_to_boolean ("download-to-temp.value", local, _downloadToTemp); _releaseChannel = config_to_string ("release.channel", local, _releaseChannel); // _updateUrl = "latest/{system_name}-{release_channel}/{app_name}.xml"; // _downloadUrl = "downloads/{app_name}-{major}-{minor}-{bug}-{build_number}"; String host = config_to_string ("update.host", local); String path = config_to_string ("update.path", local); if (host && path) { _updateUrl = host + path; host = config_to_string ("download.host", local, host); path = config_to_string ("download.path", local); if (host && path) { _downloadUrl = host + path; } } if (_updateUrl) { _log.debug << "Update URL: " << _updateUrl << endl; } else { _log.debug << "Update URL not specified." << endl; } if (_downloadUrl) { _log.debug << "Download URL: " << _downloadUrl << endl; } else { _log.debug << "Download URL not specified." << endl; } _valueAttrHandle = config_to_named_handle ( "attribute.value.name", local, "value", context); _updateMessageName = config_to_string ("update.message", local, _updateMessageName); _channelMessageName = config_to_string ("channel.message", local, _channelMessageName); }
void dmz::QtPluginAppUpdater::_slot_get_version_finished () { QNetworkReply *reply (qobject_cast<QNetworkReply *>(sender ())); if (reply) { if (reply->error () == QNetworkReply::NoError) { if (_updateDialog) { QString data (reply->readAll ()); const String XMLData (qPrintable (data)); Config cd ("global"); if (xml_string_to_config (XMLData, cd)) { _updateVersion = Version (cd); if (!_forceUpdate) { _forceUpdate = config_to_boolean ("dmz.update.force.value", cd); } if (_forceUpdate || (_updateVersion > _version)) { _get_changelog (); const QString Name (_updateVersion.get_name ().get_buffer ()); const QString Build (_updateVersion.get_build ().get_buffer ()); const QString Version (_updateVersion.get_version ().get_buffer ()); const QString CVersion (_version.get_version ().get_buffer ()); const QString CBuild (_version.get_build ().get_buffer ()); QPixmap pix (_updateVersion.get_image_name ().get_buffer()); if (!pix.isNull ()) { _ui.iconLabel->setPixmap (pix); } QString message = _ui.textLabel->text (); message.replace ("{app_name}", Name); message.replace ("{version}", Version); message.replace ("{build_number}", Build); message.replace ("{cversion}", CVersion); message.replace ("{cbuild_number}", CBuild); _ui.textLabel->setText (message); _ui.stackedWidget->setCurrentWidget (_ui.startPage); _updateDialog->open (); } } } } reply->deleteLater (); reply = 0; } }
void dmz::QtPluginCanvasObjectBasic::_init (Config &local) { _canvasModuleName = config_to_string ("module.canvas.name", local); _defaultAttributeHandle = activate_default_object_attribute ( ObjectCreateMask | ObjectDestroyMask); const String StateAttrName ( config_to_string ("attribute.state.name", local, ObjectAttributeDefaultName)); _stateAttributeHandle = activate_object_attribute (StateAttrName, ObjectStateMask); _zValue = config_to_int32 ("defaults.zValue", local, _zValue); _itemIgnoresTransformations = config_to_boolean ( "defaults.itemIgnoresTransformations", local, _itemIgnoresTransformations); Config templ; if (local.lookup_all_config ("template", templ)) { ConfigIterator it; Config objTemplate; while (templ.get_next_config (it, objTemplate)) { String templateName = config_to_string ("name", objTemplate, ""); Config *config = new Config (objTemplate); if (templateName != "" && config && *config && _templateConfigTable.store (templateName, config)) {} else { delete config; config = 0; } } } }
void dmz::RenderPluginStaticTerrainOSG::_init (Config &local) { Config list; if (local.lookup_all_config ("model", list)) { ConfigIterator it; Config model; while (list.get_next_config (it, model)) { const String ResourceName = config_to_string ("resource", model); if (ResourceName) { const String FileName = _rc.find_file (ResourceName); const Boolean Isect = config_to_boolean ("isect", model, True); if (FileName) { ModelStruct *ms = new ModelStruct (Isect); if (ms) { ms->model = osgDB::readNodeFile (FileName.get_buffer ()); if (ms->model.valid ()) { osg::BoundingSphere bound = ms->model->computeBound (); _log.info << FileName << " center: [" << bound.center ().x () << ", " << bound.center ().y () << ", " << bound.center ().z () << "]" << endl; ms->next = _modelList; _modelList = ms; _log.info << "Loaded model: " << FileName << " (" << ResourceName << ")" << endl; } else { delete ms; ms = 0; _log.error << "Failed loading model: " << FileName << " (" << ResourceName << ")" << endl; } } } } else { _log.error << "No resource name specified for static terrain." << endl; } } } }
void dmz::RenderExtViewerOSG::_init (const Config &Local) { osg::DisplaySettings *ds = osg::DisplaySettings::instance (); if (ds) { ds->setNumMultiSamples (config_to_int32 ("aa.samples", Local, 0)); } _viewerName = config_to_string ("portal.name", Local, _viewerName); _title = config_to_string ("window-title.value", Local, _title); const Boolean Fullscreen = config_to_boolean ("window.fullscreen", Local, False); const Boolean Centered = config_to_boolean ("window.center", Local, True); Int32 windowLeft = config_to_uint32 ("window.left", Local, 100); Int32 windowTop = config_to_uint32 ("window.top", Local, 100); const UInt32 WindowWidth = config_to_uint32 ("window.width", Local, 800); const UInt32 WindowHeight = config_to_uint32 ("window.height", Local, 600); const UInt32 Screen = config_to_uint32 ("window.screen", Local, 0); if (Fullscreen) { __init_viewer_fullscreen (Screen); } else { if (Centered) { __init_centered (Screen, WindowWidth, WindowHeight, windowLeft, windowTop); } __init_viewer_window (windowLeft, windowTop, WindowWidth, WindowHeight, Screen); } _log.info << "Viewer Info: "; if (Fullscreen) { _log.info << "Full Screen: "; } else { _log.info << WindowWidth << "x" << WindowHeight; if (Centered) { _log.info << " [Centered]"; } _log.info << " Corner: " << windowLeft << ", " << windowTop << " Screen: "; } _log.info << Screen << endl; }
void dmz::QtLogObserver::load_session () { if (_context) { Config session (get_session_config (DefaultName, _context)); QByteArray geometry (config_to_qbytearray ("geometry", session, saveGeometry ())); restoreGeometry (geometry); if (config_to_boolean ("window.visible", session, False)) { show (); } } }
// Object Observer Interface void dmz::RenderPluginDisableObjectIsect::create_object ( const UUID &Identity, const Handle ObjectHandle, const ObjectType &Type, const ObjectLocalityEnum Locality) { if (_isect) { Boolean *value (0); ObjectType current (Type); while (current && !value) { value = _isectTable.lookup (current.get_handle ()); if (!value) { Config data; if (current.get_config ().lookup_config ("render.isect", data)) { Boolean disable = config_to_boolean ("disable", data, False); value = new Boolean (disable); if (!_isectTable.store (current.get_handle () , value)) { delete value; value = 0; } } } current.become_parent (); } if (value && *value) { if (_isect->disable_isect (ObjectHandle) == 0) { *value = False; _log.error << "Unable to disable intersection for type: " << Type.get_name () << endl; } } } }
void dmz::AudioPluginObject::_init_sound_struct (Config &data, SoundDefStruct &ss) { ss.activateName = _rc.find_file (config_to_string ("activate-resource", data)); ss.deactivateName = _rc.find_file (config_to_string ("deactivate-resource", data)); ss.loopName = _rc.find_file (config_to_string ("looped-resource", data)); _lookup_sound_handles (ss); const String ScalarName (config_to_string ("scalar", data)); if (ScalarName) { ss.scalarAttributeHandle = activate_object_attribute (ScalarName, ObjectScalarMask); } ss.offset = config_to_float64 ("offset", data, ss.offset); ss.scale = config_to_float64 ("scale", data, ss.scale); ss.relative = config_to_boolean ("relative", data, ss.relative); }
void dmz::RenderModuleCoreOgreBasic::_init_resources (Config &local) { Config resourceList; if (local.lookup_all_config ("resources.resource", resourceList)) { ConfigIterator it; Config cd; Boolean done (!resourceList.get_first_config (it, cd)); while (!done) { String name; if (cd.lookup_attribute ("name", name)) { String type = config_to_string ("type", cd, "FileSystem"); String group = config_to_string ("group", cd, "General"); Boolean recursive = config_to_boolean ("recursive", cd, False); try { Ogre::ResourceGroupManager::getSingleton ().addResourceLocation ( name.get_buffer (), type.get_buffer (), group.get_buffer (), recursive); } catch (Ogre::Exception e) { _log.error << e.getFullDescription ().c_str () << endl; } } done = !resourceList.get_next_config (it, cd); } } }
void dmz::QtPluginGraph::_init (Config &local) { RuntimeContext *context (get_plugin_runtime_context ()); Definitions defs (context); _scene = new QGraphicsScene; _view = new QGraphicsView (_scene); _view->setAlignment (Qt::AlignLeft); // | Qt::AlignBottom); _typeSet = config_to_object_type_set ("set", local, context); if (_typeSet.get_count () == 0) { _log.info << "No object types specified. Using root type." << endl; _typeSet.add_object_type (defs.get_root_object_type ()); } activate_default_object_attribute (ObjectCreateMask | ObjectDestroyMask); Config attrList; if (local.lookup_all_config ("attribute", attrList)) { ConfigIterator it; Config attr; while (attrList.get_next_config (it, attr)) { const String Type = config_to_string ("type", attr).get_lower (); const String AttrName = config_to_string ("name", attr); if (AttrName) { if (Type == "link") { activate_object_attribute (AttrName, ObjectLinkMask | ObjectUnlinkMask); } else if (Type == "counter") { activate_object_attribute (AttrName, ObjectCounterMask); } else { _log.error << "Unknown attribute type: " << Type << endl; } } else { _log.error << "Attribute missing name." << endl; } } } _ascendingOrder = config_to_boolean ("ascending.value", local, _ascendingOrder); _maxCount = config_to_int32 ("start.value", local, _maxCount); _showPowerLaw = config_to_boolean ("power-law.show", local, _showPowerLaw); _powerStroke = config_to_qpen ("power-law.stroke", local, _powerStroke); _barStroke = config_to_qpen ("bar.stroke", local, _barStroke); _barFill = config_to_qbrush ("bar.fill", local, _barFill); _barWidth = config_to_int32 ("bar.width", local, _barWidth); _barHeight = config_to_int32 ("bar.height", local, _barHeight); _spaceWidth = config_to_int32 ("bar.space", local, _spaceWidth); _steps = config_to_int32 ("bar.steps", local, _steps); _yDivisions = config_to_int32 ("bar.divisions", local, _yDivisions); _yLabels = new QGraphicsTextItem*[_yDivisions]; for (Int32 ix = 0; ix < _yDivisions; ix++) { const Float32 Offset (-_barHeight * ((Float32)(ix + 1)) / (Float32)_yDivisions); _yLabels[ix] = new QGraphicsTextItem; _yLabels[ix]->setPlainText ( QString::number (100 * (ix +1) / _yDivisions) + QString ("%")); _yLabels[ix]->setZValue (1.0f); QRectF rect = _yLabels[ix]->boundingRect (); _yLabels[ix]->setPos (-5.0 - rect.width (), Offset - (rect.height () * 0.5f)); _scene->addItem (_yLabels[ix]); QGraphicsLineItem *line = new QGraphicsLineItem (-4.0, Offset, 0.0f, Offset); line->setZValue (1.0f); _scene->addItem (line); } }
void dmz::AudioModuleFMOD::_init (const Config &Local) { // Create a System object FMOD_RESULT createResult = FMOD::System_Create(&_system); _error_check ("Enabling FMOD", createResult); _dopplerScale = config_to_float32 ("dopplerScale.value", Local, _dopplerScale); _distanceFactor = config_to_float32 ("distanceFactor.value", Local, _distanceFactor); _rollOffScale = config_to_float32 ("rollOffScale.value", Local, _rollOffScale); _maxChannels = config_to_int32 ("maxChannels.value", Local, _maxChannels); _rightHandedCoordinates = config_to_boolean ("rightHandedCoordinate.value", Local, _rightHandedCoordinates); _forceFullDirectSoundHRTF = config_to_boolean ( "forceFullDirectSoundHRTF.value", Local, _forceFullDirectSoundHRTF); if (_system) { unsigned int version; FMOD_RESULT result =_system->getVersion (&version); FMOD_CAPS caps; FMOD_SPEAKERMODE speakermode; result = _system->getDriverCaps (0, &caps, 0, 0, &speakermode); _error_check ("Getting driver caps", result); result = _system->setSpeakerMode (speakermode); _error_check ("Setting speaker mode", result); if (caps & FMOD_CAPS_HARDWARE_EMULATED) { result = _system->setDSPBufferSize (1024, 10); _error_check ("Setting speaker mode", result); _log.warn << "Audio hardware is being emulated" << endl; } FMOD_INITFLAGS flags = FMOD_INIT_NORMAL; if (_rightHandedCoordinates) { flags |= FMOD_INIT_3D_RIGHTHANDED; } // Only enable Software HRTF emulation if we are on windows (and therefore // DirectSound is available) #ifdef _WIN32 if (_forceFullDirectSoundHRTF) { flags |= FMOD_INIT_DSOUND_HRTFFULL; } #endif result = _system->init (_maxChannels, flags, 0); if (result == FMOD_ERR_OUTPUT_CREATEBUFFER) { result = _system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO); _error_check ("Setting speaker mode to stereo", result); result = _system->init(_maxChannels, flags, 0); _error_check ("Initializing FMOD Sound System", result); } // _system->set3DSettings (_dopplerScale, _distanceFactor, _rollOffScale); set_mute_all_state (True); // Mute all sounds for now (creating the first listener // will unmute them) } _log.info << "AudioModuleFMOD Initialized" << endl; }
dmz::QtCanvasObjectText * dmz::QtPluginCanvasObjectBasic::_create_text_item ( ObjectStruct &os, QGraphicsItem *parent, const Config &Data) { QtCanvasObjectText *item (new QtCanvasObjectText (parent)); ConfigIterator it; Config cd; while (Data.get_next_config (it, cd)) { const String DataName (cd.get_name ().to_lower ()); if (DataName == "text") { String text (config_to_string (cd)); item->set_text (text.get_buffer ()); } else if (DataName == "textcolor") { item->set_text_color (config_to_qcolor (cd)); } else if (DataName == "outlinecolor") { item->set_outline_color (config_to_qcolor (cd)); } else if (DataName == "backgroundcolor") { item->set_background_color (config_to_qcolor (cd)); } else if (DataName == "enablebackground") { item->enable_background (config_to_boolean ("value", cd, true)); } else if (DataName == "alignment") { String alignmentName (config_to_string (cd).to_lower ()); if (alignmentName == "center") { item->set_alignment (Qt::AlignCenter); } else if (alignmentName == "right") { item->set_alignment (Qt::AlignRight); } else { item->set_alignment (Qt::AlignLeft); } } else if (DataName == "max-length") { item->set_max_length (config_to_int32 ("value", cd)); } else if (DataName == "translate") { Vector vec (config_to_vector (cd)); String itemName = config_to_string ("name", cd); if (itemName) { QGraphicsItem *img = os.itemTable.lookup (itemName); if (img) { QRectF rect = img->boundingRect (); Vector rectVec; if (vec.get_x () == 0) { rectVec.set_x (0); } else if (vec.get_x() > 0) { rectVec.set_x (rect.center ().x ()); } else { rectVec.set_x (-rect.center ().x ()); } if (vec.get_y () == 0) { rectVec.set_y (0); } else if (vec.get_y () > 0) { rectVec.set_y (rect.center ().y ()); } else { rectVec.set_y (-rect.center ().y ()); } vec += rectVec; item->setPos (vec.get_x (), vec.get_y ()); } } else { item->translate (vec.get_x (), vec.get_y ()); } } else if (DataName == "scale") { Vector vec (config_to_vector (cd)); if (vec.get_x () && vec.get_y ()) { item->scale (vec.get_x (), vec.get_y ()); } } } return item; }
dmz::QtCanvasObjectGroup * dmz::QtPluginCanvasObjectBasic::_create_item ( ObjectStruct &os, QGraphicsItem *parent, const Config &ItemList, HashTableStringTemplate<String> &table) { QtCanvasObjectGroup *group (0); if (parent) { group = new QtCanvasObjectGroup (parent); QGraphicsItem *item (0); ConfigIterator it; Config cd; Float32 z (1.0); while (ItemList.get_next_config (it, cd)) { const String DataName (cd.get_name ().to_lower ()); const String ItemName (config_to_string ("name", cd)); const Boolean Isect (config_to_boolean ("isect", cd, True)); if (DataName == "image") { item = _create_image_item (os, group, cd, table); if (Isect) { item->setData (QtCanvasObjectHandleIndex, (quint64)os.ObjHandle); } } else if (DataName == "text") { item = _create_text_item (os, group, cd); if (Isect) { item->setData (QtCanvasObjectHandleIndex, (quint64)os.ObjHandle); } } else if (DataName == "group") { item = _create_item (os, group, cd, table); } if (item) { item->setFlag (QGraphicsItem::ItemIgnoresParentOpacity, true); item->setFlag (QGraphicsItem::ItemDoesntPropagateOpacityToChildren, true); item->setZValue (z++); if (ItemName) { String name (ItemName); name << "." << os.ObjHandle; item->setData (QtCanvasObjectNameIndex, name.get_buffer ()); os.itemTable.store (ItemName, item); } } } } return group; }
dmz::RenderPluginObjectOSG::DefStruct * dmz::RenderPluginObjectOSG::_create_def_struct (const ObjectType &Type) { DefStruct *result = _defTable.lookup (Type.get_handle ()); Config modelList; if (!result && Type.get_config ().lookup_all_config ("render.model", modelList)) { result = new DefStruct; if (_defTable.store (Type.get_handle (), result)) { _typeTable.store (Type.get_handle (), result); ConfigIterator it; Config model; unsigned int place (1); StateStruct *currentState (0); while (modelList.get_next_config (it, model)) { const String ResourceName (config_to_string ("resource", model)); const Boolean NoModel (config_to_boolean ("none", model)); Mask state; String stateName; const Boolean StateNameFound (model.lookup_attribute ("state", stateName)); if (StateNameFound) { _defs.lookup_state (stateName, state); } if (!StateNameFound || state) { ModelStruct *ms = (NoModel ? &_noModel : _load_model (ResourceName)); if (ms) { unsigned int switchPlace (StateNameFound ? place : 0); if (StateNameFound) { place++; } if (((switchPlace + 1) > result->model->getNumChildren ()) || !result->model->getChild (switchPlace)) { result->model->insertChild (switchPlace, ms->model.get ()); if (switchPlace) { StateStruct *ss (new StateStruct (switchPlace, state)); if (currentState) { currentState->next = ss; currentState = ss; } else { result->stateMap = currentState = ss; } } } } } } } else { delete result; result = 0; } } return result; }
void dmz::QtModuleCanvasBasic::_init (Config &local) { qwidget_config_read ("widget", local, this); const Int32 MinX = config_to_int32 ("scene.min.x", local, -50000); const Int32 MinY = config_to_int32 ("scene.min.y", local, -50000); const Int32 MaxX = config_to_int32 ("scene.max.x", local, 100000); const Int32 MaxY = config_to_int32 ("scene.max.y", local, 100000); _scene.setSceneRect (QRectF (MinX, MinY, MaxX - MinX, MaxY - MinY)); //_scene.setItemIndexMethod (QGraphicsScene::NoIndex); _canvas = new QtCanvasView (this); _canvas->setTransformationAnchor (QGraphicsView::AnchorViewCenter); _canvas->setResizeAnchor (QGraphicsView::AnchorViewCenter); const Boolean ScrollBars = config_to_boolean ("scrollbars.value", local, False); if (!ScrollBars) { _canvas->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff); _canvas->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff); } _canvas->setMouseTracking (true); //_canvas->setDragMode (QGraphicsView::ScrollHandDrag); setObjectName (get_plugin_name ().get_buffer ()); _scene.setObjectName (objectName () + "Scene"); _canvas->setObjectName (objectName () + "View"); _canvas->setScene (&_scene); //_canvas->setBackgroundBrush (QPixmap ("/assets/images/background1.png")); QVBoxLayout *layout (new QVBoxLayout ()); layout->addWidget (_canvas); setLayout (layout); setMouseTracking (true); _inputModuleName = config_to_string ("module.input.name", local); if (_canvas) { _keyEvent.set_source_handle (get_plugin_handle ()); _mouseEvent.set_source_handle (get_plugin_handle ()); String value; Boolean enableOpenGL (False); if (local.lookup_attribute ("canvas.opengl", value)) { if (value.to_lower () == "true") { enableOpenGL = True; } } Boolean enableAntialiasing (False); if (local.lookup_attribute ("canvas.antialiasing", value)) { if (value.to_lower () == "true") { enableAntialiasing = True; } } if (enableOpenGL) { _canvas->setViewport (new QGLWidget (QGLFormat (QGL::SampleBuffers))); _log.info << "OpenGL enabled" << endl; } if (enableAntialiasing) { if (enableOpenGL) { _canvas->setRenderHint (QPainter::HighQualityAntialiasing, true); _log.info << "High Quality Antialiasing enabled" << endl; } else { _canvas->setRenderHint (QPainter::Antialiasing, true); _log.info << "Antialiasing enabled" << endl; } } if (local.lookup_attribute ("canvas.textantialiasing", value)) { if (value.to_lower () == "true") { _canvas->setRenderHint (QPainter::TextAntialiasing, true); _log.info << "Test Antialiasing enabled" << endl; } } _canvas->setRenderHint (QPainter::SmoothPixmapTransform, true); set_zoom_min_value (config_to_float32 ("canvas.zoom.min", local, _zoomMin)); set_zoom_max_value (config_to_float32 ("canvas.zoom.max", local, _zoomMax)); set_zoom_step_value (config_to_float32 ("canvas.zoom.step", local, _zoomStep)); set_zoom (config_to_float32 ("canvas.zoom.default", local, _zoomDefault)); } }