SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
qtTaskEditor.h
1 //=========================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //=========================================================================
10 #ifndef smtk_extension_qtTaskEditor_h
11 #define smtk_extension_qtTaskEditor_h
12 
13 #include "smtk/extension/qt/diagram/qtDiagramGenerator.h"
14 
15 #include "smtk/project/Project.h"
16 #include "smtk/task/Manager.h"
17 #include "smtk/view/Configuration.h"
18 
19 #include "smtk/common/Categories.h"
20 #include "smtk/common/Managers.h"
21 #include "smtk/common/TypeContainer.h"
22 
23 #include "smtk/PublicPointerDefs.h"
24 
25 #include "nlohmann/json.hpp"
26 
27 #include <QWidget>
28 
29 namespace smtk
30 {
31 
32 namespace task
33 {
34 class Manager;
35 }
36 
37 namespace extension
38 {
39 
40 class qtBaseArc;
41 class qtBaseNode;
42 class qtBaseTaskNode;
43 class qtTaskPath;
44 class qtTaskPortArc;
45 
49 class SMTKQTEXT_EXPORT qtTaskEditor : public qtDiagramGenerator
50 {
51  Q_OBJECT
52 
53 public:
56 
58  const smtk::view::Information& info,
60  qtDiagram* parent);
61  ~qtTaskEditor() override;
62 
63  void updateSceneNodes(
64  std::unordered_set<smtk::resource::PersistentObject*>& created,
65  std::unordered_set<smtk::resource::PersistentObject*>& modified,
66  std::unordered_set<smtk::resource::PersistentObject*>& expunged,
67  const smtk::operation::Operation& operation,
68  const smtk::operation::Operation::Result& result) override;
69 
70  void updateSceneArcs(
71  std::unordered_set<smtk::resource::PersistentObject*>& created,
72  std::unordered_set<smtk::resource::PersistentObject*>& modified,
73  std::unordered_set<smtk::resource::PersistentObject*>& expunged,
74  const smtk::operation::Operation& operation,
75  const smtk::operation::Operation::Result& result) override;
76 
78  static std::shared_ptr<smtk::view::Configuration> defaultConfiguration();
79 
81  bool addWorklet(const std::string& workletName, std::array<double, 2> location);
82 
84  bool acceptDropProposal(QDragEnterEvent* event) override;
85 
87  void moveDropPoint(QDragMoveEvent* event) override;
88 
90  void abortDrop(QDragLeaveEvent* event) override;
91 
93  bool acceptDrop(QDropEvent* event) override;
94 
96  qtBaseTaskNode* findTaskNode(const smtk::task::Task* task) const;
97 
99  smtk::task::Manager* manager() const;
100 
104  void updateVisibility(const smtk::task::Task* prevTailTask, const smtk::task::Task* nextTailTask);
105 
109  bool snapPortsToTask() const { return m_snapPortsToTask; }
110  void setSnapPortsToTask(bool val) { m_snapPortsToTask = val; }
117  double snapPortOffset() const { return m_snapPortOffset; }
118  void setSnapPortOffset(double val) { m_snapPortOffset = val; }
123  bool drawPortsToTaskCurves() const { return m_drawPortsToTaskCurves; }
124  void setDrawPortsToTaskCurves(bool val) { m_drawPortsToTaskCurves = val; }
126 
128  const qtTaskPath* taskPath() const { return m_taskPath; }
129  qtTaskPath* taskPath() { return m_taskPath; }
130 
131 protected:
136  template<bool RemoveUnusedArcs>
137  bool updateArcs(
139  QRectF& modBounds,
140  ArcLegendEntries& legendInfo);
141 
144  void updateArcStatus(qtBaseArc* arc);
145 
146  class Internal;
147  Internal* m_p;
148  qtTaskPath* m_taskPath{ nullptr };
149  bool m_snapPortsToTask{ false };
150  double m_snapPortOffset{ 0.0 };
151  bool m_drawPortsToTaskCurves{ true };
152 };
153 
154 } // namespace extension
155 } // namespace smtk
156 #endif // smtk_extension_qtTaskEditor_h
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
smtk::extension::qtTaskEditor::taskPath
const qtTaskPath * taskPath() const
Return the task-editor's task breadcrumb.
Definition: qtTaskEditor.h:128
smtk::extension::qtTaskEditor::setSnapPortOffset
void setSnapPortOffset(double val)
Get/set the offset to be used when snapping task ports nodes with respect to their task nodes.
Definition: qtTaskEditor.h:118
PublicPointerDefs.h
smtk::extension::qtTaskEditor::snapPortOffset
double snapPortOffset() const
Get/set the offset to be used when snapping task ports nodes with respect to their task nodes.
Definition: qtTaskEditor.h:117
smtk::operation::Operation::Result
std::shared_ptr< smtk::attribute::Attribute > Result
An attribute containing the operation's result.
Definition: Operation.h:81
smtk::extension::qtTaskEditor::drawPortsToTaskCurves
bool drawPortsToTaskCurves() const
Controls if external task port nodes should have a curve connecting it to their task nodes.
Definition: qtTaskEditor.h:123
smtk::view::Information
A class for information passed to views during initialization.
Definition: Information.h:32
smtk::task::Manager
A task manager is responsible for creating new tasks.
Definition: Manager.h:75
smtk::extension::qtTaskPath
An interactive widget that display the current path Task descendants.
Definition: qtTaskPath.h:43
smtk::operation::Operation
Operation is a base class for all SMTK operations.
Definition: Operation.h:64
smtk::extension::qtDiagram
A widget that displays diagrams of SMTK resources.
Definition: qtDiagram.h:72
smtk::extension::qtTaskEditor
A widget that displays SMTK tasks available to users in a diagram.
Definition: qtTaskEditor.h:49
smtk::extension::qtTaskEditor::setSnapPortsToTask
void setSnapPortsToTask(bool val)
Controls if external task port nodes should be snapped with respected to their task nodes using the s...
Definition: qtTaskEditor.h:110
smtk::extension::qtBaseTaskNode
A Graphical Item that represents a task as a node in a scene.
Definition: qtBaseTaskNode.h:44
smtk::plugin::Manager
smtk::common::Singleton< detail::Manager > Manager
The Manager is a singleton interface for registering available plugins to manager instances.
Definition: Manager.h:92
smtkSuperclassMacro
#define smtkSuperclassMacro(...)
Add a typedef to the superclass of this class.
Definition: SharedFromThis.h:167
smtk::view::Configuration::Component
Configure one item in a view, which may contain children.
Definition: Configuration.h:32
smtk::extension::qtTaskEditor::snapPortsToTask
bool snapPortsToTask() const
Controls if external task port nodes should be snapped with respected to their task nodes using the s...
Definition: qtTaskEditor.h:109
smtk::task::Task
Task is a base class for all SMTK tasks.
Definition: Task.h:70
smtk::extension::qtDiagramGenerator
A base class that maintains a diagram in the face of operations which modify the state of the diagram...
Definition: qtDiagramGenerator.h:43
smtk::resource::PersistentObject
An abstract base class for SMTK resources and their components.
Definition: PersistentObject.h:41
smtk::extension::qtTaskEditor::setDrawPortsToTaskCurves
void setDrawPortsToTaskCurves(bool val)
Controls if external task port nodes should have a curve connecting it to their task nodes.
Definition: qtTaskEditor.h:124
smtkTypenameMacro
#define smtkTypenameMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:115