OpenStudio:model_editor
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Slots | Signals | Public Member Functions | Public Attributes | Protected Types | Protected Slots | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
InspectorGadget Class Reference

#include <InspectorGadget.hpp>

+ Inheritance diagram for InspectorGadget:

Public Types

enum  FLOAT_DISPLAY { FIXED, SCIENTIFIC, UNFORMATED }
 
enum  UNIT_SYSTEM { SI, IP }
 

Public Slots

void addExtensible ()
 
void clear (bool recursive)
 removes everything from the IG More...
 
void commentConfig (bool showComments)
 show/hide comment fields More...
 
void createAllFields ()
 
void IGautosize (bool toggled)
 
void IGcommentChanged (const QString &)
 
void IGdefaultRemoved (const QString &)
 changes the color of widgets More...
 
void IGvalueChanged (const QString &)
 
void rebuild (bool recursive)
 lays out the last object again. More...
 
void removeExtensible ()
 
void setPrec ()
 
void setRecursive (bool recursive)
 
void showAllFields (bool state)
 
void toggleUnits (bool displayIP)
 

Signals

void dirty ()
 
void nameChanged (QString)
 
void toggleUnitsClicked (bool)
 
void workspaceObjectRemoved (const openstudio::Handle &)
 

Public Member Functions

void layoutModelObj (openstudio::WorkspaceObject &workObj, bool force=false, bool recursive=true, bool locked=false, bool hideChildren=false)
 lays out the WorkspaceObj More...
 
void removeWorkspaceObject (const openstudio::Handle &)
 
void setPrecision (unsigned int prec, FLOAT_DISPLAY dispType)
 sets the display precision for number fields More...
 
void setUnitSystem (const UNIT_SYSTEM unitSystem)
 
virtual ~InspectorGadget ()
 

Public Attributes

InspectorGadgetparent
 

Protected Types

typedef std::map
< openstudio::model::ModelObject,
InspectorGadget * > 
MODELMAP
 

Protected Slots

void onTimeout ()
 
void onWorkspaceObjectChanged ()
 
void onWorkspaceObjectRemoved (const openstudio::Handle &)
 

Protected Member Functions

void checkRemoveBtn (QPushButton *btn)
 
void connectWorkspaceObjectSignals () const
 
void createExtensibleToolBar (QVBoxLayout *layout,*parent, const openstudio::IddObjectProperties &props)
 
void disconnectWorkspaceObjectSignals () const
 
 InspectorGadget (openstudio::WorkspaceObject &workspaceObj, int indent, ComboHighlightBridge *bridge, int precision, FLOAT_DISPLAY style, bool showComments, bool showAllFields, bool recursive, bool locked)
 constructor More...
 
void layoutComboBox (QVBoxLayout *layout,*parent, openstudio::IddField &field, openstudio::IddFieldProperties &properties, const std::string &name, const std::string &curVal, int index, const std::string &comment, bool exists)
 
virtual void layoutItems (QVBoxLayout *layout,*parent, bool hideChildren=false)
 
void layoutText (QVBoxLayout *layout,*parent, openstudio::model::AccessPolicy::ACCESS_LEVEL level, const std::string &val, int index, const std::string &comment)
 
virtual void layoutText (QVBoxLayout *layout,*parent, openstudio::IddField &field, openstudio::model::AccessPolicy::ACCESS_LEVEL level, const std::string &name, const std::string &curVal, int index, const std::string &comment, bool exists, bool number, bool real=false)
 
void parseItem (QVBoxLayout *layout,*parent, openstudio::IddField &field, const std::string &name, const std::string &curVal, openstudio::model::AccessPolicy::ACCESS_LEVEL level, int index, const std::string &comment, bool exists)
 
void stripchar (std::string &strip, char c)
 

Static Protected Member Functions

static openstudio::LogChannel logChannel ()
 

Protected Attributes

MODELMAP m_childMap
 
ComboHighlightBridgem_comboBridge
 
m_deleteHandle
 
QErrorMessage * m_errorMessage
 
FLOAT_DISPLAY m_floatDisplayType
 
int m_indent
 
bool m_lastHideChildren
 
bool m_lastLocked
 
QVBoxLayout * m_layout
 
bool m_locked
 
boost::optional< int > m_nameIndex
 
bool m_objectHasName
 
unsigned int m_precision
 
bool m_recursive
 
QScrollArea * m_scroll
 
bool m_showAllFields
 
bool m_showComments
 
bool m_stretch
 
UNIT_SYSTEM m_unitSystem
 
openstudio::OptionalWorkspaceObject m_workspaceObj
 
bool m_workspaceObjectChanged
 

Static Protected Attributes

static const char * s_indexSlotName
 

Detailed Description

InspectorGadget will take a ModelObejct (or WorkspaceObject) and display it attributes.

InsepctorGadget interrogates objects and displays their fields/attributes based on the values contained in the AccessPolicyStore. When a new model is passed into the IG, it will delete all its old QWidgets and create new ones.

AccessPolicy::FREE Real and Integers get displayed as spinboxes AccessPolicy::LOCKED Real and Integer and all Alpha get displayed as labels. Choice is displayed as a ComboBox

Member Typedef Documentation

typedef std::map<openstudio::model::ModelObject,InspectorGadget*> InspectorGadget::MODELMAP
protected

Member Enumeration Documentation

Enumerator
FIXED 
SCIENTIFIC 
UNFORMATED 
Enumerator
SI 
IP 

Constructor & Destructor Documentation

virtual InspectorGadget::~InspectorGadget ( )
virtual

destructor

The really shouldn't need to call this, the parent Widget ought to delete the IG.

InspectorGadget::InspectorGadget ( openstudio::WorkspaceObject &  workspaceObj,
int  indent,
ComboHighlightBridge bridge,
int  precision,
FLOAT_DISPLAY  style,
bool  showComments,
bool  showAllFields,
bool  recursive,
bool  locked 
)
protected

constructor

Parameters
workspaceObjthe current workspace
indentindentation for the child frame
bridgepass in a bridge here if you need signals to get out of the IG (or the IG's children)
precisionsets the number of sigfigs to display
stylesets the style of floating point display
showCommentsshow or hide idf comment field
showAllFieldsshow or hide all fields
recursiverecursively create and show fields
lockedif true, lock all fields the ACCESS_POLICY sets to FREE If model has children, those children will get their own InspectorGadget, indent will be passed again to that constructor so the frames will nest.

Member Function Documentation

void InspectorGadget::addExtensible ( )
slot
void InspectorGadget::checkRemoveBtn ( QPushButton *  btn)
protected
void InspectorGadget::clear ( bool  recursive)
slot

removes everything from the IG

Parameters
recursiveif true, deletes the children. Removes all the information from the IG. Call this if the object being inspected gets deleted.
void InspectorGadget::commentConfig ( bool  showComments)
slot

show/hide comment fields

Parameters
showCommentsif true, show comments, if false, hide them

IdfObjects have comments about their fields. (and about themselves) This function allows you to toggle weather or not you wish IG to show those comments. The Default is not to show them.

void InspectorGadget::connectWorkspaceObjectSignals ( ) const
protected
void InspectorGadget::createAllFields ( )
slot

Create all fields in the IDD. IDFObjects can be instantiated with some IDD fields null. (they are not 'required' fields. Once you call this function, all fields possible will be created and presented to the user.

void InspectorGadget::createExtensibleToolBar ( QVBoxLayout *  layout,
parent,
const openstudio::IddObjectProperties &  props 
)
protected
void InspectorGadget::dirty ( )
signal

This signal is emitted when the IG changes the model. If your program uses IG, then you should connect to this so that you know if the file needs saving or not

void InspectorGadget::disconnectWorkspaceObjectSignals ( ) const
protected
void InspectorGadget::IGautosize ( bool  toggled)
slot
void InspectorGadget::IGcommentChanged ( const QString &  )
slot
void InspectorGadget::IGdefaultRemoved ( const QString &  )
slot

changes the color of widgets

When widget are built, if the Field is required but there is no value and no default value (which in a way, is bad idf) the IG will put 0 or 0.0 in there for you, but color it red to point out that you should address this. Once you set a value, this function is automatically called for you and sets the color back to black.

void InspectorGadget::IGvalueChanged ( const QString &  )
slot
void InspectorGadget::layoutComboBox ( QVBoxLayout *  layout,
parent,
openstudio::IddField &  field,
openstudio::IddFieldProperties &  properties,
const std::string &  name,
const std::string &  curVal,
int  index,
const std::string &  comment,
bool  exists 
)
protected
virtual void InspectorGadget::layoutItems ( QVBoxLayout *  layout,
parent,
bool  hideChildren = false 
)
protectedvirtual
Parameters
layoutthe layout to attach the items to
parentthe widget that owns all the items that will be created.
hideChildrenshow or hide children (hidden by default)

This function is a big loop over the attributes or fields*, it does the core of the work for deciding what exact widgets we should build. IGChildFrame uses this function to fill out its child frame.

It depends on weather or not you called layoutModel with a ModelObject or a WorkspaceObj

void InspectorGadget::layoutModelObj ( openstudio::WorkspaceObject &  workObj,
bool  force = false,
bool  recursive = true,
bool  locked = false,
bool  hideChildren = false 
)

lays out the WorkspaceObj

Parameters
workObjthe current workspace
forceforces a layout even if we just laid out this modelObj
recursiveif true, delete the children and rebuild them
lockedset all the FREE items to LOCKED
hideChildrenshows or hides the children

This call lays out a model. It will ask the Model for its AttributeVector and use that to decide what to display. If the ModelObject is a ParentChildObejct, then this function will create an IGChildFrame and that child calls layoutItems for its frame.

Calling this method a 2nd time will delete everything that was previously built and regenerate the QWidgets.

Recursive only effects anything if you are sending in the same workObj, if you pick a different one, the children are ALWAYS deleted and rebuilt. (because they are different children!)

If you are calling this from a place where the user should not be allowed to edit the fields, set the lock parameter to true

void InspectorGadget::layoutText ( QVBoxLayout *  layout,
parent,
openstudio::model::AccessPolicy::ACCESS_LEVEL  level,
const std::string &  val,
int  index,
const std::string &  comment 
)
protected
virtual void InspectorGadget::layoutText ( QVBoxLayout *  layout,
parent,
openstudio::IddField &  field,
openstudio::model::AccessPolicy::ACCESS_LEVEL  level,
const std::string &  name,
const std::string &  curVal,
int  index,
const std::string &  comment,
bool  exists,
bool  number,
bool  real = false 
)
protectedvirtual
static openstudio::LogChannel InspectorGadget::logChannel ( )
inlinestaticprotected
void InspectorGadget::nameChanged ( QString  )
signal
void InspectorGadget::onTimeout ( )
protectedslot
void InspectorGadget::onWorkspaceObjectChanged ( )
protectedslot
void InspectorGadget::onWorkspaceObjectRemoved ( const openstudio::Handle &  )
protectedslot
void InspectorGadget::parseItem ( QVBoxLayout *  layout,
parent,
openstudio::IddField &  field,
const std::string &  name,
const std::string &  curVal,
openstudio::model::AccessPolicy::ACCESS_LEVEL  level,
int  index,
const std::string &  comment,
bool  exists 
)
protected
void InspectorGadget::rebuild ( bool  recursive)
slot

lays out the last object again.

Parameters
recursiveif true, apply the change to the children Use this if you change a config parameter that controls how the layout happens.
void InspectorGadget::removeExtensible ( )
slot
void InspectorGadget::removeWorkspaceObject ( const openstudio::Handle &  )
void InspectorGadget::setPrec ( )
slot
void InspectorGadget::setPrecision ( unsigned int  prec,
FLOAT_DISPLAY  dispType 
)

sets the display precision for number fields

Parameters
precthe # of significant figures to display
dispTypehow to format the floating point number

If you pass in a zero to this function, IG will not format the number in anyway, meaning you will see exactly the string that was typed into the IDF/OSM file. (Default behavior) If you pass in a non zero number, all number fields will display that number of significant figures in scientific notation.

void InspectorGadget::setRecursive ( bool  recursive)
slot
void InspectorGadget::setUnitSystem ( const UNIT_SYSTEM  unitSystem)
void InspectorGadget::showAllFields ( bool  state)
slot
void InspectorGadget::stripchar ( std::string &  strip,
char  c 
)
protected
void InspectorGadget::toggleUnits ( bool  displayIP)
slot
void InspectorGadget::toggleUnitsClicked ( bool  )
signal
void InspectorGadget::workspaceObjectRemoved ( const openstudio::Handle &  )
signal

Member Data Documentation

MODELMAP InspectorGadget::m_childMap
protected
ComboHighlightBridge* InspectorGadget::m_comboBridge
protected
* InspectorGadget::m_deleteHandle
protected
QErrorMessage* InspectorGadget::m_errorMessage
protected
FLOAT_DISPLAY InspectorGadget::m_floatDisplayType
protected
int InspectorGadget::m_indent
protected
bool InspectorGadget::m_lastHideChildren
protected
bool InspectorGadget::m_lastLocked
protected
QVBoxLayout* InspectorGadget::m_layout
protected
bool InspectorGadget::m_locked
protected
boost::optional<int> InspectorGadget::m_nameIndex
protected
bool InspectorGadget::m_objectHasName
protected
unsigned int InspectorGadget::m_precision
protected
bool InspectorGadget::m_recursive
protected
QScrollArea* InspectorGadget::m_scroll
protected
bool InspectorGadget::m_showAllFields
protected
bool InspectorGadget::m_showComments
protected
bool InspectorGadget::m_stretch
protected
UNIT_SYSTEM InspectorGadget::m_unitSystem
protected
openstudio::OptionalWorkspaceObject InspectorGadget::m_workspaceObj
protected
bool InspectorGadget::m_workspaceObjectChanged
protected
InspectorGadget* InspectorGadget::parent

constructor

Parameters
parentThe GUI object that owns IG
indentThe indentation for IGChildFrame
bridgepass in a bridge here if you need signals to get out of the IG (or the IG's children)
See also
IGChildFrame
layoutModel
const char* InspectorGadget::s_indexSlotName
staticprotected