OpenMS  2.6.0
TOPPASEdge.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2020.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Johannes Veit $
32 // $Authors: Johannes Junker, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
40 #include <QtWidgets/QGraphicsItem>
41 
42 namespace OpenMS
43 {
44  class TOPPASVertex;
45  class TOPPASToolVertex;
46  class TOPPASInputFileListVertex;
47 
48  class String;
49 
59  class OPENMS_GUI_DLLAPI TOPPASEdge :
60  public QObject,
61  public QGraphicsItem
62  {
63  Q_OBJECT
64  Q_INTERFACES(QGraphicsItem)
65 public:
66 
69  {
76  ES_NOT_READY_YET, // no input files given. We cannot know if the types will match.
78  ES_UNKNOWN
79  };
80 
82  TOPPASEdge();
84  TOPPASEdge(TOPPASVertex * from, const QPointF & hover_pos);
86  TOPPASEdge(const TOPPASEdge & rhs);
88  ~TOPPASEdge() override;
90  TOPPASEdge & operator=(const TOPPASEdge & rhs);
91 
93  String toString();
94 
96  QRectF boundingRect() const override;
98  QPainterPath shape() const override;
100  void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) override;
102  QPointF startPos() const;
104  QPointF endPos() const;
106  void setHoverPos(const QPointF & pos);
108  void setSourceVertex(TOPPASVertex * tv);
110  void setTargetVertex(TOPPASVertex * tv);
112  TOPPASVertex * getSourceVertex();
114  TOPPASVertex * getTargetVertex();
116  void prepareResize();
118  void setColor(const QColor & color);
120  EdgeStatus getEdgeStatus();
122  void setSourceOutParam(int out);
124  int getSourceOutParam();
126  QString getSourceOutParamName();
128  void setTargetInParam(int in);
130  int getTargetInParam();
132  QString getTargetInParamName();
134  void updateColor();
136  void emitChanged();
138  void showIOMappingDialog();
139 
140 public slots:
141 
143  void sourceHasChanged();
144 
145 signals:
146 
148  void somethingHasChanged();
149 
150 protected:
151 
153 
154  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * e) override;
155  void contextMenuEvent(QGraphicsSceneContextMenuEvent * event) override;
157 
159 
160  EdgeStatus getToolToolStatus_(TOPPASToolVertex * source, int source_param_index, TOPPASToolVertex * target, int target_param_index);
161  EdgeStatus getListToolStatus_(TOPPASInputFileListVertex * source, TOPPASToolVertex * target, int target_param_index);
163 
165  QPointF borderPoint_(bool atTargetVertex = true) const;
166 
168  QPointF nearestPoint_(const QPointF & origin, const QList<QPointF> & list) const;
174  QPointF hover_pos_;
176  QColor color_;
181  };
182 }
183 
QObject
OpenMS::TOPPASEdge::from_
TOPPASVertex * from_
Pointer to the source of this edge.
Definition: TOPPASEdge.h:170
OpenMS::TOPPASEdge::EdgeStatus
EdgeStatus
The status of this edge.
Definition: TOPPASEdge.h:68
OpenMS::TOPPASEdge::ES_VALID
Definition: TOPPASEdge.h:70
OpenMS::String
A more convenient string class.
Definition: String.h:59
OpenMS::TOPPASEdge::target_in_param_
int target_in_param_
The target input parameter index.
Definition: TOPPASEdge.h:180
OpenMS::TOPPASToolVertex
A vertex representing a TOPP tool.
Definition: TOPPASToolVertex.h:59
OpenMS::TOPPASEdge::ES_TOOL_API_CHANGED
Definition: TOPPASEdge.h:77
QWidget
OpenMS::TOPPASEdge::hover_pos_
QPointF hover_pos_
Position of hovering end while edge is being created.
Definition: TOPPASEdge.h:174
OpenMS::TOPPASEdge::color_
QColor color_
The color.
Definition: TOPPASEdge.h:176
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::TOPPASEdge::ES_NO_SOURCE_PARAM
Definition: TOPPASEdge.h:72
OpenMS::TOPPASInputFileListVertex
A vertex representing an input file list.
Definition: TOPPASInputFileListVertex.h:49
OpenMS::TOPPASEdge::ES_FILE_EXT_MISMATCH
Definition: TOPPASEdge.h:73
OpenMS::TOPPASEdge::ES_MERGER_WITHOUT_TOOL
Definition: TOPPASEdge.h:75
OpenMS::TOPPASEdge::ES_MERGER_EXT_MISMATCH
Definition: TOPPASEdge.h:74
OpenMS::TOPPASVertex
The base class of the different vertex classes.
Definition: TOPPASVertex.h:101
OpenMS::TOPPASEdge::ES_NOT_READY_YET
Definition: TOPPASEdge.h:76
OpenMS::StringConversions::toString
String toString(const T &i)
fallback template for general purpose using Boost::Karma; more specializations below
Definition: StringUtils.h:127
OpenMS::TOPPASEdge::to_
TOPPASVertex * to_
Pointer to the target of this edge.
Definition: TOPPASEdge.h:172
OpenMS::TOPPASEdge
An edge representing a data flow in TOPPAS.
Definition: TOPPASEdge.h:59
QGraphicsItem
OpenMS::TOPPASEdge::source_out_param_
int source_out_param_
The source output parameter index.
Definition: TOPPASEdge.h:178
OpenMS::TOPPASEdge::ES_NO_TARGET_PARAM
Definition: TOPPASEdge.h:71