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

📄 ssdtripleclassbox.c

📁 这个工具集提供以下结构化分析和UML分析中所用的图形化绘图工具:ER-diagrams, data and event flow diagrams and state-transition diagr
💻 C
📖 第 1 页 / 共 2 页
字号:
                pt.y = GetTopMost() + nameHeight/2;        GetName()->SetPosition(&pt);        pt.y = GetTopMost() + snpHeight;        pt.y += (3*textHeight)/4;        for (GetLabels()->first(); !GetLabels()->done(); GetLabels()->next()) {                TextShape *t = GetLabels()->cur();                // position and left adjust textshape                int w = t->GetStringWidth();                pt.x = GetLeftMost() + w/2 + TEXTMARGIN;                t->SetPosition(&pt);                pt.y += textHeight;        }	//  Operation part	CalcPositionLabels2();        // set index label position.        pt.x = GetName()->GetPosition()->x + GetWidth()*5/12;        pt.y = GetName()->GetPosition()->y - nameHeight/4;        GetIndexLabel()->SetPosition(&pt);	if (showStereotype)		CalcPositionStereotypeLabel();        if (showProperties)                CalcPositionPropertiesLabel();}void SSDTripleClassBox::CalcPositionLabels2() {        Point pt = *GetPosition();        pt.y = GetTopMost() + DoubleBoxHeight();        int textHeight = GetName()->GetFontHeight();        pt.y += (3*textHeight)/4;        for (GetLabels2()->first(); !GetLabels2()->done(); GetLabels2()->next()) {                TextShape *t = GetLabels2()->cur();                // position and left adjust textshape                int w = t->GetStringWidth();                // int h = t->GetHeight();                pt.x = GetLeftMost() + w/2 + TEXTMARGIN;                t->SetPosition(&pt);                pt.y += textHeight;        }}void SSDTripleClassBox::CalcPositionStereotypeLabel() {        int textHeight = GetName()->GetFontHeight();        Point pt;        pt.x = GetPosition()->x;        pt.y = GetTopMost() + textHeight/2;        stereotypeLabel->SetPosition(&pt);}void SSDTripleClassBox::CalcPositionPropertiesLabel() {        int textHeight = GetName()->GetFontHeight();	int addLines = (showStereotype ? 1 : 0);	// min_firstboxlines : 2 when no <<stereotype>> / {props} shown	int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);        int snHeight = (addLines+labelLines) * textHeight;        int propHeight = (showProperties ?                        GetPropertiesLabelString()->lines()*textHeight : 0);        Point pt;        pt.x = GetPosition()->x;        pt.y = GetTopMost() + snHeight + propHeight/2;        propertiesLabel->SetPosition(&pt);}int SSDTripleClassBox::RequiredHeight() {        // int textHeight = GetName()->GetFontHeight();	int addLines = (showStereotype ? 1 : 0);	// min_firstboxlines : 2 when no <<stereotype>> / {props} shown	// int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);        // int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);	// calculate first_compartmentHeight        if (showProperties)                addLines += GetPropertiesLabelString()->lines();        // int snpHeight = (addLines+labelLines) * textHeight;        // int propHeight = GetPropertiesLabelString()->lines() * textHeight;         // int ht = (snpHeight + textHeight + GetLabels()->count()*textHeight);        // int ht2 = (snpHeight + int(1.5*textHeight) + GetLabels()->count()*textHeight +        //		textHeight + GetLabels2()->count()*textHeight);	// int dboxHeight = DoubleBoxHeight();	int tboxHeight = TripleBoxHeight();        return max(tboxHeight, GetInitialHeight());}int SSDTripleClassBox::RequiredWidth() {	int twidth = GetName()->GetWidth();	if (showStereotype)		twidth = max(twidth, GetStereotypeLabel()->GetWidth());	if (showProperties)		twidth = max(twidth, GetPropertiesLabel()->GetWidth());	// Labels	for (GetLabels()->first(); !GetLabels()->done(); GetLabels()->next()) {		int wd = GetLabels()->cur()->GetStringWidth();		twidth = max(twidth, wd);	}	for (GetLabels2()->first(); !GetLabels2()->done(); GetLabels2()->next()) {		int wd = GetLabels2()->cur()->GetStringWidth();		twidth = max(twidth, wd);	}        return twidth;}int SSDTripleClassBox::DoubleBoxHeight() {        int textHeight = GetName()->GetFontHeight();	int addLines = (showStereotype ? 1 : 0);	// min_firstboxlines : 2 when no <<stereotype>> / {props} shown	int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);	// calculate first_compartmentHeight        if (showProperties)                addLines += GetPropertiesLabelString()->lines();        int snpHeight = (addLines+labelLines) * textHeight;        if (NrLabels() == 0)                return int(snpHeight + 1.5*textHeight);        else                return int(snpHeight + (1 + NrLabels())*textHeight);}int SSDTripleClassBox::TripleBoxHeight() {        int rval1, rval2;        int textHeight = GetName()->GetFontHeight();	int addLines = (showStereotype ? 1 : 0);	// min_firstboxlines : 2 when no <<stereotype>> / {props} shown	int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);	// calculate first_compartmentHeight        if (showProperties)                addLines += GetPropertiesLabelString()->lines();        int snpHeight = (addLines+labelLines) * textHeight;        if (NrLabels() == 0)                rval1 = int(snpHeight + 1.5*textHeight);        else                rval1 = int(snpHeight + (1 + NrLabels())*textHeight);        if (NrLabels2() == 0)                rval2 = int(1.0*textHeight);        else                rval2 = int((1 + NrLabels2())*textHeight);	return (rval1+rval2);}TextShape *SSDTripleClassBox::ChooseTextShape(int x, int y) {        // in first part (of the class name) ?        int textHeight = GetName()->GetFontHeight();	int addLines = (showStereotype ? 1 : 0);	// min_firstboxlines : 2 when no <<stereotype>> / {props} shown	int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);        int snHeight = (addLines+labelLines) * textHeight;	// calculate first_compartmentHeight        if (showProperties)                addLines += GetPropertiesLabelString()->lines();        int snpHeight = (addLines+labelLines) * textHeight;        int dboxHeight = DoubleBoxHeight();        int pos_y = GetTopMost() + snpHeight;        int attr_y = GetTopMost() + dboxHeight;        if (y <= pos_y) {                if (showStereotype) {                        if (y <= GetTopMost() + textHeight)                                return GetStereotypeLabel();                }                if (GetViewer()->IsShowIndexes() && !IsFixedIndexLabel()) {                        if (y <= GetName()->GetPosition()->y &&                            x >= GetName()->GetPosition()->x + GetWidth()/3)                                return GetIndexLabel();                }                if (y > GetTopMost() + snHeight)                        return GetPropertiesLabel();                if (!IsFixedName())                        return GetName();        }	else if (y <= attr_y) {		// in attribute part		pos_y += textHeight/2;		for (GetLabels()->first(); !GetLabels()->done();		     GetLabels()->next()) {			pos_y += textHeight;			if (pos_y >= GetBottomMost())				return 0;			else if (y <= pos_y)				return GetLabels()->cur();		}		if (GetViewer()->IsEditing())			return 0;		// somewhere down the list; create a new label.		TextShape *t = new TextShape(GetView(), GetGrafport(), this);		t->SetAlignment(TextAlign::LEFT);		t->SetSequence(GetLabels()->count());		t->SetDescription(&labelDescription);		t->SetFont(GetName()->GetFont());		t->SetColor(GetName()->GetColor());		Undraw();		GetLabels()->add(t);//		CalcPositionLabels();		// move text shape to a better position.		Point pt = *t->GetPosition();		pt.x += GetWidth()/2 - TEXTMARGIN;		t->SetPosition(&pt);		Draw();		return t;        }	else {	// in operation part        	pos_y = GetTopMost() + dboxHeight;		pos_y += textHeight/2;		for (GetLabels2()->first(); !GetLabels2()->done();		     GetLabels2()->next()) {			pos_y += textHeight;			if (pos_y >= GetBottomMost())				return 0;			else if (y <= pos_y)				return GetLabels2()->cur();		}		if (GetViewer()->IsEditing())			return 0;		// somewhere down the list; create a new label.		TextShape *t = new TextShape(GetView(), GetGrafport(), this);		t->SetAlignment(TextAlign::LEFT);		t->SetSequence(GetLabels2()->count());		t->SetDescription(&label2Description);		t->SetFont(GetName()->GetFont());		t->SetColor(GetName()->GetColor());		Undraw();		GetLabels2()->add(t);		CalcPositionLabels2();		// move text shape to a better position.		Point pt = *t->GetPosition();		pt.x += GetWidth()/2 - TEXTMARGIN;		t->SetPosition(&pt);		Draw();		return t;	}	return 0;	// dummy statement shuts up compiler}void SSDTripleClassBox::UpdateStereotypeLabelString(const string *s) {        if (IsVisible())                Undraw();        SetStereotypeLabelString(s);        if (IsVisible())                Draw();} void SSDTripleClassBox::UpdatePropertiesLabelString(const string *s) {        if (IsVisible())                Undraw();        SetPropertiesLabelString(s);        if (IsVisible())                Draw();} bool SSDTripleClassBox::ReadMembers(InputFile *ifile, double format) {        if (!TripleClassBox::ReadMembers(ifile, format))                return False;        if (format >= 1.28) {                string val;                if (!ifile->ReadAttribute("ShowStereotype", &val))                        return False;                showStereotype = (val == "True");                if (!ifile->ReadAttribute("ShowProperties", &val))                        return False;                showProperties = (val == "True");        }        else {                showStereotype = False;                showProperties = False;        }	return True;} void SSDTripleClassBox::WriteMembers(OutputFile *ofile) {        TripleClassBox::WriteMembers(ofile);        (*ofile) << "\t{ ShowStereotype " << (showStereotype?"True":"False") << " }\n";        (*ofile) << "\t{ ShowProperties " << (showProperties?"True":"False") << " }\n";}

⌨️ 快捷键说明

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