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

📄 scdiagram.c

📁 这个工具集提供以下结构化分析和UML分析中所用的图形化绘图工具:ER-diagrams, data and event flow diagrams and state-transition diagr
💻 C
📖 第 1 页 / 共 3 页
字号:
      sinf->logicalId= csd->NextId();      sinf->shapeId= csd->NextId();      stimY= 110; // initial position in the temporal line      sinf->y= stimY;      sinf->isComment= True;      csd->stimuli.add (sinf);    }    row= asd->rows[i];     if (i==0)      formerState= currentState= row->GetCurrentState();    else{      formerState= currentState;      currentState= row->GetCurrentState();    }    found= False;    k= formerState+1;    while (k<=currentState && !found){      if (::isStable[k])	found= True;      else	k++;    }       if (found){        sinf= new StimulusInfo();        sinf->sender= csd->participants[0];        sinf->receiver= csd->participants[csd->participants.count()-1];        sinf->label= stable;        sinf->logicalId= csd->NextId();        sinf->shapeId= csd->NextId();        stimY+=50;        sinf->y= stimY;        sinf->isComment= True;        csd->stimuli.add (sinf);    }    for (j=0; j< asd->numObjs; j++){      ip= &(row->participants[j]);      for (ev=0; ev< ip->GetNumberOfEvents(); ev++){	pair= ip->GetPairObjEv (ev);	sinf= new StimulusInfo();	sinf->sender= csd->participants[j];	sinf->receiver= csd->participants[pair->GetObj()];	sinf->label= pair->GetEv();	sinf->logicalId= csd->NextId();	sinf->shapeId= csd->NextId();	stimY+=50;	sinf->y= stimY;	sinf->isComment= False;		stim1= new Stimulus();	stim2= new Stimulus();	stim1->isSender= True;	stim2->isSender= False;	stim1->info= sinf;	stim2->info= sinf;		csd->participants[j]->anchors.add (stim1); //Sender	if (j!=pair->GetObj()) // if it is not an event to self	    csd->participants[pair->GetObj()]->anchors.add (stim2); //Receiver	csd->stimuli.add (sinf);      } //end of loop in ev    } //end of loop in j    // We add a new comment to mark the end of the microstep or the stability of the system.    sinf= new StimulusInfo();    sinf->sender= csd->participants[0];    sinf->receiver= csd->participants[csd->participants.count()-1];    sinf->label= microstep;    sinf->logicalId= csd->NextId();    sinf->shapeId= csd->NextId();    stimY+=50;    sinf->y= stimY;    sinf->isComment= True;    csd->stimuli.add (sinf);  } //end of loop in i  if (::isStable[::statecounter-1]){ //The system finishes stable    sinf= new StimulusInfo();    sinf->sender= csd->participants[0];    sinf->receiver= csd->participants[csd->participants.count()-1];    sinf->label= stable;    sinf->logicalId= csd->NextId();    sinf->shapeId= csd->NextId();    stimY+=50;    sinf->y= stimY;    sinf->isComment= True;    csd->stimuli.add (sinf);  }  csd->lineLength= stimY+50;  return csd;}void SCDiagram::GenerateSeqDiagFile (ConcreteSequenceDiagram *csd, const string *formula){    string filen= "cntex.sqd";  OutputFile *fp;  if (csd==NULL) return;  fp= new OutputFile();  fp->Open (&filen);  (*fp) << "Storage\n";  (*fp) << "{\n";  (*fp) << "\t{ Format 1.32 }\n";  (*fp) << "\t{ GeneratedFrom TSCD-version-2.10a }\n";  (*fp) << "\t{ WrittenBy tcm }\n";  (*fp) << "\t{ WrittenOn \"Sat Jul  6 17:16:35 2002\" }\n";  (*fp) << "\t}\n\n";  (*fp) << "Document\n";  (*fp) << "{\n";  (*fp) << "\t{ Type \"Sequence Diagram\" }\n";  (*fp) << "\t{ Name cntex.sqd }\n";  (*fp) << "\t{ Author tcm }\n";  (*fp) << "\t{ CreatedOn \"Sat Jul  6 14:14:12 2002\" }\n";  (*fp) << "\t{ Annotation \"\" }\n";  (*fp) << "}\n\n";  (*fp) << "Page\n";  (*fp) << "{\n";  (*fp) << "\t{ PageOrientation Portrait }\n";  (*fp) << "\t{ PageSize A4 }\n";  (*fp) << "\t{ ShowHeaders False }\n";  (*fp) << "\t{ ShowFooters False }\n";  (*fp) << "\t{ ShowNumbers False }\n";  (*fp) << "}\n\n";  (*fp) << "Scale\n";  (*fp) << "{\n";  (*fp) << "\t{ ScaleValue 1 }\n";  (*fp) << "}\n\n";  (*fp) << "# GRAPH NODES\n\n";  GenerateGraphNodes (csd, fp);  GenerateComments (csd, fp);  GenerateNote (csd, fp, formula);  GenerateGraphEdges (csd, fp);  (*fp) << "# VIEWS AND GRAPHICAL SHAPES\n";  (*fp) << "\n";  (*fp) << "View 1\n";  (*fp) << "{\n";  (*fp) << "\t{ Index \"0\" }\n";  (*fp) << "\t{ Parent 0 }\n";  (*fp) << "}\n\n";  GenerateObjectBoxes (csd, fp);  GenerateT4Lines (csd, fp);  GenerateTextBoxes (csd, fp);  GenerateNoteBox (csd, fp);  fp->Close();}void SCDiagram::GenerateGraphNodes (ConcreteSequenceDiagram *csd, OutputFile *fp){  int i, j;  ConcreteParticipant *cp;  if (csd==NULL || fp==NULL) return;   for (i=0; i< csd->participants.count(); i++){    cp= csd->participants[i];    (*fp) << "CBDObjectNode " << cp->logicalId << "\n";    (*fp) << "{\n";    (*fp) << "\t{ Name \"" << cp->name << "\" }\n";    (*fp) << "\t{ Annotation \"\" }\n";    (*fp) << "\t{ Parent 0 }\n";    (*fp) << "\t{ Index \"\" }\n";    (*fp) << "\t{ Stereotype \"<< - >>\" }\n";    (*fp) << "\t{ Properties \"{ - }\" }\n";    (*fp) << "\t{ Anchors " << cp->anchors.count() << " }\n"; //it's OK also for 0    for (j=0; j< cp->anchors.count(); j++){      (*fp) << "\t{ Anchor " << cp->anchors[j]->info->y << " ";      if (cp->anchors[j]->isSender)	(*fp) << cp->logicalId; // it puts its own number      else	(*fp) << cp->anchors[j]->info->sender->logicalId;            (*fp) << " }\n";    }    (*fp) << "}\n";  }}void SCDiagram::GenerateComments (ConcreteSequenceDiagram *csd, OutputFile *fp){  int i;  StimulusInfo *sinf;  if (csd==NULL || fp==NULL) return;  // We travel across the stimuli and issue a "Comment" section in the file every  // time we find a stimuli with a True isComment attribute.  for (i=0; i< csd->stimuli.count(); i++){    if (csd->stimuli[i]->isComment){      sinf= csd->stimuli[i];      (*fp) << "Comment " << sinf->logicalId << "\n";      (*fp) << "{\n";      (*fp) << "\t{ Name \"" << sinf->label << "\" }\n";      (*fp) << "\t{ Annotation \"\" }\n";      (*fp) << "\t{ Parent 0 }\n";      (*fp) << "\t{ Index \"\" }\n";      (*fp) << "}\n\n";    }  }}void SCDiagram::GenerateGraphEdges (ConcreteSequenceDiagram *csd, OutputFile *fp){  int i;  StimulusInfo *sinf;  if (csd==NULL || fp==NULL) return;  (*fp) << "# GRAPH EDGES\n\n";  for (i=0; i< csd->stimuli.count(); i++){    if (!csd->stimuli[i]->isComment){ //then it is a real stimulus      sinf= csd->stimuli[i];      (*fp) << "CBDObjectLinkEdge " << sinf->logicalId << "\n";      (*fp) << "{\n";      (*fp) << "\t{ Name \"" << sinf->label << "\" }\n";      (*fp) << "\t{ Annotation \"\" }\n";      (*fp) << "\t{ Parent 0 }\n";      (*fp) << "\t{ Subject1 " << sinf->sender->logicalId << " }\n";      (*fp) << "\t{ Subject2 " << sinf->receiver->logicalId << " }\n";      (*fp) << "\t{ Anchor1 " << sinf->y << " " << sinf->sender->shapeId << " }\n";      (*fp) << "\t{ Anchor2 " << sinf->y << " " << sinf->receiver->shapeId << " }\n";      (*fp) << "}\n\n";    }  }}void SCDiagram::GenerateObjectBoxes (ConcreteSequenceDiagram *csd, OutputFile *fp){  int i, len;  ConcreteParticipant *cp;  if (csd==NULL || fp==NULL) return;  for (i=0; i< csd->participants.count(); i++){    cp= csd->participants[i];    (*fp) << "SSDSingleObjectBox " << cp->shapeId << "\n";    (*fp) << "{\n";    (*fp) << "\t{ View 1 }\n";    (*fp) << "\t{ Subject " << cp->logicalId << " }\n";    (*fp) << "\t{ Position " << cp->x << " " << cp->y << " }\n";    (*fp) << "\t{ Size 80 40 }\n";    (*fp) << "\t{ Color \"black\" }\n";    (*fp) << "\t{ LineWidth 1 }\n";    (*fp) << "\t{ LineStyle Solid }\n";    (*fp) << "\t{ FillStyle Unfilled }\n";    (*fp) << "\t{ FillColor \"white\" }\n";    (*fp) << "\t{ FixedName False }\n";    (*fp) << "\t{ Font \"-*-helvetica-medium-r-normal--10*\" }\n";    (*fp) << "\t{ TextAlignment Center }\n";    (*fp) << "\t{ TextColor \"black\" }\n";    (*fp) << "\t{ NameUnderlined True }\n";    /* We need to know how long will be the lifeline of each object. We have chosen that        all the objects have the same length.    */    (*fp) << "\t{ EndPosition " << cp->x << " " << csd->lineLength << " }\n";    (*fp) << "\t{ Destructive 0 }\n";    (*fp) << "}\n\n";  }}void SCDiagram::GenerateT4Lines (ConcreteSequenceDiagram *csd, OutputFile *fp){  int i;  StimulusInfo *sinf;  int min;  if (csd==NULL || fp==NULL) return;  for (i=0; i< csd->stimuli.count(); i++){    sinf= csd->stimuli[i];    if (!sinf->isComment){      (*fp) << "T4Line " << sinf->shapeId << "\n";      (*fp) << "{\n";      (*fp) << "\t{ View 1 }\n";      (*fp) << "\t{ Subject " << sinf->logicalId << " }\n";      (*fp) << "\t{ FromShape " << sinf->sender->shapeId << " }\n";      (*fp) << "\t{ ToShape " << sinf->receiver->shapeId << " }\n";      (*fp) << "\t{ Curved False }\n";      (*fp) << "\t{ End1 Empty }\n";      (*fp) << "\t{ End2 FilledArrow }\n";      if (sinf->sender==sinf->receiver){ // event to self	// This kind of arrow consists of 4 points.	(*fp) << "\t{ Points 4 }\n";	(*fp) << "\t{ Point " << sinf->sender->x << " " << sinf->y << " }\n";	(*fp) << "\t{ Point " << (sinf->sender->x+20) << " " << sinf->y << " }\n";	(*fp) << "\t{ Point " << (sinf->sender->x+20) << " " << (sinf->y+10) << " }\n";	(*fp) << "\t{ Point " << sinf->sender->x << " " << (sinf->y+10) << " }\n";      }      else{ //event between two different participants	(*fp) << "\t{ Points 2 }\n";	(*fp) << "\t{ Point " << sinf->sender->x << " " << sinf->y << " }\n";	(*fp) << "\t{ Point " << sinf->receiver->x << " " << sinf->y << " }\n";      }      // The position of the name is fixed to 140 units from the smallest X of both objects      // and 10 units from the Y, unless it is an event to self. In that case, the offset is 20.      if (sinf->sender->x < sinf->receiver->x)	min= sinf->sender->x;      else	min= sinf->receiver->x;	      if (sinf->sender==sinf->receiver)	 (*fp) << "\t{ NamePosition " << (min+20) << " " << (sinf->y-10) << " }\n";      else         (*fp) << "\t{ NamePosition " << (min+140) << " " << (sinf->y-10) << " }\n";      (*fp) << "\t{ Color \"black\" }\n";      (*fp) << "\t{ LineWidth 1 }\n";      (*fp) << "\t{ LineStyle Solid }\n";      (*fp) << "\t{ FixedName False }\n";      (*fp) << "\t{ Font \"-*-helvetica-medium-r-normal--10*\" }\n";      (*fp) << "\t{ TextAlignment Center }\n";      (*fp) << "\t{ TextColor \"black\" }\n";      (*fp) << "\t{ NameUnderlined False }\n";      (*fp) << "}\n\n";    }  }}void SCDiagram::GenerateTextBoxes (ConcreteSequenceDiagram *csd, OutputFile *fp){  int i;  StimulusInfo *sinf;  if (csd==NULL || fp==NULL) return;  for (i=0; i< csd->stimuli.count(); i++){    sinf= csd->stimuli[i];    if (sinf->isComment){      (*fp) << "TextBox " << sinf->shapeId << "\n";      (*fp) << "{\n";      (*fp) << "\t{ View 1 }\n";      (*fp) << "\t{ Subject " << sinf->logicalId << " }\n";      (*fp) << "\t{ Position " << (sinf->sender->x+140) << " " << sinf->y << " }\n";      (*fp) << "\t{ Size 20 20 }";      (*fp) << "\t{ Color \"black\" }\n";      (*fp) << "\t{ LineWidth 1 }\n";      (*fp) << "\t{ LineStyle Invisible }\n";      (*fp) << "\t{ FillStyle Unfilled }\n";      (*fp) << "\t{ FillColor \"white\" }\n";      (*fp) << "\t{ FixedName False }\n";      (*fp) << "\t{ Font \"-*-helvetica-medium-r-normal--10*\" }\n";      (*fp) << "\t{ TextAlignment Center }\n";      (*fp) << "\t{ TextColor \"black\" }\n";      (*fp) << "\t{ NameUnderlined False }\n";      (*fp) << "}\n\n";     }  }}void SCDiagram::GenerateNote (ConcreteSequenceDiagram *csd, OutputFile *fp, const string *formula){  if (csd==NULL || fp==NULL || formula==NULL) return;  (*fp) << "Note " << csd->NextId() << "\n";  (*fp) << "{\n";  (*fp) << "\t{ Name \"Counterexample for\\r" << *formula << "\" }\n";  (*fp) << "\t{ Annotation \"\" }\n";  (*fp) << "\t{ Parent 0 }\n";  (*fp) << "\t{ Index \"\" }\n";  (*fp) << "}\n\n";}void SCDiagram::GenerateNoteBox (ConcreteSequenceDiagram *csd, OutputFile *fp){  if (csd==NULL || fp==NULL) return;  int id= csd->NextId();  int posx= csd->participants[csd->participants.count()-1]->x;  int posy= csd->participants[csd->participants.count()-1]->y;  (*fp) << "NoteBox " << id << "\n";  (*fp) << "{\n";  (*fp) << "\t{ View 1 }\n";  (*fp) << "\t{ Subject " << (id-1) << " }\n";  (*fp) << "\t{ Position " << (posx+160) << " " << posy << " }\n";  (*fp) << "\t{ Size 170 82 }\n"; //Enhacement: calculate the size based on the characters of the formula.  (*fp) << "\t{ Color \"black\" }\n";  (*fp) << "\t{ LineWidth 1 }\n";  (*fp) << "\t{ LineStyle Solid }\n";  (*fp) << "\t{ FillStyle Unfilled }\n";  (*fp) << "\t{ FillColor \"white\" }\n";  (*fp) << "\t{ FixedName False }\n";  (*fp) << "\t{ Font \"-*-helvetica-medium-r-normal--10*\" }\n";  (*fp) << "\t{ TextAlignment Center }\n";  (*fp) << "\t{ TextColor \"black\" }\n";  (*fp) << "\t{ NameUnderlined False }\n";  (*fp) << "}\n\n";}void InteractionParticipant::AddPairObjEv (int object, string event){  PairObjEv *newPair= new PairObjEv (object, event);  eventsToSend.add (newPair);}void InteractionParticipant::PrintIt (){  std::cout << "Participant:" << std::endl;  for (int i=0; i< eventsToSend.count(); i++)    eventsToSend[i]->PrintIt();  std::cout << std::endl;}void InteractionRow::PrintIt (){  for (int i=0; i< numObj; i++)    participants[i].PrintIt();  std::cout << std::endl;}void AbstractSequenceDiagram::PrintIt (){  for (int t=0; t< rows.count(); t++){    std::cout << "Time " << std::endl;    rows[t]->PrintIt();  }}InteractionRow * AbstractSequenceDiagram::AddRow (int cs){  InteractionRow *ir= new InteractionRow (numObjs, cs);  rows.add (ir);  return ir;} #endif//bool SCDiagram::SetText(TextShape *t, const string *s) {//	const string *description = t->GetDescription();//	Subject *subj = t->GetParent()->GetSubject();//	if (*description == "Event")//		return SetEvent((Transition *)subj, s);//	else if (*description == "Action")//		return SetAction(subj, s, t->GetSequence());//	else //		return Diagram::SetText(t, s);//}

⌨️ 快捷键说明

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