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

📄 transitionarrow.c

📁 这个工具集提供以下结构化分析和UML分析中所用的图形化绘图工具:ER-diagrams, data and event flow diagrams and state-transition diagr
💻 C
📖 第 1 页 / 共 2 页
字号:
			pt.x -= HLINEXOFFSET;			pt.y -= 2*HLINEYOFFSET;			event->UpdatePosition(&pt);			return event;		}		else {			// if there are actions return the first one.			if (actions->count() > 0) {				// return the first action.				TextShape *t = (*actions)[0];				return t;			}			// create a new action.			else {				TextShape *t = new TextShape(					GetView(), GetGrafport(), this);				t->SetAlignment(TextAlign::LEFT);				t->SetSequence(0);				t->SetDescription("Action");				t->SetFont(GetName()->GetFont());				actions->add(t);				CalcPositionActions();				// move the action a bit up.				Point pt = *t->GetPosition();				pt.x = (hlineFrom.x + hlineTo.x)/2;				pt.y -= HLINEYOFFSET;				t->SetPosition(&pt);				return t;			}		}	}	// hit some spot on line (but not the hline or a label).	// Recalculate hline position.	if (GetViewer()->IsEditing() && GetViewer()->IsInlineEdit())		return 0;	Point *pt1, *pt2;	int xx, yy;	if (!GetLine()->first())		return 0;	else		pt1 = GetLine()->cur();	SetLineNumber(1);	while (GetLine()->next()) {		pt2 = GetLine()->cur();		if (ContainsPtLine(x, y, pt1, pt2, xx, yy))			break; 		pt1 = pt2;		if (GetLineNumber() < GetLine()->count()-1)			SetLineNumber(GetLineNumber()+1);	}	UpdatePosition();	// hit (empty ?) event string.	if (y <= hlineFrom.y) {		return event;	}	else {		if (actions->count() > 0) {			// return last action.			TextShape *t = (*actions)[actions->count()-1];			return t;		}		else {			// create new action.			TextShape *t = new TextShape(				GetView(), GetGrafport(), this);			t->SetDescription("Action");			t->SetAlignment(TextAlign::LEFT);			t->SetSequence(0);			t->SetFont(GetName()->GetFont());			actions->add(t);			CalcPositionActions();			Point pt = *t->GetPosition();			pt.x = (hlineFrom.x + hlineTo.x)/2;			pt.y -= HLINEYOFFSET;			t->SetPosition(&pt);			return t;		}	}}bool TransitionArrow::HasTextShape(TextShape *t) const {	if (Line::HasTextShape(t))		return True;	else if (event == t)		return True;	for (actions->first(); !actions->done(); actions->next())		if (actions->cur() == t)			return True;	return False;}int TransitionArrow::GetLeftMost() const {	int a = Line::GetLeftMost();	int b = event->GetLeftMost();	for (actions->first(); !actions->done(); actions->next()) {		int c = actions->cur()->GetLeftMost();		if (c < b)			b = c;	}	return min(a, b);}int TransitionArrow::GetTopMost() const {	int a = Line::GetTopMost();	int b = event->GetTopMost();	for (actions->first(); !actions->done(); actions->next()) {		int c = actions->cur()->GetTopMost();		if (c < b)			b = c;	}	return min(a, b);}int TransitionArrow::GetRightMost() const {	int a = Line::GetRightMost();	int b = event->GetRightMost();	for (actions->first(); !actions->done(); actions->next()) {		int c = actions->cur()->GetRightMost();		if (c > b)			b = c;	} 	return max(a, b);}int TransitionArrow::GetBottomMost() const {	int a = Line::GetBottomMost();	int b = event->GetBottomMost();	for (actions->first(); !actions->done(); actions->next()) {		int c = actions->cur()->GetBottomMost();		if (c > b)			b = c;	} 	return max(a, b);}const char *TransitionArrow::Sep2String(SepType sep) {	if (sep == LEFT)		return "Left";	else if (sep == RIGHT)		return "Right";	else if (sep == UP)		return "Up";	else // (sep == DOWN)		return "Down";}TransitionArrow::SepType TransitionArrow::String2Sep(const string *s) {	if (*s %= "Left")		return LEFT;	else if (*s %= "Right")		return RIGHT;	else if (*s %= "Up")		return UP;	else // (*s %= "Down")		return DOWN;}void TransitionArrow::WriteMembers(OutputFile *ofile) {	Line::WriteMembers(ofile);	(*ofile) << "\t{ AnchorPoint " << anchorPoint << " }\n";	(*ofile) << "\t{ Separator " << Sep2String(separator) << " }\n";	(*ofile) << "\t{ LineNumber " << GetLineNumber() << " }\n";}bool TransitionArrow::ReadMembers(InputFile *ifile, double format) {	string val1, val2;	if (!Line::ReadMembers(ifile, format))		return False;	if (format <= 1.10) {		if (!ifile->ReadAttribute2("HLineFrom", &val1, &val2))			return False;		hlineFrom = Point(val1.toint(), val2.toint());		if (!ifile->ReadAttribute2("HLineTo", &val1, &val2))			return False;		hlineTo = Point(val1.toint(), val2.toint());	}	else { // (format >= 1.11)		if (!ifile->ReadAttribute2("AnchorPoint", &val1, &val2))			return False;		anchorPoint = Point(val1.toint(), val2.toint());		if (!ifile->ReadAttribute("Separator", &val1))			return False;		separator = String2Sep(&val1);		if (!ifile->ReadAttribute("LineNumber", &val1))			return False;		SetLineNumber(val1.toint());	}	return True;}bool TransitionArrow::SetAssocSubject(AssocList *al) {	if (!Line::SetAssocSubject(al))		return False;	if (check(GetSubject() && 		  GetSubject()->GetClassType() == Code::TRANSITION))		return True;	SetSubject(0);	return False;}void TransitionArrow::SetTextShape() {	int n = GetLineNumber(); // line number has to stay unaltered.	Line::SetTextShape();	SetLineNumber(max(1, min(n, GetLine()->count()-1)));	if (check(GetSubject() && GetSubject()->GetClassType() == Code::TRANSITION))		event->SetString(((Transition *)GetSubject())->GetEvent());	event->SetParent(this);	actions->clear();	if (!check(GetSubject()))		return;	unsigned numItems = ((Transition *)GetSubject())->NrActions();	for (unsigned i=0; i<numItems; i++) {		TextShape *t = new TextShape(GetView(), GetGrafport(), this);		t->SetDescription("Action");		t->SetFont(GetName()->GetFont());		t->SetAlignment(TextAlign::LEFT);		t->SetSequence(i);		t->SetString(((Transition *)GetSubject())->GetAction(i));		t->SetParent(this);		actions->add(t);	}	CalcHLinePart();}void TransitionArrow::SetGrafport(Grafport *g) {	Line::SetGrafport(g);	for (actions->first(); !actions->done(); actions->next()) 		actions->cur()->SetGrafport(g);	event->SetGrafport(g);}void TransitionArrow::SetView(ShapeView *v) {	Line::SetView(v);	for (actions->first(); !actions->done(); actions->next()) 		actions->cur()->SetView(v);	event->SetView(v);}void TransitionArrow::SetFont(XFont *ft) {	Line::SetFont(ft);	for (actions->first(); !actions->done(); actions->next())		actions->cur()->SetFont(ft);	event->SetFont(ft);	CalcHLinePart();}void TransitionArrow::SetTextColor(const string *c) {	Line::SetTextColor(c);	for (actions->first(); !actions->done(); actions->next())		actions->cur()->SetColor(c);	event->SetColor(c);}void TransitionArrow::SetAction(const string *s, unsigned n, bool update) {	if (update) {		if (n > actions->count())			error("%s, line %d: impl error: "			  "illegal action nr %d\n", __FILE__, __LINE__, n);		else if (n == actions->count()) {			// insert new action.			TextShape *t = new TextShape(GetView(), GetGrafport(), this);			t->SetDescription("Action");			t->SetAlignment(TextAlign::LEFT);			t->SetSequence(n);			t->SetFont(GetName()->GetFont());			actions->add(t);		}		if (*s != "")			// update existing action			(*actions)[n]->SetString(s);		else {			// delete existing action			unsigned i = actions->count() -1;			for (unsigned j = n; j < i; j++) {				const string *nm = (*actions)[j+1]->GetString();				(*actions)[j]->SetString(nm);			}			TextShape *x = (*actions)[i];			actions->removei(i);			delete x;		}	}	else {		if (n > actions->count())			error("%s, line %d: impl error: "			  "illegal action nr %d\n", __FILE__, __LINE__, n);		else if (*s != "") {			// insert new action.			TextShape *t = new TextShape(GetView(), GetGrafport(), this);			t->SetDescription("Action");			t->SetAlignment(TextAlign::LEFT);			t->SetSequence(n);			t->SetString(s);			t->SetFont(GetName()->GetFont());			actions->insert(t, n);			for (unsigned i=n+1; i<actions->count(); i++)				(*actions)[i]->SetSequence(i);		}		// ignore empty strings;	}}bool TransitionArrow::HasString(const string *s, bool sens, bool sub) const {	if (*s != "" && event->HasString(s, sens, sub))		return True;	for (actions->first(); !actions->done(); actions->next()) {		if (actions->cur()->HasString(s, sens, sub))			return True;	}	return False;}bool TransitionArrow::HasString(const string *s, bool sens, bool sub, 			List<TextShape *> *list) {	if (*s == "")		return 0;	bool b = event->HasString(s, sens, sub, list);	List<TextShape *> actions2 (*actions);	for (actions2.first(); !actions2.done(); actions2.next())		b += actions2.cur()->HasString(s, sens, sub, list);	return b;}void TransitionArrow::MoveRaw(const Point *delta) {	Line::MoveRaw(delta);	for (actions->first(); !actions->done(); actions->next())		actions->cur()->Move(delta);	event->Move(delta);	anchorPoint = anchorPoint+*delta;	CalcPositionHLine();}

⌨️ 快捷键说明

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