VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
setStatePropertyDialog.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
8 
12 
13 #pragma once
14 
15 #if !defined(Q_MOC_RUN)
22 #endif
23 
24 #include <QLabel>
25 #include <QGridLayout>
26 
27 namespace makVrf
28 {
32  {
33  Q_OBJECT
34  public:
35  //CTOR
36  DtSetStatePropertyDialog(makVrv::DtDe& de, QWidget* parent, const DtString& property,
37  const Qt::WindowFlags& flags = 0);
38 
39  //DTOR
40  virtual ~DtSetStatePropertyDialog();
41 
42  protected:
43  virtual void setupGui(const std::vector<makVrv::DtSimEntry*>& data);
44  virtual QSize canvasSize();
45 
48  template<typename StateType>
49  void setupGui(const std::vector<makVrv::DtSimEntry*>& data)
50  {
52 
53  std::vector<makVrv::DtSimEntry*>::const_iterator iter = data.begin();
54  bool merge = false;
55  std::vector<DtString> props;
56 
57  myProperty.tokenize(';', props);
58 
59  clearProperties();
60 
61  bool allAggregate = true;
62  myStateProperties = DtRwProperties("");
63  myParameterData = DtRwProperties("");
64 
65  if(data.size() == 0)
66  {
68 
69  if (myDefaultPlatformFile.length())
70  {
71  DtObjectType objectType;
72 
73  myIgnoreMaximum = true;
74 
75  objectType = myDefaultPlatformFile.c_str();
76 
77  if (objectType != DtObjectType())
78  {
80  DtVrfModelSetManager::instance(myDe).statePropertiesFor(objectType, myStateProperties);
81  DtVrfModelSetManager::instance(myDe).parameterPropertiesFor(objectType, myParameterData);
82  }
83  else
84  {
86  DtVrfModelSetManager::instance(myDe).statePropertiesForPlatform(myDefaultPlatformFile, myStateProperties);
87  DtVrfModelSetManager::instance(myDe).parameterPropertiesForPlatform(myDefaultPlatformFile, myParameterData);
88  myUsingGeneric = true;
89  }
90  }
91  }
92  else
93  {
94  if (myInvalidSelectionLabel)
95  {
96  delete myInvalidSelectionLabel;
97  myInvalidSelectionLabel = 0;
98  }
99 
100  while (iter != data.end())
101  {
102  if (!DtAggregateRollUpManager::instance(myDe).hasStateProperties((*iter)->id()))
103  {
104  allAggregate = false;
105  break;
106  }
107 
108  ++iter;
109  }
110 
111  if (allAggregate)
112  {
113  DtAggregateRollUpManager::instance(myDe).statePropertiesFor(data, myStateProperties);
114  DtAggregateRollUpManager::instance(myDe).parameterData(data, myParameterData);
115  }
116  else
117  {
118  iter = data.begin();
119  while (iter != data.end())
120  {
122  {
123  if (iter == data.begin())
124  {
125  DtAggregateRollUpManager::instance(myDe).statePropertiesFor((*iter)->id(), myStateProperties);
126  DtAggregateRollUpManager::instance(myDe).parameterData((*iter)->id(), myParameterData);
127  }
128  else
129  {
130  DtRwProperties stateProperties("");
131  DtRwProperties parameterData("");
132 
133  DtAggregateRollUpManager::instance(myDe).statePropertiesFor((*iter)->id(), stateProperties);
134  myStateProperties.merge(stateProperties, DtPropertyInterface::RollUp);
135  DtAggregateRollUpManager::instance(myDe).parameterData((*iter)->id(), parameterData);
136  myParameterData.merge(parameterData, DtPropertyInterface::RollUp);
137  }
138  }
139  else
140  {
141  DtVrfObjectDataState* state = findStateFor<DtVrfObjectDataState*>(*iter);
142 
143  if(state)
144  {
145  if (iter == data.begin())
146  {
147  myStateProperties = state->myStateProperties;
148  }
149  else
150  {
151  myStateProperties.merge(state->myStateProperties, DtPropertyInterface::RollUp);
152  }
153  }
154  }
155 
156  ++iter;
157  }
158  }
159  }
160 
161  if (myStateProperties.registry().registryData().size())
162  {
163  int iLimit = props.size();
164  int i;
165  for (i = 0; i < iLimit; i++)
166  {
167  DtString propString(props[i].c_str());
168  bool hasStar = false;
169  int index = 0;
170 
171  if (propString[0] == '+')
172  {
173  propString = DtString(&propString.c_str()[1], propString.length() - 1);
174  }
175 
176  QString propStr(propString.c_str());
177 
178  if ((index = propStr.indexOf('*')) == propStr.length() - 1)
179  {
180  hasStar = true;
181  propStr[index] = 0;
182  }
183 
184  DtReaderWriter* rw = myStateProperties.findVariableBinding(propStr.toStdString().c_str());
185  DtPropertyInterface* prop = dynamic_cast<DtPropertyInterface*>(rw);
186 
187  if (prop)
188  {
189  if (hasMoreThanDefaultValueInRegistry(rw))
190  {
191  myScrollArea->setFrameShape(QFrame::NoFrame);
192  myScrollArea->setFrameShadow(QFrame::Plain);
193  }
194 
195  addProperty(prop, merge, hasStar);
196  }
197  }
198 
199  if(myPropertyItems.size() == 0)
200  {
202  setupGuiWhenSelectionInvalid();
203  }
204  }
205  else
206  {
207  setupGuiWhenNoSelection();
208  }
209  }
210 
213  virtual void setupGuiWhenNoSelection();
214 
217  virtual void setupGuiWhenSelectionInvalid();
218 
219  protected:
220 
224  };
225 
227  {
228  public:
229  DtSetStatePropertyDialogCreator(makVrv::DtDe&, const DtString& prop, const DtString& defaultPlatformFile = "");
230 
231  virtual DtTaskSetDialogInterface* create(makVrv::DtDe&, QWidget* parent);
232  bool supportsType(makVrv::DtDe&, const DtSetMessageType&, const DtSimStatement*) const;
233 
235  virtual bool isValidFor(makVrv::DtDe& de, const makVrv::DtSelectionManager::IdSet& ids,
236  int partOfPlanDialog) const;
237 
238  protected:
240  virtual DtTaskSetDialogInterface* createDialog(makVrv::DtDe&, QWidget* parent);
241 
243  virtual bool checkProperties(const DtString&, const DtString&) const;
244  virtual DtString stripModifiers(const DtString&) const;
245 
246  protected:
250  };
251 }
QLabel * myInvalidSelectionLabel
Label displaying text indicating currently selected simulation objects are not valid for this propert...
Definition: setStatePropertyDialog.h:223
DtString myDefaultPlatformFile
Definition: setStatePropertyDialog.h:248
Definition: taskSetDialogInterface.h:65
virtual void statePropertiesFor(const makVrv::DtStateView< makVrv::DtVrlinkSimulatedBaseState > *, DtRwProperties &) const
Returns the rolled up state properties or the state properties for the individual (if this is not a p...
SpecificRwType * addProperty(DtReaderWriter &properties, const DtString &propertyName)
Adds a property with the specified name to the given set of properties. SpecificRwType must be a subc...
DtString myProperty
Definition: setStatePropertyDialog.h:247
Definition: taskSetDialogInterface.h:84
Definition: readerWriter.h:85
virtual void parameterPropertiesFor(const DtEntityType &, DtRwProperties &)
If there is parameter properties in the .ope file referenced by this entity, return them...
Definition: propertyInterface.h:62
virtual void statePropertiesFor(const DtEntityType &, DtRwProperties &) const
If there are state properties in the .ope file referenced by this entity, return them.
makVrv::DtDe & myDe
Definition: setStatePropertyDialog.h:249
static DtAggregateRollUpManager & instance(makVrv::DtDe &de)
Returns instance of the messager.
Interface class used to define minimal interface for a property. The DtPropertyInterface class provid...
Definition: propertyInterface.h:53
virtual bool hasStateProperties(makVrv::DtUniqueID) const
Returns true if the aggregate with the given unique ID has, or has any subordinates with...
This class is the base for setting state properties. In and of itself it does not populate itself wit...
Definition: setStatePropertiesDialog.h:77
Definition: setStatePropertyDialog.h:226
virtual bool merge(const DtPropertyInterface &target, MergeFlags, const DtMergePath &path=DtMergePath(), const std::set< DtString > &ignore=std::set< DtString >())
Takes the contents of the supplied properties and merges with the following rules if replace is false...
virtual void setupGui(const std::vector< makVrv::DtSimEntry * > &data)
Initializes state and parameter data based on selection.
virtual void statePropertiesForPlatform(const DtString &, DtRwProperties &) const
Returns a copy of the state properties for the given platform, if it exists.
virtual void parameterData(makVrv::DtStateView< makVrv::DtVrlinkSimulatedBaseState > *, DtRwProperties &) const
Given the state, if the state is an aggregate and has subordinates, return a total of all the paramet...
Sets up the set dialog to be able to change all state properties. If multiple items are selected only...
Definition: setStatePropertyDialog.h:31
void setupGui(const std::vector< makVrv::DtSimEntry * > &data)
If there is a single entry, find it&#39;s location and convert to local to set. This version can be given...
Definition: setStatePropertyDialog.h:49
class DtSimStatement:
Definition: simStatement.h:38
DtRwProperties myStateProperties
Definition: vrfObjectDataState.h:108
A list of properties. A DtPropertyInterface object that is a specialized version of DtRwVariableBindi...
Definition: rwProperties.h:122
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:72
virtual void parameterPropertiesForPlatform(const DtString &, DtRwProperties &) const
Returns a copy of the parameter properties for the given platform, if it exists.
#define DT_DLL_VRFGUITASKSETQT
Definition: vrfGuiTaskSetQt.h:22
std::set< DtUniqueID > IdSet
Definition: DtSelectionManager.h:32
static DtVrfModelSetManager & instance(makVrv::DtDe &de)
Returns instance of the messager.
Definition: vrfObjectDataState.h:87

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)