|
From: <got...@us...> - 2009-01-31 16:35:13
|
Revision: 179
http://scstudio.svn.sourceforge.net/scstudio/?rev=179&view=rev
Author: gotthardp
Date: 2009-01-31 16:35:08 +0000 (Sat, 31 Jan 2009)
Log Message:
-----------
Visualization of both basic MSC and HMSC completed.
Modified Paths:
--------------
trunk/src/data/msc.h
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/extract.cpp
trunk/src/view/visio/addon/extract.h
trunk/src/view/visio/addon/visualize.cpp
trunk/src/view/visio/addon/visualize.h
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/data/msc.h 2009-01-31 16:35:08 UTC (rev 179)
@@ -109,6 +109,21 @@
typedef std::set<HMscNodePtr> HMscNodePtrSet;
+struct nocase_comparator: public std::binary_function<std::string, std::string, bool>
+{
+ struct nocase_compare: public std::binary_function<unsigned char, unsigned char, bool>
+ {
+ bool operator() (const unsigned char& c1, const unsigned char& c2) const
+ { return tolower(c1) < tolower(c2); };
+ };
+
+ bool operator() (const std::string& s1, const std::string& s2) const
+ {
+ return std::lexicographical_compare(
+ s1.begin(), s1.end(), s2.begin(), s2.end(), nocase_compare());
+ }
+};
+
/**
* \brief Common basic abstract class for all elements of MSC
*/
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/view/visio/addon/document.cpp 2009-01-31 16:35:08 UTC (rev 179)
@@ -307,7 +307,7 @@
if(result != NULL)
{
m_reportView->Print(RS_ERROR, stringize()
- << (*cpos)->get_description() << " violated.");
+ << (*cpos)->get_description() << " violated.", result);
violated_count++;
}
else
@@ -572,8 +572,8 @@
{
MscPtr drawing = formatter->load_msc(stream);
- CDrawingVisualizer visualizer(m_vsoApp->ActivePage);
- visualizer.visualize_msc(drawing);
+ CDrawingVisualizer visualizer(m_vsoApp);
+ visualizer.visualize_msc(m_vsoApp->ActivePage, drawing);
}
void CDocumentMonitor::ExportActiveDocument(const ExportFormatterPtr& formatter, std::ostream& stream)
@@ -620,8 +620,8 @@
{
Visio::IVDocumentPtr vsoDocument = m_vsoApp->GetDocuments()->Add(VST_FILE_NAME);
- CDrawingVisualizer visualizer(vsoDocument->Pages->Item[1]);
- visualizer.visualize_msc(msc);
+ CDrawingVisualizer visualizer(m_vsoApp);
+ visualizer.visualize_msc(vsoDocument->Pages->Item[1], msc);
return 0;
}
Modified: trunk/src/view/visio/addon/extract.cpp
===================================================================
--- trunk/src/view/visio/addon/extract.cpp 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/view/visio/addon/extract.cpp 2009-01-31 16:35:08 UTC (rev 179)
@@ -179,6 +179,15 @@
page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters]);
}
+Point CDrawingExtractor::GetPinPos(Visio::IVShapePtr shape)
+{
+ double page_height = align5(shape->ContainingPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+
+ return Point(
+ shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormPinX]->Result[visMillimeters],
+ page_height - shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormPinY]->Result[visMillimeters]);
+}
+
void CDrawingExtractor::assert_no_nested_FromConnects(Visio::IVShapePtr shape)
{
for(int i = 1; i <= shape->Shapes->Count; i++)
@@ -263,8 +272,6 @@
IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
if(message == NULL)
continue;
- // lost message: glued on begin, dot on end
- message->set_dot_position(GetLineEnd(shape));
// create coregion event
event = area->add_event(new CoregionEvent());
event->set_position(Point(pos.m_y,pos.m_x));
@@ -285,8 +292,6 @@
IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
if(message == NULL)
continue;
- // found message: glued on end, dot on begin
- message->set_dot_position(GetLineBegin(shape));
// create coregion event
event = area->add_event(new CoregionEvent());
event->set_position(Point(pos.m_y,pos.m_x));
@@ -447,11 +452,21 @@
messages[shape->ID] = new CompleteMessage((const char*)shape->Text);
break;
case ST_BMSC_MESSAGE_LOST:
- messages[shape->ID] = new IncompleteMessage(LOST, (const char*)shape->Text);
+ {
+ IncompleteMessage *new_message = new IncompleteMessage(LOST, (const char*)shape->Text);
+ // lost message: glued on begin, dot on end
+ new_message->set_dot_position(GetLineEnd(shape));
+ messages[shape->ID] = new_message;
break;
+ }
case ST_BMSC_MESSAGE_FOUND:
- messages[shape->ID] = new IncompleteMessage(FOUND, (const char*)shape->Text);
+ {
+ IncompleteMessage *new_message = new IncompleteMessage(FOUND, (const char*)shape->Text);
+ // found message: glued on end, dot on begin
+ new_message->set_dot_position(GetLineBegin(shape));
+ messages[shape->ID] = new_message;
break;
+ }
case ST_BMSC_COREGION:
case ST_BMSC_ORDER_LINE:
@@ -529,15 +544,7 @@
case ST_BMSC_MESSAGE_LOST:
if(connect->FromPart == visBegin)
- {
- IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
- if(message == NULL)
- continue;
- // lost message: glued on begin, dot on end
- message->set_dot_position(GetLineEnd(shape));
-
event.event_type = SStrictOrder::ET_OUTGOING;
- }
else
{
PrintError(stringize() << page_name << ": "
@@ -549,15 +556,7 @@
case ST_BMSC_MESSAGE_FOUND:
if(connect->FromPart == visEnd)
- {
- IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
- if(message == NULL)
- continue;
- // found message: glued on end, dot on begin
- message->set_dot_position(GetLineBegin(shape));
-
event.event_type = SStrictOrder::ET_INCOMING;
- }
else
{
PrintError(stringize() << page_name << ": "
@@ -672,13 +671,6 @@
if(message == NULL)
continue;
- if(epos->shape_type == ST_BMSC_MESSAGE_LOST)
- // lost message: glued on begin, dot on end
- message->set_dot_position(GetLineEnd(shape));
- else if(epos->shape_type == ST_BMSC_MESSAGE_FOUND)
- // found message: glued on end, dot on begin
- message->set_dot_position(GetLineBegin(shape));
-
StrictEventPtr event = strict_area->add_event(new StrictEvent());
event->set_position(Point(epos->event_offset, epos->event_height));
message->glue_event(event);
@@ -959,8 +951,14 @@
break;
case ST_HMSC_CONNECTION:
- hmsc->add_node(nodes[shape->ID] = new ConnectionNode());
+ {
+ ConnectionNode *new_connection = new ConnectionNode();
+ new_connection->set_position(GetPinPos(shape));
+
+ hmsc->add_node(new_connection);
+ nodes[shape->ID] = new_connection;
break;
+ }
case ST_HMSC_START:
{
if(hmsc->get_start() != NULL)
@@ -972,16 +970,26 @@
continue;
}
StartNode *new_start = new StartNode();
+ new_start->set_position(GetPinPos(shape));
+
hmsc->set_start(new_start);
nodes[shape->ID] = new_start;
break;
}
case ST_HMSC_END:
- hmsc->add_node(nodes[shape->ID] = new EndNode());
+ {
+ EndNode *new_end = new EndNode();
+ new_end->set_position(GetPinPos(shape));
+
+ hmsc->add_node(new_end);
+ nodes[shape->ID] = new_end;
break;
+ }
case ST_HMSC_REFERENCE:
{
ReferenceNode *new_node = new ReferenceNode();
+ new_node->set_position(GetPinPos(shape));
+
hmsc->add_node(new_node);
nodes[shape->ID] = new_node;
Modified: trunk/src/view/visio/addon/extract.h
===================================================================
--- trunk/src/view/visio/addon/extract.h 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/view/visio/addon/extract.h 2009-01-31 16:35:08 UTC (rev 179)
@@ -22,21 +22,6 @@
#include "data/msc.h"
-struct nocase_comparator: public std::binary_function<std::string, std::string, bool>
-{
- struct nocase_compare: public std::binary_function<unsigned char, unsigned char, bool>
- {
- bool operator() (const unsigned char& c1, const unsigned char& c2) const
- { return tolower(c1) < tolower(c2); };
- };
-
- bool operator() (const std::string& s1, const std::string& s2) const
- {
- return std::lexicographical_compare(
- s1.begin(), s1.end(), s2.begin(), s2.end(), nocase_compare());
- }
-};
-
enum TShapeType
{
ST_BMSC_INSTANCE,
@@ -126,6 +111,7 @@
Point GetLineBegin(Visio::IVShapePtr shape);
Point GetLineEnd(Visio::IVShapePtr shape);
+ Point GetPinPos(Visio::IVShapePtr shape);
//! assert the given shape has no connections to its sub-shapes
void assert_no_nested_FromConnects(Visio::IVShapePtr shape);
Modified: trunk/src/view/visio/addon/visualize.cpp
===================================================================
--- trunk/src/view/visio/addon/visualize.cpp 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/view/visio/addon/visualize.cpp 2009-01-31 16:35:08 UTC (rev 179)
@@ -23,50 +23,82 @@
#include <math.h>
#include <Visconst.h>
-inline double align5(double mm)
+CDrawingVisualizer::CDrawingVisualizer(Visio::IVApplicationPtr vsoApp)
{
- return floor(mm/5)*5;
-}
+ m_vsoApp = vsoApp;
-CDrawingVisualizer::CDrawingVisualizer(Visio::IVPagePtr vsoPage)
-{
- m_page = vsoPage;
- m_page_height = align5(vsoPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+ Visio::IVDocumentPtr bmsc_stencil = vsoApp->Documents->Item[BMSC_STENCIL_NAME];
+ m_instance_master = bmsc_stencil->Masters->Item["Line Instance"];
+ m_coregion_master = bmsc_stencil->Masters->Item["Coregion Box"];
+ m_message_master = bmsc_stencil->Masters->Item["Message (Right)"];
+ m_lost_message_master = bmsc_stencil->Masters->Item["Lost Message"];
+ m_found_message_master = bmsc_stencil->Masters->Item["Found Message"];
+ m_ordering_side_side_master = bmsc_stencil->Masters->Item["Ordering Side-Side"];
+ m_ordering_sides_master = bmsc_stencil->Masters->Item["Ordering Sides"];
+ m_ordering_arrow_master = bmsc_stencil->Masters->Item["Ordering Arrow"];
- Visio::IVDocumentPtr stencil = vsoPage->Application->Documents->Item[BMSC_STENCIL_NAME];
- m_instance_master = stencil->Masters->Item["Line Instance"];
- m_coregion_master = stencil->Masters->Item["Coregion Box"];
-
- m_message_master = stencil->Masters->Item["Message (Right)"];
- m_lost_message_master = stencil->Masters->Item["Lost Message"];
- m_found_message_master = stencil->Masters->Item["Found Message"];
+ Visio::IVDocumentPtr hmsc_stencil = vsoApp->Documents->Item[HMSC_STENCIL_NAME];
+ m_start_symbol_master = hmsc_stencil->Masters->Item["Start Symbol"];
+ m_end_symbol_master = hmsc_stencil->Masters->Item["End Symbol"];
+ m_msc_reference_master = hmsc_stencil->Masters->Item["MSC Reference"];
+ m_connection_point_master = hmsc_stencil->Masters->Item["Connection Point"];
+ m_connection_arrow_master = hmsc_stencil->Masters->Item["Connection Arrow"];
}
-void CDrawingVisualizer::visualize_msc(const MscPtr& drawing)
+void CDrawingVisualizer::visualize_msc(Visio::IVPagePtr vsoPage, const MscPtr& drawing)
{
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(drawing);
if(bmsc != NULL)
- visualize_bmsc(bmsc);
+ visualize_bmsc(vsoPage, bmsc);
+ HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(drawing);
+ if(hmsc != NULL)
+ visualize_hmsc(vsoPage, hmsc);
+
// the last dropped shape would be selected
- m_page->Application->ActiveWindow->DeselectAll();
+ m_vsoApp->ActiveWindow->DeselectAll();
}
+double get_page_height(Visio::IVPagePtr vsoPage)
+{
+ double mm = vsoPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters];
+ // keep vertical alignment
+ return floor(mm/5)*5;
+}
+
+Visio::IVShapePtr CDrawingVisualizer::DropMaster(Visio::IVPagePtr vsoPage, Visio::IVMasterPtr master, const Point& pos)
+{
+ double page_height = get_page_height(vsoPage);
+ // drop the master to bottom-left corner
+ // note: drop coordinates are in Visio internal units
+ Visio::IVShapePtr shape = vsoPage->Drop(master, 0, 0);
+ // move shape to the right position
+ shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormPinX]->Result[visMillimeters] = pos.get_x(),
+ shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormPinY]->Result[visMillimeters] = page_height - pos.get_y();
+ return shape;
+}
+
void CDrawingVisualizer::SetLineBegin(Visio::IVShapePtr what, const Point& pos)
{
+ double page_height = get_page_height(what->ContainingPage);
+
what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX]->Result[visMillimeters] = pos.get_x();
- what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters] = m_page_height-pos.get_y();
+ what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters] = page_height-pos.get_y();
}
void CDrawingVisualizer::SetLineEnd(Visio::IVShapePtr what, const Point& pos)
{
+ double page_height = get_page_height(what->ContainingPage);
+
what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX]->Result[visMillimeters] = pos.get_x();
- what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters] = m_page_height-pos.get_y();
+ what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters] = page_height-pos.get_y();
}
void MarkShape(Visio::IVShapePtr what)
{
+ // line color = red
what->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 2;
+ // text color = red
what->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 2;
}
@@ -76,6 +108,7 @@
double width = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters];
Visio::IVCellPtr cell = what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
+ // glue coordinates represent decimal fractions of the shape's width and height
// note: instances in Visio are rotated by 90', height is the 'x' coordinate
cell->GlueToPos(where, pos.get_y()/max(1.0,width), pos.get_x()/max(1.0,height));
}
@@ -97,30 +130,30 @@
list.push_back(item);
}
-Visio::IVShapePtr CDrawingVisualizer::drop_message(MessagePtrMap& messages,
+Visio::IVShapePtr CDrawingVisualizer::drop_message(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
MscMessagePtr message, Visio::IVMasterPtr master)
{
Visio::IVShapePtr msg = messages[message];
- if(msg == NULL)
- {
- msg = m_page->Drop(master, 0, m_page_height-0);
- if(message->get_marked())
- MarkShape(msg);
+ if(msg != NULL)
+ return msg;
- msg->Text = message->get_label().c_str();
- messages[message] = msg;
- }
+ msg = vsoPage->Drop(master, 0, 0);
+ if(message->get_marked())
+ MarkShape(msg);
+ msg->Text = message->get_label().c_str();
+ messages[message] = msg;
+
return msg;
}
-void CDrawingVisualizer::show_event(MessagePtrMap& messages,
+void CDrawingVisualizer::show_event(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
Visio::IVShapePtr parent, EventPtr event)
{
CompleteMessagePtr complete_message = event->get_complete_message();
if(complete_message != NULL)
{
- Visio::IVShapePtr msg = drop_message(messages, complete_message, m_message_master);
+ Visio::IVShapePtr msg = drop_message(vsoPage, messages, complete_message, m_message_master);
if(complete_message->get_send_event() == event)
GlueBeginToPos(msg, parent, event->get_position());
@@ -133,13 +166,13 @@
{
if(incomplete_message->is_lost())
{
- Visio::IVShapePtr msg = drop_message(messages, incomplete_message, m_lost_message_master);
+ Visio::IVShapePtr msg = drop_message(vsoPage, messages, incomplete_message, m_lost_message_master);
GlueBeginToPos(msg, parent, event->get_position());
SetLineEnd(msg, incomplete_message->get_dot_position());
}
else if(incomplete_message->is_found())
{
- Visio::IVShapePtr msg = drop_message(messages, incomplete_message, m_found_message_master);
+ Visio::IVShapePtr msg = drop_message(vsoPage, messages, incomplete_message, m_found_message_master);
SetLineBegin(msg, incomplete_message->get_dot_position());
GlueEndToPos(msg, parent, event->get_position());
}
@@ -147,29 +180,55 @@
if(event->get_marked())
{
- Visio::IVMasterPtr marker_master = m_page->Document->Masters->Item["Event Marker"];
+ Visio::IVMasterPtr marker_master = vsoPage->Document->Masters->Item["Event Marker"];
- double posX;
- double posY;
-
+ double posX, posY;
+ // convert drop coordinates to Visio internal units
// note: instances in Visio are rotated by 90', height is the 'x' coordinate
parent->XYToPage(
- m_page->Application->ConvertResult(event->get_position().get_y(), visMillimeters, visInches),
- m_page->Application->ConvertResult(event->get_position().get_x(), visMillimeters, visInches),
+ vsoPage->Application->ConvertResult(event->get_position().get_y(), visMillimeters, visInches),
+ vsoPage->Application->ConvertResult(event->get_position().get_x(), visMillimeters, visInches),
&posX, &posY);
- Visio::IVShapePtr marker = m_page->Drop(marker_master, posX, posY);
+ Visio::IVShapePtr marker = vsoPage->Drop(marker_master, posX, posY);
}
}
-void CDrawingVisualizer::visualize_bmsc(const BMscPtr& bmsc)
+Visio::IVShapePtr CDrawingVisualizer::connect_events(Visio::IVPagePtr vsoPage,
+ Visio::IVShapePtr parent, EventPtr pred_event, EventPtr succ_event)
{
+ Visio::IVShapePtr connector;
+
+ // events are on the same height
+ if(pred_event->get_position().get_y() == succ_event->get_position().get_y())
+ connector = vsoPage->Drop(m_ordering_arrow_master, 0, 0);
+ // events are on the same side
+ else if(pred_event->get_position().get_x() == succ_event->get_position().get_x())
+ {
+ connector = vsoPage->Drop(m_ordering_sides_master, 0, 0);
+ // set the vertical line offset
+ connector->CellsSRC[visSectionControls][visRowControl][visCtlX]->Result[visMillimeters] = -5.0;
+ }
+ else
+ connector = vsoPage->Drop(m_ordering_side_side_master, 0, 0);
+
+ GlueBeginToPos(connector, parent, pred_event->get_position());
+ GlueEndToPos(connector, parent, succ_event->get_position());
+
+ return connector;
+}
+
+void CDrawingVisualizer::visualize_bmsc(Visio::IVPagePtr vsoPage, const BMscPtr& bmsc)
+{
+ vsoPage->Name = bmsc->get_label().c_str();
+
std::map<InstancePtr,Visio::IVShapePtr> instances;
+ // visualize all instances
for(InstancePtrList::const_iterator ipos = bmsc->get_instances().begin();
ipos != bmsc->get_instances().end(); ipos++)
{
- Visio::IVShapePtr inst = m_page->Drop(m_instance_master, 0, m_page_height-0);
+ Visio::IVShapePtr inst = vsoPage->Drop(m_instance_master, 0, 0);
if((*ipos)->get_marked())
MarkShape(inst);
@@ -182,6 +241,7 @@
MessagePtrMap messages;
+ // walk through all instance events and visualize the messages
for(InstancePtrList::const_iterator ipos = bmsc->get_instances().begin();
ipos != bmsc->get_instances().end(); ipos++)
{
@@ -198,14 +258,14 @@
for(StrictEventPtr event = strict_area->get_first();
event != NULL; event = event->get_successor())
{
- show_event(messages, inst, event);
+ show_event(vsoPage, messages, inst, event);
}
}
CoregionAreaPtr coregion_area = boost::dynamic_pointer_cast<CoregionArea>(area);
if(coregion_area != NULL)
{
- Visio::IVShapePtr coregion = m_page->Drop(m_coregion_master, 0, m_page_height-0);
+ Visio::IVShapePtr coregion = vsoPage->Drop(m_coregion_master, 0, 0);
if(coregion_area->get_marked())
MarkShape(coregion);
@@ -226,12 +286,27 @@
for(std::list<CoregionEventPtr>::const_iterator epos = event_stack.begin();
epos != event_stack.end(); epos++)
{
- show_event(messages, coregion, *epos);
+ show_event(vsoPage, messages, coregion, *epos);
+
+ for(CoregEventRelPtrSet::const_iterator spos = (*epos)->get_successors().begin();
+ spos != (*epos)->get_successors().end(); spos++)
+ {
+ CoregionEventPtr successor = (*spos)->get_successor();
+
+ Visio::IVShapePtr connector = connect_events(vsoPage, coregion, *epos, successor);
+ if((*spos)->get_marked())
+ MarkShape(connector);
+
+ // add successors of this event to the stack
+ // note: std::list<>::push_back doesn't invalidate iterators
+ push_back_if_unique<CoregionEventPtr>(event_stack, successor);
+ }
}
}
}
}
+ // walk through generated messages
for(MessagePtrMap::const_iterator mpos = messages.begin();
mpos != messages.end(); mpos++)
{
@@ -243,4 +318,113 @@
}
}
+Visio::IVShapePtr CDrawingVisualizer::drop_hmsc_node(Visio::IVPagePtr vsoPage, NodePtrMap& nodes, HMscNodePtr node)
+{
+ Visio::IVShapePtr shape = nodes[node];
+ if(shape != NULL)
+ return shape;
+
+ StartNodePtr start_node = boost::dynamic_pointer_cast<StartNode>(node);
+ if(start_node != NULL)
+ {
+ shape = DropMaster(vsoPage, m_start_symbol_master, start_node->get_position());
+ }
+
+ ConnectionNodePtr connection_node = boost::dynamic_pointer_cast<ConnectionNode>(node);
+ if(connection_node != NULL)
+ {
+ shape = DropMaster(vsoPage, m_connection_point_master, connection_node->get_position());
+ }
+
+ ReferenceNodePtr reference_node = boost::dynamic_pointer_cast<ReferenceNode>(node);
+ if(reference_node != NULL)
+ {
+ shape = DropMaster(vsoPage, m_msc_reference_master, reference_node->get_position());
+
+ MscPtr msc = reference_node->get_msc();
+ if(msc != NULL)
+ {
+ shape->Text = msc->get_label().c_str();
+
+ Visio::IVPagePtr newPage;
+ for(int i = 1; i <= vsoPage->Document->Pages->Count; i++)
+ {
+ Visio::IVPagePtr thisPage = vsoPage->Document->Pages->Item[i];
+ if(_tcsicmp(thisPage->Name, shape->Text) == 0)
+ {
+ newPage = thisPage;
+ break;
+ }
+ }
+
+ if(newPage == NULL)
+ {
+ newPage = vsoPage->Document->Pages->Add();
+ visualize_msc(newPage, msc);
+ }
+ }
+ else
+ shape->Text = "(void)";
+ }
+
+ EndNodePtr end_node = boost::dynamic_pointer_cast<EndNode>(node);
+ if(end_node != NULL)
+ {
+ shape = DropMaster(vsoPage, m_end_symbol_master, end_node->get_position());
+ }
+
+ if(node->get_marked())
+ MarkShape(shape);
+
+ nodes[node] = shape;
+
+ return shape;
+}
+
+void CDrawingVisualizer::visualize_hmsc(Visio::IVPagePtr vsoPage, const HMscPtr& hmsc)
+{
+ vsoPage->Name = hmsc->get_label().c_str();
+
+ NodePtrMap nodes;
+
+ // nodes to be processed; this is to avoid recursion
+ std::list<HMscNodePtr> node_stack;
+
+ // initialize the stack with the start node
+ push_back_if_unique<HMscNodePtr>(node_stack, hmsc->get_start());
+
+ // process all nodes in the stack
+ for(std::list<HMscNodePtr>::const_iterator npos = node_stack.begin();
+ npos != node_stack.end(); npos++)
+ {
+ Visio::IVShapePtr shape = drop_hmsc_node(vsoPage, nodes, *npos);
+
+ PredecessorNode *predecessor_node = dynamic_cast<PredecessorNode*>(npos->get());
+ if(predecessor_node != NULL)
+ {
+ for(NodeRelationPtrSet::const_iterator spos = predecessor_node->get_successors().begin();
+ spos != predecessor_node->get_successors().end(); spos++)
+ {
+ SuccessorNode *successor = (*spos)->get_successor();
+ HMscNode *successor_node = dynamic_cast<HMscNode*>(successor);
+
+ Visio::IVShapePtr successor_shape = drop_hmsc_node(vsoPage, nodes, successor_node);
+
+ Visio::IVShapePtr connector = vsoPage->Drop(m_connection_arrow_master, 0, 0);
+ if((*spos)->get_marked())
+ MarkShape(connector);
+
+ Visio::IVCellPtr from_cell = connector->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
+ from_cell->GlueToPos(shape, 0.5, 0.0);
+ Visio::IVCellPtr to_cell = connector->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX];
+ to_cell->GlueToPos(successor_shape, 0.5, 1.0);
+
+ // add successors of this node to the stack
+ // note: std::list<>::push_back doesn't invalidate iterators
+ push_back_if_unique<HMscNodePtr>(node_stack, successor_node);
+ }
+ }
+ }
+}
+
// $Id$
Modified: trunk/src/view/visio/addon/visualize.h
===================================================================
--- trunk/src/view/visio/addon/visualize.h 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/view/visio/addon/visualize.h 2009-01-31 16:35:08 UTC (rev 179)
@@ -23,31 +23,47 @@
class CDrawingVisualizer
{
public:
- CDrawingVisualizer(Visio::IVPagePtr vsoPage);
- void visualize_msc(const MscPtr& drawing);
+ CDrawingVisualizer(Visio::IVApplicationPtr vsoApp);
+ void visualize_msc(Visio::IVPagePtr vsoPage, const MscPtr& drawing);
protected:
- Visio::IVPagePtr m_page;
- double m_page_height;
+ Visio::IVApplicationPtr m_vsoApp;
Visio::IVMasterPtr m_instance_master;
Visio::IVMasterPtr m_coregion_master;
Visio::IVMasterPtr m_message_master;
Visio::IVMasterPtr m_lost_message_master;
Visio::IVMasterPtr m_found_message_master;
+ Visio::IVMasterPtr m_ordering_side_side_master;
+ Visio::IVMasterPtr m_ordering_sides_master;
+ Visio::IVMasterPtr m_ordering_arrow_master;
+ Visio::IVMasterPtr m_start_symbol_master;
+ Visio::IVMasterPtr m_end_symbol_master;
+ Visio::IVMasterPtr m_msc_reference_master;
+ Visio::IVMasterPtr m_connection_point_master;
+ Visio::IVMasterPtr m_connection_arrow_master;
+
typedef std::map<MscMessagePtr,Visio::IVShapePtr> MessagePtrMap;
typedef std::map<InstancePtr,Visio::IVShapePtr> InstancePtrMap;
+ Visio::IVShapePtr DropMaster(Visio::IVPagePtr vsoPage, Visio::IVMasterPtr master, const Point& pos);
void SetLineBegin(Visio::IVShapePtr what, const Point& pos);
void SetLineEnd(Visio::IVShapePtr what, const Point& pos);
- Visio::IVShapePtr drop_message(MessagePtrMap& messages,
+ Visio::IVShapePtr drop_message(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
MscMessagePtr message, Visio::IVMasterPtr master);
- void show_event(MessagePtrMap& messages,
+ void show_event(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
Visio::IVShapePtr parent, EventPtr event);
+ Visio::IVShapePtr connect_events(Visio::IVPagePtr vsoPage,
+ Visio::IVShapePtr parent, EventPtr pred_event, EventPtr succ_event);
- void visualize_bmsc(const BMscPtr& bmsc);
+ void visualize_bmsc(Visio::IVPagePtr vsoPage, const BMscPtr& bmsc);
+
+ typedef std::map<HMscNodePtr,Visio::IVShapePtr> NodePtrMap;
+ Visio::IVShapePtr drop_hmsc_node(Visio::IVPagePtr vsoPage, NodePtrMap& nodes, HMscNodePtr node);
+
+ void visualize_hmsc(Visio::IVPagePtr vsoPage, const HMscPtr& hmsc);
};
// $Id$
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|