VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
planTreeWidget.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2016 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
11 #if !defined(Q_MOC_RUN)
12 
15 #include <vrfplan/rwTriggersList.h>
18 #include <vrfutil/rwUUID.h>
19 #include <vrvCore/DtUniqueID.h>
20 #endif
21 #include <boost/signals2.hpp>
22 
23 #include <QtWidgets/QTreeWidget>
24 #include <QtWidgets/QHeaderView>
25 #include <QtWidgets/QStyledItemDelegate>
26 
27 #include <set>
28 
30 //
31 
32 class QMenu;
33 class QAction;
34 class QTreeWidget;
35 class DtPlan;
36 class DtStmtIndex;
37 class DtSimBlock;
38 class DtSimStatement;
39 class DtRwTriggersList;
40 class QToolButton;
41 
42 namespace makVrv
43 {
44  class DtDe;
45 }
46 
47 #define planPasteType "text/x-myPlanText@Type"
48 #define planTopLevelPasteType "text/x-myPlanText@TopType"
49 
50 namespace makVrf
51 {
52  class DtPlanStatementItem;
53  class DtPlanListBoxItem;
54  class DtPlanTriggerItem;
55 
58  {
59  Q_OBJECT
60 
61  Q_PROPERTY(QColor DropLineColor MEMBER myDropLineColor USER true)
62  Q_PROPERTY(QColor BlockActiveColor MEMBER myBlockActiveColor USER true)
63  Q_PROPERTY(QColor MainBlockBackgroundColor MEMBER myMainBlockBackgroundColor USER true)
64  Q_PROPERTY(QColor TriggerBlockBackgroundColor MEMBER myTriggerBlockBackgroundColor USER true)
65 
66  public:
67 
69  DtPlanTreeWidget(makVrv::DtDe&, QWidget* parent = NULL);
70 
72  virtual ~DtPlanTreeWidget() override;
73 
74  virtual void setExecutingTriggers(const std::vector<DtUUID>&);
75  virtual bool triggerIsExecuting(const DtUUID&) const;
76 
77  virtual void setRegisteredTriggers(const std::vector<DtUUID>&);
78  virtual bool triggerIsRegistered(const DtUUID&) const;
79 
80  virtual void setExecutingTriggerStatementIds(const std::vector<int>&);
81  virtual bool triggerStatementIdIsBeingExecuted(int) const;
82 
84  virtual DtPlanStatementItem* currentlySelectedItem() const;
85  virtual DtPlanStatementItem* currentlyExecutingItem() const;
86 
88  virtual bool hasItem(const DtPlanStatementItem*);
89 
90  virtual makVrv::DtUniqueID entityId() const;
91 
93  virtual void print();
94 
96  virtual void setName(const DtUUID&);
97  const DtUUID& name() const;
98 
100  virtual void displayPlan(bool andSelectStatement = true);
101 
104  virtual void setIsGlobalPlan(bool);
105 
107  virtual void clearAllStatements();
108 
110  virtual void clearPlan();
111 
113  virtual void copySelectedPlanStatementToClipboard();
114 
116  virtual void copyPlanToClipboard();
117 
120  virtual void addStatementsToPlan(const std::vector<DtSimStatement*>&, bool append, bool redisplay = true);
121 
123  virtual void addStatementAfter(DtSimStatement* stmt,
124  const DtPlanStatementItem* listItem = 0, bool redisplay = true, bool addAtEndOfParentBlock = false,
125  DtSimStatement* lastStatementAdded = nullptr);
126 
128  virtual void replaceStatement(DtSimStatement* stmt, DtPlanStatementItem* item);
129 
130  virtual bool isBeingDragged(QTreeWidgetItem*) const;
131 
133  virtual void setPlan(DtPlan*);
134  virtual DtPlan* plan() const;
135  virtual DtPlan* plan() { return getOrCreatePlan(); };
136 
138  virtual void selectTrigger(const DtUUID&);
139 
141  virtual DtPlanTriggerItem* triggerItem(const DtUUID&) const;
142 
144  virtual DtPlanListBoxItem* mainPlanItem();
145 
146  virtual DtPlan* getOrCreatePlan();
147 
149  virtual void setCanDropOn(int, bool);
150  virtual bool canDropOn(int) const;
151  virtual bool canDropOn(QTreeWidgetItem*) const;
152  virtual bool canDropOnCurrentItem() const;
153 
155  virtual DtSimStatement* selectStatement(int, DtPlanListBoxItem* inPlan = nullptr, bool andMakeCurrent = false);
156 
159  virtual DtPlanStatementItem* findItemByIndex(int statementIndex, DtPlanListBoxItem*, int subBlock = 0);
160 
162  virtual void setIsComplete(bool);
163 
166  virtual void addPlanMimeDataAfter(const QMimeData*, DtPlanStatementItem*, bool copy = true, bool redisplay = true, bool reselectCurrentItem = true);
167 
169  virtual DtPlanStatementItem* findLastItemByIndex(int statementIndex, DtPlanListBoxItem* plan, int subBlock = 0);
170 
171  virtual void setPlanTitle(const QString&);
172  virtual const QString& planTitle() const;
173 
174  virtual bool planIsModified() const;
175  virtual void clearPlanIsModified();
176  virtual void markPlanIsModified();
177 
178  boost::signals2::signal<void (bool)> signal_planIsModified;
179  boost::signals2::signal<void ()> signal_addedTriggers;
180 
182  virtual DtSimStatement* selectedBlockStatement() const;
183 
185  virtual DtSimStatement* selectedStatement() const;
186 
188  virtual DtSimStatement* displayBlockStatement() const;
189 
190  virtual void setShowRightClickMenu(bool);
191  bool showRightClickMenu() const { return myShowRightClickMenu; };
192 
193  virtual QString planDescriptiveName() const;
194 
196  virtual void removeTrigger(const DtUUID&);
197 
199  virtual void renameTrigger(const DtUUID& uuid, const DtString& newName);
200 
201  virtual void unusedTriggers(DtRwTriggersList&) const;
202 
203  bool dragDraw() const { return myDragDraw; };
204 
205  virtual bool clearing() const;
206 
208  virtual void selectLastStatement();
209 
211  virtual DtPlanListBoxItem* currentPlanItem();
212 
214  virtual void setPlanIsModified(bool);
215 
218  virtual bool deleteStatement(DtPlanStatementItem*);
219 
220  const QColor& dropLineColor() const { return myDropLineColor; };
221  const QColor& blockActiveColor() const { return myBlockActiveColor; };
222  const QColor& mainBlockBackgroundColor() const { return myMainBlockBackgroundColor; };
223  const QColor& triggerBlockBackgroundColor() const { return myTriggerBlockBackgroundColor; };
224 
226  virtual void displayTriggers();
227 
229  virtual std::map<DtUUID, bool> clearTriggers();
230 
232  virtual void addSeparator(const QString&);
233 
235  virtual void computeUnusedTriggers();
236 
238  {
239  return myUnusedTriggers;
240  }
241 
242  virtual bool triggerIsUnused(const DtUUID&) const;
243 
244  virtual void setPlanLocked(bool);
245  bool planLocked() const
246  {
247  return myPlanLocked;
248  }
249 
250  protected:
251  virtual void internalComputeUnusedTriggers();
252 
254  virtual void resetUUIDsInStatements(DtSimStatement* stmt) const;
255 
256  virtual void initializeRightClickMenu();
257 
258  virtual void resizeEvent(QResizeEvent*) override;
259 
260  virtual QMimeData* mimeData(const QList<QTreeWidgetItem*> list) const override;
261  virtual void dragEnterEvent(QDragEnterEvent* event) override;
262  virtual void dragMoveEvent(QDragMoveEvent* event) override;
263  virtual bool dropMimeData(
264  QTreeWidgetItem* parent, int index, const QMimeData* mimeData, Qt::DropAction action) override;
265  virtual void dropEvent(QDropEvent* event) override;
266  virtual void dragLeaveEvent(QDragLeaveEvent*) override;
267 
270  virtual void reissueStatementIds(DtSimStatement* stmt);
271 
272  virtual void startDrag(Qt::DropActions supportedActions) override;
273  virtual bool eventFilter(QObject* o, QEvent*) override;
274 
275  virtual void itemRightClickedOn(QTreeWidgetItem*, QMouseEvent*, int col) override;
276 
277  virtual void unusedTriggers(DtSimBlock*, DtRwTriggersList&, std::set<DtUUID>& visited) const;
278 
279  virtual void uuidChanged();
280 
281  virtual void storeCurrentContext();
282  virtual void restoreCurrentContext();
283  virtual void clearCurrentContext();
284 
285  friend class DtPlanStatementItem;
286  friend class DtPlanListBoxItem;
287  virtual void statementDeleted(DtPlanStatementItem*);
288 
289  signals:
290  void editCurrentlySelectedPlanStatement();
291  void deleteCurrentlySelectedPlanStatement();
292  void copyCurrentlySelectedPlanStatement();
293  void pastePlanStatement();
294  void planRightClickMenuCreated(QMenu*);
295  void rightClickToBeShown(bool&);
296  void editCurrentlySelectedTrigger();
297  void addNewTriggerBlock();
298  void removeTriggerBlock(const DtUUID&);
299  void editTriggerBlock(const DtUUID&);
300 
301  public:
309 
310  protected:
315 
322 
324  QString myPlanTitle;
325 
328  bool myPlanLocked = false;
330 
333 
335  {
336  void clear()
337  {
338  selectedStatementId = 0;
339  selectedPlanId = DtUUID::nullUUID();
340  executingStatementId = 0;
341  executingPlanId = DtUUID::nullUUID();
342  }
343 
344  int selectedStatementId = 0;
345  DtUUID selectedPlanId = DtUUID::nullUUID();
346 
347  int executingStatementId = 0;
348  DtUUID executingPlanId = DtUUID::nullUUID();
349  };
350 
352 
353  std::set<DtUUID> myExecutingTriggers;
354  std::set<DtUUID> myRegisteredTriggers;
355 
356  boost::signals2::scoped_connection myComputeUnusedTriggersConnection;
358 
360 
361  private:
363  DtPlanTreeWidget(const DtPlanTreeWidget& orig);
364 
366  DtPlanTreeWidget& operator=(const DtPlanTreeWidget& rhs);
367  };
368 
371  {
372  public:
375 
377  virtual ~DtPlanTreeWidgetCreator() override;
378 
380  static DtPlanTreeWidgetCreator& instance(makVrv::DtDe&);
381 
383  static void registerInstance(makVrv::DtDe&, DtPlanTreeWidgetCreator*);
384 
386  virtual DtPlanTreeWidget* create( QWidget* parent);
387 
388  protected:
390  };
391 
394  {
395  public:
397  virtual ~DtPlanWidgetItemDelegate() override;
398 
399  virtual void paint(QPainter *painter,
400  const QStyleOptionViewItem &option,
401  const QModelIndex &index) const override;
402 
403  protected:
406  };
407 }
QColor myDropLineColor
Definition: planTreeWidget.h:311
UUID is a unique ID wrapper class.
Definition: uuid.h:59
QColor myTriggerBlockBackgroundColor
Definition: planTreeWidget.h:314
Definition: treeWidget.h:35
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
const QColor & dropLineColor() const
Definition: planTreeWidget.h:220
Item delegate to draw drag lines and style plan list.
Definition: planTreeWidget.h:393
DtPlanStatementItem * myDraggingOver
Definition: planTreeWidget.h:318
std::set< DtUUID > myExecutingTriggers
Definition: planTreeWidget.h:353
QAction * myCopyAction
Definition: planTreeWidget.h:306
#define DT_DLL_VRFGUICOREQT
Definition: vrfGuiCoreQt.h:26
makVrv::DtDe & myDe
Definition: planTreeWidget.h:389
QColor myMainBlockBackgroundColor
Definition: planTreeWidget.h:313
Definition: planStatementItem.h:35
class DtStmtIndex:
Definition: stmtIndex.h:24
QToolButton * myAddNewTriggerBlock
Definition: planTreeWidget.h:308
This class will support the listing of plan items and the dragging/dropping thereof.
Definition: planTreeWidget.h:57
Contains the DtUUID class declaration.
boost::signals2::scoped_connection myComputeUnusedTriggersConnection
Definition: planTreeWidget.h:356
boost::signals2::signal< void()> signal_addedTriggers
Definition: planTreeWidget.h:179
makVrv::DtSignalConnectionManager myConnections
Definition: planTreeWidget.h:329
int myProposedAction
Definition: planTreeWidget.h:327
bool myDragDraw
Definition: planTreeWidget.h:326
bool myFirstShow
Definition: planTreeWidget.h:323
void print(double **a, int r, int c, const char *str)
class DtSimBlock:
Definition: simBlock.h:27
static const DtUUID & nullUUID()
bool myShowRightClickMenu
Definition: planTreeWidget.h:321
Contains makVrv::DtVirtualBaseClass class.
std::set< DtUUID > myRegisteredTriggers
Definition: planTreeWidget.h:354
DtRwTriggersList myUnusedTriggers
Definition: planTreeWidget.h:357
DtPlanTreeWidget * myPlanTreeWidget
Definition: planTreeWidget.h:404
This item will be the root node for a plan item – this will create children of type DtPlanStatementIt...
Definition: planListBoxItem.h:32
std::vector< int > myExecutingTriggerStatementIds
Definition: planTreeWidget.h:359
QAction * myEditTriggerAction
Definition: planTreeWidget.h:304
bool myPlanIsModified
Definition: planTreeWidget.h:320
const QColor & triggerBlockBackgroundColor() const
Definition: planTreeWidget.h:223
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
StoredSelectionInformation myStoredSelectionInformation
Definition: planTreeWidget.h:351
Creator for the DtPlanTreeWidget.
Definition: planTreeWidget.h:370
void clear()
Definition: planTreeWidget.h:336
QObject * myDropSource
Definition: planTreeWidget.h:331
const QColor & mainBlockBackgroundColor() const
Definition: planTreeWidget.h:222
bool dragDraw() const
Definition: planTreeWidget.h:203
makVrv::DtDe & myDe
Definition: planTreeWidget.h:405
bool planLocked() const
Definition: planTreeWidget.h:245
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
bool myIsGlobalPlan
Definition: planTreeWidget.h:316
class DtPlan:
Definition: plan.h:92
bool myDropIsInsertAtTopIfNoEntry
Definition: planTreeWidget.h:332
QAction * myDeleteAction
Definition: planTreeWidget.h:305
const QColor & blockActiveColor() const
Definition: planTreeWidget.h:221
QAction * myEditAction
Definition: planTreeWidget.h:303
Base class to provide boost signal/slot management.
class DtSimStatement:
Definition: simStatement.h:38
QAction * myPasteAction
Definition: planTreeWidget.h:307
Contains makVrv::DtUniqueID type.
This item will be the root node for a trigger item – this will create children of type DtPlanStatemen...
Definition: planTriggerItem.h:42
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:76
DtPlanStatementItem * myCurrentlyExecutingItem
Definition: planTreeWidget.h:319
const DtRwTriggersList & unusedTriggers() const
Definition: planTreeWidget.h:237
QString myPlanTitle
Definition: planTreeWidget.h:324
QMenu * myRightClickMenu
Definition: planTreeWidget.h:302
boost::signals2::signal< void(bool)> signal_planIsModified
Definition: planTreeWidget.h:178
QList< DtPlanStatementItem * > myLastDraggedItems
Definition: planTreeWidget.h:317
Instances of DtRwTriggersList are lists of readable, writeable when statements (triggers) The list co...
Definition: rwTriggersList.h:21
bool showRightClickMenu() const
Definition: planTreeWidget.h:191
QColor myBlockActiveColor
Definition: planTreeWidget.h:312

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)