Show how to add a shared display unit setting (Mils Orientation).
This example show how to add a custom "Orientation" unit converter. A new class DtMilsConverter that derived from DtOrientationUnitConverter class is created. That class implement the necessary functions to do the needed units conversion. Once created the new converter is added to the DtDisplayUnitsSettingsManager.
This example is a plug-in. You can run it by running ./bin64/exampleMilUnits_stealth.bat (on Windows from cmd.exe) or ./bin64/exampleMilUnits_stealth.sh (on Linux). Menu "Settings->Display...", select "Display Units Settings", the new "Mils" unit was added to "Orientation" drop down list. For more information about running examples, please see Running Applications and Examples.
#ifndef exampleMilUnitsPlugin_H_
#define exampleMilUnitsPlugin_H_
#ifdef _WIN32
#ifdef EXAMPLEMILUNITSPLUGIN_EXPORTS
#define DT_DLL_EXAMPLEMILUNITSPLUGIN __declspec ( dllexport )
#else
#define DT_DLL_EXAMPLEMILUNITSPLUGIN __declspec ( dllimport )
#endif
#else
#define DT_DLL_EXAMPLEMILUNITSPLUGIN
#endif
#endif
#include <matrix/vlMath.h>
{
return true;
}
{
namespace vrvExampleMilUnitsPlugin
{
inline double DtRad2Mil(double rad)
{
return ((rad / M_PI) * 3200.);
}
inline double DtMil2Rad(double mil)
{
return ((mil * M_PI) / 3200.0);
}
class DtMilsConverter : public DtOrientationUnitConverter
{
public:
DtMilsConverter()
: DtOrientationUnitConverter( UnitsMils )
{
}
~DtMilsConverter()
{
}
double radiansToLocal( double radians ) const
{
return DtRad2Mil(radians);
}
double localToRadians( double local ) const
{
return DtMil2Rad(local);
}
DtUnitConverter* clone() const
{
return new DtMilsConverter();
}
};
void installUnitConverter(DtDe& de)
{
de.sharedState().coordinateSystem().units().addUnitConverter(
DtDisplayUnitsSettingsRecord::Orientation, UnitsMils,
new DtMilsConverter() );
{
DtWriteSettingsLock<DtSharedDisplayUnitsSettings>
if (writeSettings->getUnitAttributes(DtDisplayUnitsSettingsRecord::Orientation, attr))
{
attr.push_back(DtSharedDisplayUnitsSettings::UnitEntry(
writeSettings->setUnitAttributes(DtDisplayUnitsSettingsRecord::Orientation, attr);
}
}
}
{
if (de.isInMasterMode())
{
de.signal_initializeDefaultState.connect(boost::bind(
&installUnitConverter, std::ref(de) ));
}
}
}
}
Contains the DtCoordinateDisplayCollection class declaration.
Contains makVrv::DtDe class.
#define DT_DE_INIT_ONCE(de)
This macro is called by modules in their init() function. This macro ensures that the module is only ...
Definition DtDe.h:30
Contains makVrv::DtDeSharedState class.
Contains the DtDisplayUnitsSettingsManager class declaration.
Contains the DtDisplayUnitsSettingsRecord class declaration.
Contains the DtSharedDisplayUnitsSettings class declaration.
Contains the DtUnitConverterCollection class declaration.
OrientationUnits
Enumeration of the different orientation units.
Definition DtDisplayUnitsSettingsRecord.h:103
@ OrientationUserStart
Definition DtDisplayUnitsSettingsRecord.h:107
virtual void setAutoSave(bool doit)
Sets whether autosave is enabled for the settings manager. If autosave is enabled,...
Definition DtBaseSettingsManager.h:75
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer,...
Definition DtDe.h:77
static DtDisplayUnitsSettingsManager & instance(DtDe &de)
Get an instance of the settings manager.
std::vector< UnitEntry > Units
A vector of unit names and unit notations.
Definition DtSharedDisplayUnitsSettings.h:199
static DtSharedSettingsManager & instance(DtDe &)
Get an instance of the shared settings manager from the DtDe;.
static DtUnicode tr(const char *ascii)
Definition DtUnicode.h:92
Contains DLL export macros.
DT_DE_PLUGIN_EXPORT_MACRO bool initDeModule(makVrv::DtDe *de)
Definition DtAddPropsRuleRecord.h:20
DT_DLL_EXAMPLEMILUNITSPLUGIN void init(DtDe &anIG)
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16