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();
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 
253  virtual void initializeRightClickMenu();
254 
255  virtual void resizeEvent(QResizeEvent*);
256 
257  virtual QMimeData* mimeData(const QList<QTreeWidgetItem*> list) const;
258  virtual void dragEnterEvent(QDragEnterEvent* event);
259  virtual void dragMoveEvent(QDragMoveEvent* event);
260  virtual bool dropMimeData(QTreeWidgetItem* parent, int index, const QMimeData* mimeData, Qt::DropAction action);
261  virtual void dropEvent(QDropEvent *event);
262  virtual void dragLeaveEvent(QDragLeaveEvent*);
263 
266  virtual void reissueStatementIds(DtSimStatement* stmt);
267 
268  virtual void startDrag(Qt::DropActions supportedActions);
269  virtual bool eventFilter(QObject* o, QEvent*);
270 
271  virtual void itemRightClickedOn(QTreeWidgetItem*, QMouseEvent*, int col);
272 
273  virtual void unusedTriggers(DtSimBlock*, DtRwTriggersList&, std::set<DtUUID>& visited) const;
274 
275  virtual void uuidChanged(makVrv::DtUniqueID, const DtUUID&, const DtUUID&);
276 
277  virtual void storeCurrentContext();
278  virtual void restoreCurrentContext();
279  virtual void clearCurrentContext();
280 
281  friend class DtPlanStatementItem;
282  friend class DtPlanListBoxItem;
283  virtual void statementDeleted(DtPlanStatementItem*);
284 
285  signals:
286  void editCurrentlySelectedPlanStatement();
287  void deleteCurrentlySelectedPlanStatement();
288  void copyCurrentlySelectedPlanStatement();
289  void pastePlanStatement();
290  void planRightClickMenuCreated(QMenu*);
291  void rightClickToBeShown(bool&);
292  void editCurrentlySelectedTrigger();
293  void addNewTriggerBlock();
294  void removeTriggerBlock(const DtUUID&);
295  void editTriggerBlock(const DtUUID&);
296 
297  public:
305 
306  protected:
311 
318 
320  QString myPlanTitle;
321 
324  bool myPlanLocked = false;
326 
329 
331  {
332  void clear()
333  {
334  selectedStatementId = 0;
335  selectedPlanId = DtUUID::nullUUID();
336  executingStatementId = 0;
337  executingPlanId = DtUUID::nullUUID();
338  }
339 
340  int selectedStatementId = 0;
341  DtUUID selectedPlanId = DtUUID::nullUUID();
342 
343  int executingStatementId = 0;
344  DtUUID executingPlanId = DtUUID::nullUUID();
345  };
346 
348 
349  std::set<DtUUID> myExecutingTriggers;
350  std::set<DtUUID> myRegisteredTriggers;
351 
352  boost::signals2::scoped_connection myComputeUnusedTriggersConnection;
354 
356 
357  private:
359  DtPlanTreeWidget(const DtPlanTreeWidget& orig);
360 
362  DtPlanTreeWidget& operator=(const DtPlanTreeWidget& rhs);
363  };
364 
367  {
368  public:
371 
373  virtual ~DtPlanTreeWidgetCreator();
374 
376  static DtPlanTreeWidgetCreator& instance(makVrv::DtDe&);
377 
379  static void registerInstance(makVrv::DtDe&, DtPlanTreeWidgetCreator*);
380 
382  virtual DtPlanTreeWidget* create( QWidget* parent);
383 
384  protected:
386  };
387 
390  {
391  public:
393  virtual ~DtPlanWidgetItemDelegate();
394 
395  virtual void paint(QPainter *painter,
396  const QStyleOptionViewItem &option,
397  const QModelIndex &index) const override;
398 
399  protected:
402  };
403 }
QColor myDropLineColor
Definition: planTreeWidget.h:307
UUID is a unique ID wrapper class.
Definition: uuid.h:59
QColor myTriggerBlockBackgroundColor
Definition: planTreeWidget.h:310
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:389
DtPlanStatementItem * myDraggingOver
Definition: planTreeWidget.h:314
std::set< DtUUID > myExecutingTriggers
Definition: planTreeWidget.h:349
QAction * myCopyAction
Definition: planTreeWidget.h:302
#define DT_DLL_VRFGUICOREQT
Definition: vrfGuiCoreQt.h:26
makVrv::DtDe & myDe
Definition: planTreeWidget.h:385
QColor myMainBlockBackgroundColor
Definition: planTreeWidget.h:309
Definition: planStatementItem.h:35
class DtStmtIndex:
Definition: stmtIndex.h:24
QToolButton * myAddNewTriggerBlock
Definition: planTreeWidget.h:304
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:352
boost::signals2::signal< void()> signal_addedTriggers
Definition: planTreeWidget.h:179
makVrv::DtSignalConnectionManager myConnections
Definition: planTreeWidget.h:325
int myProposedAction
Definition: planTreeWidget.h:323
bool myDragDraw
Definition: planTreeWidget.h:322
bool myFirstShow
Definition: planTreeWidget.h:319
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:317
Contains makVrv::DtVirtualBaseClass class.
std::set< DtUUID > myRegisteredTriggers
Definition: planTreeWidget.h:350
DtRwTriggersList myUnusedTriggers
Definition: planTreeWidget.h:353
DtPlanTreeWidget * myPlanTreeWidget
Definition: planTreeWidget.h:400
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:355
QAction * myEditTriggerAction
Definition: planTreeWidget.h:300
bool myPlanIsModified
Definition: planTreeWidget.h:316
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:347
Creator for the DtPlanTreeWidget.
Definition: planTreeWidget.h:366
void clear()
Definition: planTreeWidget.h:332
QObject * myDropSource
Definition: planTreeWidget.h:327
const QColor & mainBlockBackgroundColor() const
Definition: planTreeWidget.h:222
bool dragDraw() const
Definition: planTreeWidget.h:203
makVrv::DtDe & myDe
Definition: planTreeWidget.h:401
bool planLocked() const
Definition: planTreeWidget.h:245
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
bool myIsGlobalPlan
Definition: planTreeWidget.h:312
class DtPlan:
Definition: plan.h:92
bool myDropIsInsertAtTopIfNoEntry
Definition: planTreeWidget.h:328
QAction * myDeleteAction
Definition: planTreeWidget.h:301
const QColor & blockActiveColor() const
Definition: planTreeWidget.h:221
QAction * myEditAction
Definition: planTreeWidget.h:299
Base class to provide boost signal/slot management.
class DtSimStatement:
Definition: simStatement.h:38
QAction * myPasteAction
Definition: planTreeWidget.h:303
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:72
DtPlanStatementItem * myCurrentlyExecutingItem
Definition: planTreeWidget.h:315
const DtRwTriggersList & unusedTriggers() const
Definition: planTreeWidget.h:237
QString myPlanTitle
Definition: planTreeWidget.h:320
QMenu * myRightClickMenu
Definition: planTreeWidget.h:298
boost::signals2::signal< void(bool)> signal_planIsModified
Definition: planTreeWidget.h:178
QList< DtPlanStatementItem * > myLastDraggedItems
Definition: planTreeWidget.h:313
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:308

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)