PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
VCG.h
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: src/base/VCG.h
4// Purpose: Defines an class that can produce data files
5// interpretable by VCG viewer.
6// Author: Shane T. Mueller, Ph.D.
7// Copyright: (c) 2003-2026 Shane T. Mueller <smueller@obereed.net>
8// License: GPL 2
9//
10//
11//
12//
13// This file is part of the PEBL project.
14//
15// PEBL is free software; you can redistribute it and/or modify
16// it under the terms of the GNU General Public License as published by
17// the Free Software Foundation; either version 2 of the License, or
18// (at your option) any later version.
19//
20// PEBL is distributed in the hope that it will be useful,
21// but WITHOUT ANY WARRANTY; without even the implied warranty of
22// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23// GNU General Public License for more details.
24//
25// You should have received a copy of the GNU General Public License
26// along with PEBL; if not, write to the Free Software
27// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29#ifndef __VCG_H__
30#define __VCG_H__
31#include "PNode.h"
32
33#include <iostream>
34#include <list>
35#include <stdlib.h>
36
37using namespace std;
38
39class VCGGraph;
40class VCGNode;
41class VCGEdge;
42
43class VCG
44{
45public:
46
47 VCG();
48 ~VCG();
49
50 void MakeGraph(const PNode * node); //This will initiate a new VCG
51 void PrintGraph();
52 void Evaluate(const PNode * node, const char* parent, const int anchor);
53
54
55private:
56 VCGGraph * mGraph;
57 int mNodeIndex;
58 char * mHeader;
59};
60
62{
63public:
64 VCGGraph();
65 ~VCGGraph();
66 friend std::ostream& operator <<(std::ostream& out,VCGGraph & v);
67 void SetTitle(const char* title){if(mTitle)free(mTitle); mTitle=strdup(title);};
68 void AddEdge(VCGEdge * edge);
69 void AddNode(VCGNode * node);
70
71 bool GetSplines()const{return mSplines;};
72 char * GetTitle()const{return mTitle;}
73 int GetWidth()const{return mWidth;};
74 int GetHeight()const{return mHeight;};
75 int GetX()const{return mX;};
76 int GetY()const{return mY;};
77 char* GetColor()const{return mColor;};
78
79 void OutputNodes( std::ostream & out);
80 void OutputEdges( std::ostream & out);
81
82private:
83
84 char* mTitle;
85 std::list<VCGEdge> mVCGEdges;
86 std::list<VCGNode> mVCGNodes;
87
88 bool mSplines;
89 int mWidth;
90 int mHeight;
91 int mX;
92 int mY;
93 char* mColor;
94
95};
96
98{
99public:
100 VCGNode();
101 ~VCGNode();
102 VCGNode(const char* title, const char* label);
103
104 void SetTitle(const char* title){if(mTitle)free(mTitle);mTitle=strdup(title);};
105 void SetLabel(const char* label){if(mLabel)free(mLabel);mLabel=strdup(label);};
106 void SetShape(const char* shape){if(mShape)free(mShape);mShape=strdup(shape);};
107 void SetBorderColor(const char * color){if(mBorderColor)free(mBorderColor); mBorderColor=strdup(color);};
108 friend std::ostream& operator <<(std::ostream& out,VCGNode & v);
109 char* GetTitle()const {return mTitle;};
110 char* GetLabel()const {return mLabel;};
111 char* GetShape()const {return mShape;};
112 char* GetBorderColor()const {return mBorderColor;};
113private:
114
115 char * mTitle;
116 char * mLabel;
117 char * mShape;
118 char * mBorderColor;
119};
120
121
123{
124public:
125 VCGEdge();
126 ~VCGEdge();
127 VCGEdge(const char* from , const char* to);
128
129 void SetThickness(const int thickness){mThickness=thickness;};
130 void SetFrom(const char * from){if(mFrom)free(mFrom);mFrom = strdup(from);};
131 void SetTo(const char* to){if(mTo)free(mTo); mTo = strdup(to);};
132 void SetAnchor(const int i){mAnchor = i;};
133 friend std::ostream& operator <<(std::ostream& out,VCGEdge & v);
134
135 int GetThickness()const {return mThickness;};
136 char* GetFrom()const {return mFrom;};
137 char* GetTo()const {return mTo;};
138 int GetAnchor()const {return mAnchor;};
139
140private:
141 int mThickness;
142 char* mFrom; //Source node
143 char* mTo; //Destination Node
144 int mAnchor; //The point it is attaching to
145
146};
147
148#endif
Definition PNode.h:45
Definition VCG.h:123
~VCGEdge()
Standard Destructor for the 'Edge' class.
Definition VCG.cpp:363
void SetFrom(const char *from)
Definition VCG.h:130
VCGEdge()
Standard Constructor for the 'Edge' class.
Definition VCG.cpp:340
char * GetTo() const
Definition VCG.h:137
void SetThickness(const int thickness)
Definition VCG.h:129
char * GetFrom() const
Definition VCG.h:136
int GetAnchor() const
Definition VCG.h:138
void SetAnchor(const int i)
Definition VCG.h:132
int GetThickness() const
Definition VCG.h:135
void SetTo(const char *to)
Definition VCG.h:131
friend std::ostream & operator<<(std::ostream &out, VCGEdge &v)
Definition VCG.h:62
int GetWidth() const
Definition VCG.h:73
void AddNode(VCGNode *node)
Definition VCG.cpp:214
void OutputNodes(std::ostream &out)
Definition VCG.cpp:252
char * GetColor() const
Definition VCG.h:77
void AddEdge(VCGEdge *edge)
Definition VCG.cpp:209
~VCGGraph()
Standard Destructor for the 'Graph' class.
Definition VCG.cpp:202
char * GetTitle() const
Definition VCG.h:72
int GetHeight() const
Definition VCG.h:74
void OutputEdges(std::ostream &out)
Definition VCG.cpp:268
friend std::ostream & operator<<(std::ostream &out, VCGGraph &v)
bool GetSplines() const
Definition VCG.h:71
VCGGraph()
Standard Constructor for the 'Graph' class.
Definition VCG.cpp:186
void SetTitle(const char *title)
Definition VCG.h:67
int GetY() const
Definition VCG.h:76
int GetX() const
Definition VCG.h:75
Definition VCG.h:98
void SetTitle(const char *title)
Definition VCG.h:104
char * GetLabel() const
Definition VCG.h:110
VCGNode()
Standard Constructor for the 'Graph' class.
Definition VCG.cpp:288
void SetLabel(const char *label)
Definition VCG.h:105
void SetBorderColor(const char *color)
Definition VCG.h:107
char * GetTitle() const
Definition VCG.h:109
void SetShape(const char *shape)
Definition VCG.h:106
char * GetShape() const
Definition VCG.h:111
char * GetBorderColor() const
Definition VCG.h:112
~VCGNode()
Standard Destructor for the 'Graph' class.
Definition VCG.cpp:316
friend std::ostream & operator<<(std::ostream &out, VCGNode &v)
Definition VCG.h:44
~VCG()
Standard Destructor for Main VCG class.
Definition VCG.cpp:59
void PrintGraph()
Definition VCG.cpp:71
void Evaluate(const PNode *node, const char *parent, const int anchor)
Definition VCG.cpp:82
void MakeGraph(const PNode *node)
Definition VCG.cpp:65
VCG()
Standard Constructor for Main VCG class.
Definition VCG.cpp:50