VR-Forces 4.7 Class Documentation
 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 
21 #include <QLabel>
22 #include <QGridLayout>
23 
24 namespace makVrf
25 {
29  {
30  Q_OBJECT
31  public:
32  //CTOR
33  DtSetStatePropertyDialog(makVrv::DtDe& de, QWidget* parent, const DtString& property,
34  const Qt::WindowFlags& flags = 0);
35 
36  //DTOR
37  virtual ~DtSetStatePropertyDialog();
38 
39  protected:
40  virtual void setupGui(const std::vector<makVrv::DtSimEntry*>& data);
41  virtual QSize canvasSize();
42 
45  template<typename StateType>
46  void setupGui(const std::vector<makVrv::DtSimEntry*>& data)
47  {
49 
50  std::vector<makVrv::DtSimEntry*>::const_iterator iter = data.begin();
51  bool merge = false;
52  std::vector<DtString> props;
53 
54  myProperty.tokenize(';', props);
55 
56  clearProperties();
57 
58  bool allAggregate = true;
59  myStateProperties = DtRwProperties("");
60  myParameterData = DtRwProperties("");
61 
62  if(data.size() == 0)
63  {
65 
66  if (myDefaultPlatformFile.length())
67  {
68  DtObjectType objectType;
69 
70  myIgnoreMaximum = true;
71 
72  objectType = myDefaultPlatformFile.c_str();
73 
74  if (objectType != DtObjectType())
75  {
77  DtVrfModelSetManager::instance(myDe).statePropertiesFor(objectType, myStateProperties);
78  DtVrfModelSetManager::instance(myDe).parameterPropertiesFor(objectType, myParameterData);
79  }
80  else
81  {
83  DtVrfModelSetManager::instance(myDe).statePropertiesForPlatform(myDefaultPlatformFile, myStateProperties);
84  DtVrfModelSetManager::instance(myDe).parameterPropertiesForPlatform(myDefaultPlatformFile, myParameterData);
85  myUsingGeneric = true;
86  }
87  }
88  }
89  else
90  {
91  if (myInvalidSelectionLabel)
92  {
93  delete myInvalidSelectionLabel;
94  myInvalidSelectionLabel = 0;
95  }
96 
97  while (iter != data.end())
98  {
100  {
101  allAggregate = false;
102  break;
103  }
104 
105  ++iter;
106  }
107 
108  if (allAggregate)
109  {
110  DtAggregateRollUpManager::instance(myDe).statePropertiesFor(data, myStateProperties);
111  DtAggregateRollUpManager::instance(myDe).parameterData(data, myParameterData);
112  }
113  else
114  {
115  iter = data.begin();
116  while (iter != data.end())
117  {
119  {
120  if (iter == data.begin())
121  {
122  DtAggregateRollUpManager::instance(myDe).statePropertiesFor((*iter)->id(), myStateProperties);
123  DtAggregateRollUpManager::instance(myDe).parameterData((*iter)->id(), myParameterData);
124  }
125  else
126  {
127  DtRwProperties stateProperties("");
128  DtRwProperties parameterData("");
129 
130  DtAggregateRollUpManager::instance(myDe).statePropertiesFor((*iter)->id(), stateProperties);
131  myStateProperties.merge(stateProperties, DtPropertyInterface::RollUp);
132  DtAggregateRollUpManager::instance(myDe).parameterData((*iter)->id(), parameterData);
133  myParameterData.merge(parameterData, DtPropertyInterface::RollUp);
134  }
135  }
136  else
137  {
138  StateType* state = findStateFor<StateType*>(*iter);
139 
140  if(state)
141  {
142  if (iter == data.begin())
143  {
144  myStateProperties = state->myStateProperties;
145  }
146  else
147  {
148  myStateProperties.merge(state->myStateProperties, DtPropertyInterface::RollUp);
149  }
150  }
151  }
152 
153  ++iter;
154  }
155  }
156  }
157 
158  if (myStateProperties.registry().registryData().size())
159  {
160  int iLimit = props.size();
161  int i;
162  for (i = 0; i < iLimit; i++)
163  {
164  DtString propString(props[i].c_str());
165  bool hasStar = false;
166  int index = 0;
167 
168  if (propString[0] == '+')
169  {
170  propString = DtString(&propString.c_str()[1], propString.length() - 1);
171  }
172 
173  QString propStr(propString.c_str());
174 
175  if ((index = propStr.indexOf('*')) == propStr.length() - 1)
176  {
177  hasStar = true;
178  propStr[index] = 0;
179  }
180 
181  DtReaderWriter* rw = myStateProperties.findVariableBinding(propStr.toStdString().c_str());
182  DtPropertyInterface* prop = dynamic_cast<DtPropertyInterface*>(rw);
183 
184  if (prop)
185  {
186  if (hasMoreThanDefaultValueInRegistry(rw))
187  {
188  myScrollArea->setFrameShape(QFrame::NoFrame);
189  myScrollArea->setFrameShadow(QFrame::Plain);
190  }
191 
192  addProperty(prop, merge, hasStar);
193  }
194  }
195 
196  if(myPropertyItems.size() == 0)
197  {
199  setupGuiWhenSelectionInvalid();
200  }
201  }
202  else
203  {
204  setupGuiWhenNoSelection();
205  }
206  }
207 
210  virtual void setupGuiWhenNoSelection();
211 
214  virtual void setupGuiWhenSelectionInvalid();
215 
216  protected:
217 
221  };
222 
224  {
225  public:
226  DtSetStatePropertyDialogCreator(makVrv::DtDe&, const DtString& prop, const DtString& defaultPlatformFile = "");
227 
228  virtual DtTaskSetDialogInterface* create(makVrv::DtDe&, QWidget* parent);
229  bool supportsType(makVrv::DtDe&, const DtSetMessageType&, const DtSimStatement*) const;
230 
232  virtual bool isValidFor(makVrv::DtDe& de, const makVrv::DtSelectionManager::IdSet& ids,
233  int partOfPlanDialog) const;
234 
235  protected:
237  virtual DtTaskSetDialogInterface* createDialog(makVrv::DtDe&, QWidget* parent);
238 
240  virtual bool checkProperties(const DtString&, const DtString&) const;
241  virtual DtString stripModifiers(const DtString&) const;
242 
243  protected:
247  };
248 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)