/usr/include/GraphUnidraw/nodecomp.h is in ivtools-dev 1.2.11a1-11.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | /*
* Copyright (c) 2006-2007 Scott E. Johnston
* Copyright (c) 1994,1999 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of the copyright holders not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. The copyright holders make
* no representations about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#ifndef nodecomp_h
#define nodecomp_h
#include <GraphUnidraw/graphcomp.h>
#include <OverlayUnidraw/ovcomps.h>
#include <OverlayUnidraw/ovviews.h>
#include <OverlayUnidraw/scriptview.h>
#include <Unidraw/Components/grcomp.h>
#include <Unidraw/Components/psview.h>
class ArrowLine;
class Command;
class EdgeComp;
class FullGraphic;
class GraphComp;
class NodeView;
class Picture;
class Rubberband;
class SF_Ellipse;
class TextGraphic;
class TopoNode;
class Viewer;
#include <iosfwd>
//: node component
// component for a node in an edge-node directed graph. Default appearance
// is a single ellipse with centered text for regular nodes, a double
// ellipse with centered text for nodes with nested graphs inside them.
// Uses underlying TopoNode to represent topology.
class NodeComp : public OverlayComp {
public:
NodeComp(SF_Ellipse*, TextGraphic*,
boolean reqlabel = false, OverlayComp* parent = nil);
// construct node component with ellipse and text graphic
// (text display not requiredd by default).
NodeComp(SF_Ellipse*, TextGraphic*, SF_Ellipse*, GraphComp*,
boolean reqlabel = false, OverlayComp* parent = nil);
// construct node component with internal graph
// (text display not requiredd by default).
NodeComp(Picture*, boolean reqlabel =false, OverlayComp* parent = nil);
// construct node component with pre-made Picture graphic.
NodeComp(GraphComp*);
// construct node component around a graph.
NodeComp(istream&, OverlayComp* parent = nil);
// construct node component from istream, relying on GraphCatalog
// to re-establish connections between edges and nodes.
NodeComp(OverlayComp* parent = nil);
// construct node component but defer anything graphical
virtual ~NodeComp();
virtual NodeComp* NewNodeComp(SF_Ellipse* ell, TextGraphic* txt,
boolean reqlabel = false, OverlayComp* parent = nil)
{ return new NodeComp(ell, txt, reqlabel, parent); }
// virtual constructor for use of derived classes
virtual NodeComp* NewNodeComp(SF_Ellipse* ell1, TextGraphic* txt, SF_Ellipse* ell2, GraphComp* comp,
boolean reqlabel = false, OverlayComp* parent = nil)
{ return new NodeComp(ell1, txt, ell2, comp, reqlabel, parent); }
// virtual constructor for use of derived classes
virtual NodeComp* NewNodeComp(Picture* pict, boolean reqlabel =false, OverlayComp* parent = nil)
{ return new NodeComp(pict, reqlabel, parent); }
// virtual constructor for use of derived classes
virtual NodeComp* NewNodeComp(GraphComp* comp)
{ return new NodeComp(comp); }
// virtual constructor for use of derived classes
virtual NodeComp* NewNodeComp(istream& strm, OverlayComp* parent = nil)
{ return new NodeComp(strm, parent); }
// virtual constructor for use of derived classes
virtual NodeComp* NewNodeComp(OverlayComp* parent = nil)
{ return new NodeComp(parent); }
// virtual constructor for use of derived classes
void SetGraph(GraphComp*);
// set internal graph for this node.
GraphComp* GetGraph();
// return internal graph for this node.
void GraphGraphic(SF_Ellipse* e = nil);
// set auxiliary graphic used to indicate internal graph.
virtual Component* Copy();
virtual void Interpret(Command*);
// handle delete, cut, move, and change-text commands, pass rest to base class.
virtual void Uninterpret(Command*);
// handle undoing move and graph-delete command, pass rest to base class.
virtual void Read(istream&); // archaic read method.
virtual void Write(ostream&); // archaic write method.
virtual ClassId GetClassId();
virtual boolean IsA(ClassId);
SF_Ellipse* GetEllipse();
// return pointer to ellipse graphic.
TextGraphic* GetText();
// return pointer to text graphic.
void SetText(TextGraphic*);
// set pointer to text graphic.
SF_Ellipse* GetEllipse2();
// return pointer to second ellipse graphic used to indicate internal graph.
EdgeComp* SubEdgeComp(int);
// return pointer to nth edge component on internal graph.
ArrowLine* SubEdgeGraphic(int);
// return pointer to nth edge graphic on internal graph.
TopoNode* Node() const { return _node; }
// return pointer to underlying TopoNode.
NodeView* GetNodeView(Viewer*);
// return pointer to NodeView of this component in given viewer.
boolean RequireLabel() { return _reqlabel; }
// flag to indicate whether node must have label (text graphic).
void RequireLabel(boolean flag) { _reqlabel = flag; }
// flag to indicate whether node must have label (text graphic).
#if 0
void update(Observable*);
// update notification received from Observable.
#endif
virtual void Notify();
// override OverlayComp::Notify, separating view update from
// attribute list update.
EdgeComp* EdgeIn(int n) const;
// return pointer to nth incoming edge.
EdgeComp* EdgeOut(int n) const;
// return pointer to nth outgoing edge.
int EdgeInOrder(EdgeComp*) const;
// return order of incoming edge.
int EdgeOutOrder(EdgeComp*) const;
// return order of outgoing edge.
void nedges (int &nin, int &nout) const;
// count number of input and ouput edges
EdgeComp* EdgeByDir(int n, boolean out_edge) const;
// return pointer to nth edge of given direction.
NodeComp* NodeIn(int n) const;
// return pointer to node on other side of nth incoming edge.
NodeComp* NodeOut(int n) const;
// return pointer to node on other side of nth outgoing edge.
virtual boolean operator == (OverlayComp&);
void index(int i) {_index = i; }
// set temporary index for writing to file
int index() { return _index; }
// get temporary index for writing to file
virtual const char* nodename();
// Name of node.
protected:
GraphComp* _graph;
TopoNode* _node;
boolean _reqlabel;
int _index;
protected:
ParamList* GetParamList();
void GrowParamList(ParamList*);
static ParamList* _node_params;
CLASS_SYMID("NodeComp");
};
inline void NodeComp::SetGraph(GraphComp* comp) { if (_graph) delete _graph; _graph = comp; }
inline GraphComp* NodeComp::GetGraph() { return _graph; }
//: graphical view of NodeComp.
class NodeView : public OverlayView {
public:
NodeView(NodeComp* = nil);
virtual ~NodeView();
virtual void Update();
// update view based on any changes to component.
virtual void Interpret(Command*);
// pass to GraphicView::Interpret.
virtual void Uninterpret(Command*);
// pass to GraphicView::Uninterpret.
virtual Graphic* GetGraphic();
// return pointer to graphic used for this view.
virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*);
// create tool-specific manipulator for creating, moving, or reshaping the node.
virtual Command* InterpretManipulator(Manipulator*);
// interpret tool-specific manipulator for creating, moving, or reshaping
// the node.
virtual ClassId GetClassId();
virtual boolean IsA(ClassId);
virtual Graphic* HighlightGraphic();
// default highlighting -- solid brush of width 2, pattern #4 from catalog.
SF_Ellipse* GetEllipse();
// return pointer to view's ellipse graphic.
TextGraphic* GetText();
// return pointer to view's text graphic.
SF_Ellipse* GetEllipse2();
// return pointer to view's second ellipse graphic, the one for indicating
// an internal graph.
int SubEdgeIndex(ArrowLine*);
// return index of ArrowLine graphic relative to edges on internal graph.
virtual NodeComp* NewNodeComp(SF_Ellipse* ellipse, TextGraphic* txt, boolean reqlabel = false)
{ return new NodeComp(ellipse, txt, reqlabel); }
// virtual function to allow construction of specialized NodeComp's by specialized NodeView's
virtual Rubberband* MakeRubberband(IntCoord x, IntCoord y);
// make Rubberband specific to this node.
protected:
static FullGraphic* _nv_gs;
};
//: serialized view of NodeComp.
class NodeScript : public OverlayScript {
public:
NodeScript(NodeComp* = nil);
virtual const char* script_name() { return "node"; }
// for overriding in derived classes
virtual boolean Definition(ostream&);
// output variable-length ASCII record that defines the component.
void Attributes(ostream& out);
// specialized output of property list.
virtual boolean EmitGS(ostream&, Clipboard*, boolean);
// specialized output of graphic states.
static int ReadGraph(istream&, void*, void*, void*, void*);
// read sub-graph and construct internal GraphComp.
static int ReadEllipse(istream&, void*, void*, void*, void*);
// read arguments of ellipse, and construct SF_Ellipse.
static int ReadText(istream&, void*, void*, void*, void*);
// read arguments of text, and construct TextGraphic.
static int ReadEllipseTransform(istream&, void*, void*, void*, void*);
// read transform for ellipse graphic.
static int ReadTextTransform(istream&, void*, void*, void*, void*);
// read transform for text graphic.
virtual ClassId GetClassId();
virtual boolean IsA(ClassId);
boolean dot_format() { return format() ? strcmp(format(), "dot")==0 : 0; }
// test for GraphViz dot format export
};
#endif
|