⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcfdiagram.c

📁 这个工具集提供以下结构化分析和UML分析中所用的图形化绘图工具:ER-diagrams, data and event flow diagrams and state-transition diagr
💻 C
📖 第 1 页 / 共 2 页
字号:
//////////////////////////////////////////////////////////////////////////////////// This file is part of Toolkit for Conceptual Modeling (TCM).// (c) copyright 1995, Vrije Universiteit Amsterdam.// Author: Frank Dehne (frank@cs.vu.nl).//// TCM is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// TCM is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with TCM; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA// 02111-1307, USA.////////////////////////////////////////////////////////////////////////////////#include "dcfwindow.h"#include "dcfgraph.h"#include "dcfviewer.h"#include "dcfstubs.h"#include "dcfchecks.h"#include "externalentity.h"#include "datastore.h"#include "eventstore.h"#include "dataprocess.h"#include "controlprocess.h"#include "splitmergenode.h"#include "bidirectionaldataflow.h"#include "continuousdataflow.h"#include "continuouseventflow.h"#include "square.h"#include "circle.h"#include "line.h"#include "horizontalbar.h"#include "textbox.h"#include "blackdot.h"#include "comment.h"#include "dcfdiagram.h"#include "togglelistdialog.h"#include <ctype.h> DCFDiagram::DCFDiagram(Config *c, DCFWindow *d, DCFViewer *v, DCFGraph *g): 		DFDiagram(c,d,v,g) {	UpdateNodeType(1);	UpdateEdgeType(1);	dcfChecks = new DCFChecks(this,g);	List<string *> l;	l.add(new string("Continuing			    "));	l.add(new string("Instantaneous			 "));	persistenceDialog = new ToggleListDialog(d->GetWidget(), False);	persistenceDialog->Initialize();	persistenceDialog->SetTitle("Process persistence");	persistenceDialog->CreateToggles(&l);	persistenceDialog->ManageCancelButton(False);	persistenceDialog->SetToggleChangedCallback(		DCFStubs::PersistenceOKCB, this);	l.clear();	l.add(new string("Stimulus			"));	l.add(new string("Time				"));	l.add(new string("Trigger			"));	l.add(new string("Unspecified			"));	activationDialog = new ToggleListDialog(d->GetWidget(), True);	activationDialog->Initialize();	activationDialog->SetTitle("Process activation");	activationDialog->CreateToggles(&l);	activationDialog->ManageCancelButton(False);	activationDialog->SetToggleChangedCallback(		DCFStubs::ActivationToggleCB, this);	activationDialog->SetOKCallback(DCFStubs::ActivationOKCB, this);	l.clear();}DCFDiagram::~DCFDiagram() {	delete dcfChecks;	delete activationDialog;	delete persistenceDialog;}Thing *DCFDiagram::CreateThing(int classNr) {	Grafport *g = GetDiagramViewer()->GetGrafport();	ShapeView *v = GetDiagramViewer()->GetCurView();	DCFGraph *dg = (DCFGraph *)GetGraph();	Thing *thing = 0;	// view	if (classNr == Code::VIEW)		thing = new ShapeView(GetDiagramViewer());	// node shapes	else if (classNr == Code::SQUARE)		thing = new Square(v, g, 0, 0);	else if (classNr == Code::HORIZONTAL_BAR)		thing = new HorizontalBar(v, g, 0, 0);	else if (classNr == Code::CIRCLE) {		Circle *c = new Circle(v, g, 0, 0);		c->SetFixedIndexLabel(False);		thing = c;	}	else if (classNr == Code::BLACK_DOT)		thing = new BlackDot(v, g, 0, 0);	else if (classNr == Code::TEXT_BOX)		thing = new TextBox(v, g, 0, 0);	// lines	else if (classNr == Code::LINE)		thing = new Line(v, g, 0, 0, 0);	else if (classNr == Code::ARROW) {		Line *line = new Line(v, g, 0, 0, 0);		line->SetEnd1(LineEnd::EMPTY);		line->SetEnd2(LineEnd::FILLED_ARROW);		thing = line;	}	else if (classNr == Code::DOUBLE_ARROW) {		Line *line = new Line(v, g, 0, 0, 0);		line->SetEnd1(LineEnd::FILLED_ARROW);		line->SetEnd2(LineEnd::FILLED_ARROW);		thing = line;	}	else if (classNr == Code::DOUBLE_HEADED_ARROW) {		Line *line = new Line(v, g, 0, 0, 0);		line->SetEnd1(LineEnd::EMPTY);		line->SetEnd2(LineEnd::DOUBLE_FILLED_ARROW);		thing = line;	}	// nodes	else if (classNr == Code::EXTERNAL_ENTITY)		thing = new ExternalEntity(dg);	else if (classNr == Code::DATA_STORE)		thing = new DataStore(dg);	else if (classNr == Code::DATA_PROCESS)		thing = new DataProcess(dg);	else if (classNr == Code::SPLIT_MERGE_NODE)		thing = new SplitMergeNode(dg);	else if (classNr == Code::CONTROL_PROCESS)		thing = new ControlProcess(dg);	else if (classNr == Code::EVENT_STORE)		thing = new EventStore(dg);	else if (classNr == Code::COMMENT)		thing = new Comment(dg);	// edges	else if (classNr == Code::DATA_FLOW)		thing = new DataFlow(dg, 0, 0);	else if (classNr == Code::BIDIRECTIONAL_DATA_FLOW)		thing = new BidirectionalDataFlow(dg, 0, 0);	else if (classNr == Code::EVENT_FLOW)		thing = new EventFlow(dg, 0, 0);	else if (classNr == Code::CONTINUOUS_DATA_FLOW)		thing = new ContinuousDataFlow(dg, 0, 0);	else if (classNr == Code::CONTINUOUS_EVENT_FLOW)		thing = new ContinuousEventFlow(dg, 0, 0);	else		error("%s, line %d: impl error: "			"wrong class number %d\n", __FILE__, __LINE__, classNr);	return thing;}Node *DCFDiagram::CreateNode(){	Node *node = 0;	DCFGraph *g = (DCFGraph *)GetGraph();	if (GetNodeType() == Code::EXTERNAL_ENTITY)		node = new ExternalEntity(g);	else if (GetNodeType() == Code::DATA_PROCESS)		node = new DataProcess(g);	else if (GetNodeType() == Code::CONTROL_PROCESS)		node = new ControlProcess(g);	else if (GetNodeType() == Code::DATA_STORE)		node = new DataStore(g);	else if (GetNodeType() == Code::EVENT_STORE)		node = new EventStore(g);	else if (GetNodeType() == Code::SPLIT_MERGE_NODE)		node = new SplitMergeNode(g);	else if (GetNodeType() == Code::COMMENT)		node = new Comment(g);	else		error("%s, line %d: unknown node type\n", __FILE__, __LINE__);	return node;}Edge *DCFDiagram::CreateEdge(Subject *subj1, Subject *subj2){	if (!CheckEdgeConstraints(subj1, subj2))		return 0;	Edge *edge = 0;	DCFGraph *g = (DCFGraph *)GetGraph();	if (GetEdgeType() == Code::DATA_FLOW)		edge = new DataFlow(g, subj1, subj2);	else if (GetEdgeType() == Code::BIDIRECTIONAL_DATA_FLOW)		edge = new BidirectionalDataFlow(g, subj1, subj2);	else if (GetEdgeType() == Code::EVENT_FLOW)		edge = new EventFlow(g, subj1, subj2);	else if (GetEdgeType() == Code::CONTINUOUS_DATA_FLOW)		edge = new ContinuousDataFlow(g, subj1, subj2);	else if (GetEdgeType() == Code::CONTINUOUS_EVENT_FLOW)		edge = new ContinuousEventFlow(g, subj1, subj2);	else		error("%s, line %d: unknown edge type\n", __FILE__, __LINE__);	return edge;}NodeShape *DCFDiagram::CreateNodeShape(Node *node, int x, int y){	NodeShape *shape = 0;	Grafport *g = GetDiagramViewer()->GetGrafport();	ShapeView *v = GetDiagramViewer()->GetCurView();	if (GetNodeShapeType() == Code::CIRCLE) {		Circle *c = new Circle(v, g, x, y);		c->SetFixedIndexLabel(False);		shape = c;	}	else if (GetNodeShapeType() == Code::SQUARE)		shape = new Square(v, g, x, y);	else if (GetNodeShapeType() == Code::HORIZONTAL_BAR)		shape = new HorizontalBar(v, g, x, y);	else if (GetNodeShapeType() == Code::BLACK_DOT)		shape = new BlackDot(v, g, x, y);	else if (GetNodeShapeType() == Code::TEXT_BOX)		shape = new TextBox(v, g, x, y);	else		error("%s, line %d: impl error: "			"node shape type does not exist\n", __FILE__, __LINE__);		if (check(shape)) {		shape->SetSubject(node);		shape->SetTextShape();	}	return shape;}Line *DCFDiagram::CreateLine(		Edge *edge, GShape *from, GShape *to, List<Point *> *l) {	Grafport *g = GetDiagramViewer()->GetGrafport();	ShapeView *v = GetDiagramViewer()->GetCurView();	Line *line = 0;	if (GetLineType() == Code::LINE)		line = new Line(v, g, from, to, l, IsCurve());	else 		error("%s, line %d: impl error: "			"line type does not exist\n", __FILE__, __LINE__);		if (check(line)) {		line->SetSubject(edge);		line->SetTextShape();		line->SetEnd1(GetLineEnd1());		line->SetEnd2(GetLineEnd2());	}	return line;}void DCFDiagram::UpdateNodeType(int num) {	((DiagramWindow *)GetMainWindow())->SetNodeName(num);	switch (num) {	case 1: SetNodeType(Code::DATA_PROCESS);		SetNodeShapeType(Code::CIRCLE);		SetNodeLineStyle(LineStyle::SOLID);		break;	case 2: SetNodeType(Code::CONTROL_PROCESS);		SetNodeShapeType(Code::CIRCLE);		SetNodeLineStyle(LineStyle::DASHED);		break;	case 3: SetNodeType(Code::EXTERNAL_ENTITY);		SetNodeShapeType(Code::SQUARE);		SetNodeLineStyle(LineStyle::SOLID);		break;	case 4: SetNodeType(Code::DATA_STORE);		SetNodeShapeType(Code::HORIZONTAL_BAR);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -