|
From: <got...@us...> - 2009-01-29 22:44:13
|
Revision: 178
http://scstudio.svn.sourceforge.net/scstudio/?rev=178&view=rev
Author: gotthardp
Date: 2009-01-29 22:26:55 +0000 (Thu, 29 Jan 2009)
Log Message:
-----------
Enhanced error visualization.
- Displays bMSC with messages and coregions. Do not show general ordering (yet).
- Displays event marking.
- Displays hyperlinks in verification report, so the error can be more easily shown.
Modified Paths:
--------------
trunk/src/data/engmann/engmann.cpp
trunk/src/data/msc.cpp
trunk/src/data/msc.h
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/addon.h
trunk/src/view/visio/addon/dllmodule.rc
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/reportview.cpp
trunk/src/view/visio/addon/reportview.h
trunk/src/view/visio/addon/visualize.cpp
trunk/src/view/visio/addon/visualize.h
trunk/src/view/visio/stencils/Sequence Chart Studio/Basic MSC.vsx
trunk/src/view/visio/stencils/Sequence Chart Studio/MSC.vtx
Modified: trunk/src/data/engmann/engmann.cpp
===================================================================
--- trunk/src/data/engmann/engmann.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/data/engmann/engmann.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -129,8 +129,8 @@
static const Coordinate x_step = 30; // distance between instances [mm]
Coordinate current_x = 10;
- static const Coordinate y_step = 5; // distance between messages [mm]
- Coordinate current_y = 5;
+ static const Coordinate y_step = 7.5; // distance between messages [mm]
+ Coordinate current_y = 7.5;
while(stream.good())
{
@@ -152,6 +152,7 @@
// create new instance
InstancePtr inst = new Instance(node_name.text);
+ inst->set_width(10);
inst->set_line_begin(Point(current_x,5));
result->add_instance(inst);
@@ -179,10 +180,10 @@
CompleteMessagePtr message = new CompleteMessage(message_label);
EventPtr from_event = from_area->add_event();
- from_event->set_y(current_y);
+ from_event->set_position(Point(0,current_y));
EventPtr to_event = to_area->add_event();
- to_event->set_y(current_y);
+ to_event->set_position(Point(0,current_y));
message->glue_events(from_event, to_event);
}
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/data/msc.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -37,7 +37,7 @@
m_line = line;
}
-const PolyLine& NodeRelation::get_line()
+const PolyLine& NodeRelation::get_line() const
{
return m_line;
}
@@ -168,7 +168,7 @@
get_coregion_area()->add_minimal_event(e->get_successor());
}
-CoregionArea* CoregionEvent::get_coregion_area()
+CoregionArea* CoregionEvent::get_coregion_area() const
{
return dynamic_cast<CoregionArea*>(m_area);
}
@@ -248,6 +248,7 @@
Instance::Instance(const std::string& label, const std::string& kind):
MscElementTmpl<Instance>(NULL),m_label(label),m_kind(kind)
{
+ m_width = 0;
}
Instance::Instance(Instance* original):MscElementTmpl<Instance>(original)
@@ -284,7 +285,8 @@
IncompleteMessage::IncompleteMessage(IncompleteMessage* original):MscMessage(original)
{
- m_type = original->get_type();
+ m_dot_position = original->m_dot_position;
+ m_type = original->m_type;
}
void IncompleteMessage::glue_event(const EventPtr& event)
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/data/msc.h 2009-01-29 22:26:55 UTC (rev 178)
@@ -257,7 +257,7 @@
}
}
- bool get_marked()
+ bool get_marked() const
{
return m_marked;
}
@@ -401,7 +401,7 @@
/**
* Setter for m_label
*/
- const std::string& get_label()
+ const std::string& get_label() const
{
return m_label;
}
@@ -446,7 +446,7 @@
/**
* Getter for m_instances.
*/
- const InstancePtrList& get_instances()
+ const InstancePtrList& get_instances() const
{
return m_instances;
}
@@ -481,12 +481,12 @@
/**
* Getter of m_label
*/
- const std::string& get_label()
+ const std::string& get_label() const
{
return m_label;
}
- HMsc* get_owner()
+ HMsc* get_owner() const
{
return m_owner;
}
@@ -496,11 +496,16 @@
m_owner = owner;
}
- Point& get_position()
+ const Point& get_position() const
{
return m_position;
}
+ void set_position(const Point& position)
+ {
+ m_position = position;
+ }
+
HMscNodePtr my_ptr();
virtual ~HMscNode()
@@ -526,12 +531,12 @@
m_predecessor = NULL;
}
- SuccessorNode* get_successor()
+ SuccessorNode* get_successor() const
{
return m_successor;
}
- PredecessorNode* get_predecessor()
+ PredecessorNode* get_predecessor() const
{
return m_predecessor;
}
@@ -550,7 +555,7 @@
void set_line(const PolyLine& line);
- const PolyLine& get_line();
+ const PolyLine& get_line() const;
};
typedef boost::intrusive_ptr<NodeRelation> NodeRelationPtr;
@@ -578,7 +583,7 @@
/**
* Getter for m_predecessors.
*/
- const NodeRelationPtrSet& get_predecessors()
+ const NodeRelationPtrSet& get_predecessors() const
{
return m_predecessors;
}
@@ -634,7 +639,7 @@
/**
* Getter for m_successors.
*/
- const NodeRelationPtrSet& get_successors()
+ const NodeRelationPtrSet& get_successors() const
{
return m_successors;
}
@@ -746,7 +751,7 @@
/**
* Getter for m_start.
*/
- StartNodePtr get_start()
+ StartNodePtr get_start() const
{
return m_start;
}
@@ -757,7 +762,7 @@
m_start->set_owner(this);
}
- const HMscNodePtrSet& get_nodes()
+ const HMscNodePtrSet& get_nodes() const
{
return m_nodes;
}
@@ -812,7 +817,7 @@
/**
* Getter for m_msc.
*/
- MscPtr get_msc()
+ MscPtr get_msc() const
{
return m_msc;
}
@@ -830,7 +835,7 @@
*
* If not successfull undefined HMscPtr is returned.
*/
- HMscPtr get_hmsc()
+ HMscPtr get_hmsc() const
{
return boost::dynamic_pointer_cast<HMsc>(m_msc);
}
@@ -840,7 +845,7 @@
*
* If not successfull undefined BMscPtr is returned.
*/
- BMscPtr get_bmsc()
+ BMscPtr get_bmsc() const
{
return boost::dynamic_pointer_cast<BMsc>(m_msc);
}
@@ -934,7 +939,7 @@
}
- InstanceAxisForm get_form()
+ InstanceAxisForm get_form() const
{
return m_form;
}
@@ -949,7 +954,7 @@
/**
* Getter for m_first.
*/
- EventAreaPtr get_first()
+ EventAreaPtr get_first() const
{
return m_first;
}
@@ -957,7 +962,7 @@
/**
* Getter for m_label.
*/
- const std::string& get_label()
+ const std::string& get_label() const
{
return m_label;
}
@@ -967,7 +972,7 @@
m_last = a;
}
- EventAreaPtr get_last()
+ EventAreaPtr get_last() const
{
return m_last;
}
@@ -985,7 +990,7 @@
m_bmsc = bmsc;
}
- Point get_line_begin() const
+ const Point& get_line_begin() const
{
return m_line_begin;
}
@@ -995,7 +1000,7 @@
m_line_begin = line_begin;
}
- Point get_line_end() const
+ const Point& get_line_end() const
{
return m_line_end;
}
@@ -1194,11 +1199,16 @@
IncompleteMessage(IncompleteMessage* original);
- Point& get_dot_position()
+ const Point& get_dot_position() const
{
return m_dot_position;
}
+ void set_dot_position(const Point& dot_position)
+ {
+ m_dot_position = dot_position;
+ }
+
const std::string& get_instance_label() const
{
return m_instance_label;
@@ -1236,10 +1246,13 @@
{
protected:
-
- Coordinate m_y;
/**
+ * Relative position of the event to the respective instance/area.
+ */
+ Point m_position;
+
+ /**
* Label of message whose this is send or receive event.
*/
MscMessagePtr m_message;
@@ -1252,7 +1265,7 @@
{
if(original)
{
- m_y = original->get_y();
+ m_position = original->m_position;
}
}
@@ -1289,7 +1302,7 @@
* Return instance of CompleteMessage in case m_message contains the instance,
* undefined NULL otherwise
*/
- CompleteMessagePtr get_complete_message()
+ CompleteMessagePtr get_complete_message() const
{
return boost::dynamic_pointer_cast<CompleteMessage>(m_message);
}
@@ -1298,7 +1311,7 @@
* Return instance of CompleteMessage in case m_message contains the instance,
* undefined NULL otherwise
*/
- IncompleteMessagePtr get_incomplete_message()
+ IncompleteMessagePtr get_incomplete_message() const
{
return boost::dynamic_pointer_cast<IncompleteMessage>(m_message);
}
@@ -1307,7 +1320,7 @@
* Retrives matching event of this Event in case this Event has complete
* message, otherwise it returns NULL
*/
- Event* get_matching_event()
+ Event* get_matching_event() const
{
if(is_matched())
{
@@ -1402,14 +1415,14 @@
}
}
- Coordinate set_y(Coordinate y)
+ void set_position(const Point& position)
{
- return m_y = y;
+ m_position = position;
}
- Coordinate get_y()
+ const Point& get_position() const
{
- return m_y;
+ return m_position;
}
};
@@ -1440,7 +1453,7 @@
/**
* Returns EventArea which this Event occures in
*/
- TArea* get_area()
+ TArea* get_area() const
{
return m_area;
}
@@ -1501,7 +1514,7 @@
/**
* Getter for m_successor.
*/
- StrictEventPtr get_successor()
+ StrictEventPtr get_successor() const
{
return m_successor;
}
@@ -1509,7 +1522,7 @@
/**
* Getter for predecessor.
*/
- StrictEvent* get_predecessor()
+ StrictEvent* get_predecessor() const
{
return m_predecessor;
}
@@ -1561,12 +1574,12 @@
m_line = line;
}
- CoregionEvent* get_predecessor()
+ CoregionEvent* get_predecessor() const
{
return m_predecessor;
}
- CoregionEvent* get_successor()
+ CoregionEvent* get_successor() const
{
return m_successor;
}
@@ -1616,7 +1629,7 @@
/**
* Getter for m_successors
*/
- const CoregEventRelPtrSet& get_successors()
+ const CoregEventRelPtrSet& get_successors() const
{
return m_successors;
}
@@ -1624,7 +1637,7 @@
/**
* Getter for m_predecessors
*/
- const CoregEventRelPtrSet& get_predecessors()
+ const CoregEventRelPtrSet& get_predecessors() const
{
return m_predecessors;
}
@@ -1656,7 +1669,7 @@
/**
* Getter for m_area
*/
- CoregionArea* get_coregion_area();
+ CoregionArea* get_coregion_area() const;
bool is_minimal()
{
@@ -1693,8 +1706,11 @@
*/
EventArea* m_previous;
- Size m_height;
-
+ Coordinate m_begin_height;
+ Coordinate m_end_height;
+
+ Size m_width;
+
/**
* Instance which EventArea occures on
*
@@ -1710,7 +1726,8 @@
{
if(original)
{
- m_height = original->get_height();
+ m_begin_height = original->m_begin_height;
+ m_end_height = original->m_end_height;
}
}
@@ -1729,7 +1746,7 @@
/**
* Getter for m_next
*/
- EventAreaPtr get_next()
+ EventAreaPtr get_next() const
{
return m_next;
}
@@ -1750,7 +1767,7 @@
/**
* Getter for m_previous
*/
- EventArea* get_previous()
+ EventArea* get_previous() const
{
return m_previous;
}
@@ -1768,16 +1785,41 @@
return m_previous==NULL;
}
- Size get_height()
+ const Coordinate& get_begin_height() const
{
- return m_height;
+ return m_begin_height;
}
- void set_height(Size height)
+ void set_begin_height(const Coordinate& begin_height)
{
- m_height=height;
+ m_begin_height = begin_height;
}
+ const Coordinate& get_end_height() const
+ {
+ return m_end_height;
+ }
+
+ void set_end_height(const Coordinate& end_height)
+ {
+ m_end_height = end_height;
+ }
+
+ Size get_height() const
+ {
+ return fabs(m_end_height - m_begin_height);
+ }
+
+ Size get_width() const
+ {
+ return m_width;
+ }
+
+ void set_width(const Size& width)
+ {
+ m_width = width;
+ }
+
/**
* Adds event into this area. The added event is returned.
*/
@@ -1819,7 +1861,7 @@
/**
* Getter for m_first.
*/
- StrictEventPtr get_first()
+ StrictEventPtr get_first() const
{
return m_first;
}
@@ -1841,7 +1883,7 @@
/**
* Getter for m_first.
*/
- StrictEventPtr get_last()
+ StrictEventPtr get_last() const
{
return m_last;
}
@@ -1937,7 +1979,7 @@
/**
* Getter for m_minimal_events.
*/
- const CoregionEventPSet& get_minimal_events()
+ const CoregionEventPSet& get_minimal_events() const
{
return m_minimal_events;
}
@@ -1945,7 +1987,7 @@
/**
* Getter for m_maximal_events.
*/
- const CoregionEventPSet& get_maximal_events()
+ const CoregionEventPSet& get_maximal_events() const
{
return m_maximal_events;
}
@@ -1991,7 +2033,7 @@
return m_minimal_events.size()==0;
}
- const CoregionEventPtrSet& get_events()
+ const CoregionEventPtrSet& get_events() const
{
return m_events;
}
@@ -2018,7 +2060,7 @@
return e;
}
- InstanceAxisForm get_form()
+ InstanceAxisForm get_form() const
{
return m_form;
}
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/addon.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -21,6 +21,7 @@
#include "addon.h"
#include "aboutdlg.h"
#include "document.h"
+#include "extract.h"
#include "errors.h"
#include "resource.h"
@@ -41,8 +42,9 @@
CStudioAddon scstudio(_T(ADDON_NAME), IDS_ADDON_NAME);
+const unsigned short visEvtBeforeDocumentClose = Visio::visEvtDel | Visio::visEvtDoc;
const unsigned short visEvtPageAdded = Visio::visEvtAdd | Visio::visEvtPage;
-const unsigned short visEvtBeforeDocumentClose = Visio::visEvtDel | Visio::visEvtDoc;
+const unsigned short visEvtCellChanged = Visio::visEvtMod | Visio::visEvtCell;
const unsigned short visEvtConnectionsAdded = Visio::visEvtAdd | Visio::visEvtConnect;
const unsigned short visEvtConnectionsDeleted = Visio::visEvtDel | Visio::visEvtConnect;
@@ -335,7 +337,6 @@
IUnknown *ipSink, short nEventCode, IDispatch *pSourceObj, long nEventID,
long nEventSeqNum, IDispatch *pSubjectObj, VARIANT vMoreInfo, VARIANT *pvResult)
{
- TRACE("CStudioAddon::HandleVisioEvent() called");
try
{
if (ipSink == NULL || pSourceObj == NULL || pSubjectObj == NULL || pvResult == NULL)
@@ -344,27 +345,31 @@
return E_FAIL;
}
- switch (nEventCode)
+ unsigned short event = nEventCode;
+ switch (event)
{
+ case visEvtBeforeDocumentClose:
+ TRACE("CStudioAddon::HandleVisioEvent() visEvtBeforeDocumentClose");
+ break;
case visEvtPageAdded:
TRACE("CStudioAddon::HandleVisioEvent() visEvtPageAdded");
break;
- case visEvtBeforeDocumentClose:
- TRACE("CStudioAddon::HandleVisioEvent() visEvtBeforeDocumentClose");
+ case visEvtCellChanged:
+ HandleCellChanged(pSubjectObj);
break;
case visEvtConnectionsAdded:
TRACE("CStudioAddon::HandleVisioEvent() visEvtConnectionsAdded");
HandleConnectionsAdded(pSubjectObj);
break;
-
case visEvtConnectionsDeleted:
TRACE("CStudioAddon::HandleVisioEvent() visEvtConnectionsDeleted");
break;
default:
- TRACE("CStudioAddon::HandleVisioEvent() unexpected event id=" << nEventCode);
+ TRACE("CStudioAddon::HandleVisioEvent() unexpected event id="
+ << std::ios::hex << event);
break;
}
@@ -377,6 +382,30 @@
}
}
+void CStudioAddon::HandleCellChanged(Visio::IVCellPtr vsoCell)
+{
+ if(vsoCell->Section == visSectionControls)
+ {
+ // note: to keep stencil compatibility, the names must not be changed
+ if(_tcsicmp(vsoCell->RowName, _T("mscHeadWidth")) == 0 && vsoCell->Column == visCtlY)
+ {
+ double value = vsoCell->ResultIU;
+ TRACE("CStudioAddon::HandleCellChanged() mscHeadWidth changed to " << value);
+
+ Visio::IVShapePtr vsoShape = vsoCell->Shape;
+ // walk through connected shapes
+ for(int i = 1; i <= vsoShape->FromConnects->Count; i++)
+ {
+ Visio::IVConnectPtr fromConnect = vsoShape->FromConnects->Item[i];
+ // change width of all coregion boxes
+ // note: the coregion is rotated by 90', width is the 'y' coordinate
+ if(get_shape_type(fromConnect->FromSheet) == ST_BMSC_COREGION)
+ fromConnect->FromSheet->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->ResultIU = value*2;
+ }
+ }
+ }
+}
+
void CStudioAddon::HandleConnectionsAdded(Visio::IVConnectsPtr vsoConnects)
{
// dynamic connectors are positioned on Width*X
@@ -472,14 +501,14 @@
pDocumentMonitor = new CDocumentMonitor(this, vsoApp, vsoDocument);
pDocumentMonitor->InitMenu(vsoApp);
+ // register BeforeDocumentClose
+ vsoEvent = vsoDocumentEventList->AddAdvise(visEvtBeforeDocumentClose, varSink, _T(""), _T(""));
+ pDocumentMonitor->m_vsoBeforeDocumentClosedEvent = vsoEvent;
// register PageAdded
vsoEvent = vsoDocumentEventList->AddAdvise(visEvtPageAdded, varSink, _T(""), _T(""));
pDocumentMonitor->m_vsoPageAddedEvent = vsoEvent;
-
- // register BeforeDocumentClose
- vsoEvent = vsoDocumentEventList->AddAdvise(visEvtBeforeDocumentClose, varSink, _T(""), _T(""));
- pDocumentMonitor->m_vsoBeforeDocumentClosedEvent = vsoEvent;
+ vsoDocumentEventList->AddAdvise(visEvtCellChanged, varSink, _T(""), _T("CellChanged"));
vsoDocumentEventList->AddAdvise(visEvtConnectionsAdded, varSink, _T(""), _T("ConnectionsAdded"));
vsoDocumentEventList->AddAdvise(visEvtConnectionsDeleted, varSink, _T(""), _T("ConnectionsDeleted"));
Modified: trunk/src/view/visio/addon/addon.h
===================================================================
--- trunk/src/view/visio/addon/addon.h 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/addon.h 2009-01-29 22:26:55 UTC (rev 178)
@@ -44,6 +44,7 @@
VARIANT vMoreInfo, // [in] other info
VARIANT *pvResult); // [retval][out] return a value to Visio for query events
+ void HandleCellChanged(Visio::IVCellPtr vsoCell);
void HandleConnectionsAdded(Visio::IVConnectsPtr vsoConnects);
void RegisterPersistentEvents(Visio::IVDocumentPtr vsoDocument);
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/dllmodule.rc 2009-01-29 22:26:55 UTC (rev 178)
@@ -72,8 +72,8 @@
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,1,3,0
- PRODUCTVERSION 0,1,3,0
+ FILEVERSION 0,1,6,0
+ PRODUCTVERSION 0,1,6,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x9L
@@ -90,13 +90,13 @@
BEGIN
VALUE "CompanyName", "Masaryk University Brno"
VALUE "FileDescription", "Microsoft Visio add-on for design and verification of Message Sequence Charts (MSC)."
- VALUE "FileVersion", "0.1.3"
+ VALUE "FileVersion", "0.1.6"
VALUE "InternalName", "scstudio.vsl"
VALUE "LegalCopyright", "(c) Petr Gotthard. All rights reserved."
VALUE "OriginalFilename", "scstudio.vsl"
VALUE "PrivateBuild", "$Revision$"
VALUE "ProductName", "Sequence Chart Studio"
- VALUE "ProductVersion", "0.1.3"
+ VALUE "ProductVersion", "0.1.6"
END
END
BLOCK "VarFileInfo"
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/document.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -290,7 +290,7 @@
if(result != NULL)
{
m_reportView->Print(RS_ERROR, stringize()
- << (*cpos)->get_description() << " violated. [details]", result);
+ << (*cpos)->get_description() << " violated.", result);
violated_count++;
}
else
@@ -545,19 +545,16 @@
Visio::IVWindowPtr vsoWindow = vsoApp->GetActiveWindow();
const int defWidth = 500;
- const int defHeight = 200;
+ const int defHeight = 150;
m_reportWindow = vsoWindow->Windows->Add(LoadStringResource(IDS_REPORT_VIEW),
Visio::visWSVisible | Visio::visWSAnchorLeft, Visio::visAnchorBarAddon, 1, 1, defWidth, defHeight);
- LoadLibrary(CReportView::GetLibraryName());
+ LoadLibrary(CRichEditCtrl::GetLibraryName());
RECT rc = {0, 0, defWidth, defHeight};
- HWND hwndTV = m_reportView->Create(
- (HWND)m_reportWindow->WindowHandle,
+ HWND hwndTV = m_reportView->Create((HWND)m_reportWindow->WindowHandle,
rc, NULL,
- WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
- ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY,
- WS_EX_STATICEDGE);
+ WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
m_reportMenuItem->State = Visio::visButtonDown;
m_vsoDocument->CustomMenus->UpdateUI();
Modified: trunk/src/view/visio/addon/extract.cpp
===================================================================
--- trunk/src/view/visio/addon/extract.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/extract.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -62,7 +62,7 @@
return NULL;
}
-CDrawingExtractor::TShapeType CDrawingExtractor::get_shape_type(Visio::IVShapePtr shape)
+TShapeType get_shape_type(Visio::IVShapePtr shape)
{
// walk though all user-defined cells
// note: rows are numbered starting with 0
@@ -156,6 +156,29 @@
return SPoint(posx->Result[visMillimeters], posy->Result[visMillimeters]);
}
+inline double align5(double mm)
+{
+ return floor(mm/5)*5;
+}
+
+Point CDrawingExtractor::GetLineBegin(Visio::IVShapePtr shape)
+{
+ double page_height = align5(shape->ContainingPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+
+ return Point(
+ shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX]->Result[visMillimeters],
+ page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters]);
+}
+
+Point CDrawingExtractor::GetLineEnd(Visio::IVShapePtr shape)
+{
+ double page_height = align5(shape->ContainingPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+
+ return Point(
+ shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX]->Result[visMillimeters],
+ page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters]);
+}
+
void CDrawingExtractor::assert_no_nested_FromConnects(Visio::IVShapePtr shape)
{
for(int i = 1; i <= shape->Shapes->Count; i++)
@@ -214,6 +237,8 @@
continue;
// create coregion event
event = area->add_event(new CoregionEvent());
+ // note: instances in Visio are rotated by 90', height is the 'x' coordinate
+ event->set_position(Point(pos.m_y,pos.m_x));
// connect the message
switch(connect->FromPart)
{
@@ -238,8 +263,11 @@
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));
// connect the message
if(connect->FromPart == visBegin)
message->glue_event(event);
@@ -257,8 +285,11 @@
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));
// connect the message
if(connect->FromPart == visEnd)
message->glue_event(event);
@@ -364,23 +395,24 @@
return area;
}
-inline double align5(double mm)
+InstancePtr CDrawingExtractor::new_instance_ptr(Visio::IVShapePtr shape)
{
- return floor(mm/5)*5;
-}
+ InstancePtr result = new Instance((const char*)shape->Text);
-InstancePtr new_instance_ptr(Visio::IVShapePtr shape)
-{
- double page_height = align5(shape->ContainingPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+ result->set_line_begin(GetLineBegin(shape));
+ result->set_line_end(GetLineEnd(shape));
- InstancePtr result = new Instance((const char*)shape->Text);
+ // walk though all controls
+ // note: rows are numbered starting with 0
+ for(short i = 0; i < shape->RowCount[visSectionControls]; i++)
+ {
+ Visio::IVCellPtr cell = shape->CellsSRC[visSectionControls][visRowControl+i][visCtlY];
+ if(cell == NULL)
+ continue;
- result->set_line_begin(Point(
- shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX]->Result[visMillimeters],
- page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters]));
- result->set_line_end(Point(
- shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX]->Result[visMillimeters],
- page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters]));
+ if(_tcsicmp(cell->RowName, _T("mscHeadWidth")) == 0)
+ result->set_width(2.0*cell->Result[visMillimeters]);
+ }
return result;
}
@@ -473,7 +505,9 @@
SStrictOrder event;
event.shape_id = shape->ID;
event.shape_type = get_shape_type(shape);
- event.event_time = pos.m_x;
+ event.event_offset = pos.m_y;
+ // note: instances in Visio are rotated by 90', height is the 'x' coordinate
+ event.event_height = pos.m_x;
// which shape is connected?
switch(event.shape_type)
@@ -495,7 +529,15 @@
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 << ": "
@@ -507,7 +549,15 @@
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 << ": "
@@ -566,6 +616,7 @@
} state = ST_EXPECTING_AREA;
StrictOrderAreaPtr strict_area;
+ CoregionAreaPtr coregion_area;
long coregion_id;
// walk though the events in a time-order
@@ -590,7 +641,7 @@
continue;
StrictEventPtr event = strict_area->add_event(new StrictEvent());
- event->set_y(epos->event_time);
+ event->set_position(Point(epos->event_offset, epos->event_height));
if(epos->event_type == SStrictOrder::ET_OUTGOING)
message->glue_send_event(event);
else if(epos->event_type == SStrictOrder::ET_INCOMING)
@@ -621,7 +672,15 @@
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);
break;
@@ -643,7 +702,9 @@
case ST_STRICT:
if(epos->event_type == SStrictOrder::ET_OUTGOING)
{
- ipos->second->add_area(create_coregion_area(messages, shape));
+ ipos->second->add_area(coregion_area = create_coregion_area(messages, shape));
+ coregion_area->set_begin_height(epos->event_height);
+ coregion_area->set_width(shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters]);
}
else
{
@@ -665,6 +726,7 @@
}
else if(epos->event_type == SStrictOrder::ET_INCOMING)
{
+ coregion_area->set_end_height(epos->event_height);
state = ST_EXPECTING_AREA;
}
else
Modified: trunk/src/view/visio/addon/extract.h
===================================================================
--- trunk/src/view/visio/addon/extract.h 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/extract.h 2009-01-29 22:26:55 UTC (rev 178)
@@ -37,6 +37,29 @@
}
};
+enum TShapeType
+{
+ ST_BMSC_INSTANCE,
+ ST_BMSC_MESSAGE,
+ ST_BMSC_MESSAGE_LOST,
+ ST_BMSC_MESSAGE_FOUND,
+ ST_BMSC_COREGION,
+ ST_BMSC_ORDER_LINE,
+ ST_BMSC_ORDER_ARROW,
+ ST_COMMENT,
+ ST_TEXT,
+ ST_HMSC_CONNECTION,
+ ST_HMSC_START,
+ ST_HMSC_END,
+ ST_HMSC_REFERENCE,
+ ST_HMSC_LINE,
+ ST_HMSC_ARROW,
+ ST_UNKNOWN
+};
+
+//! determine MSC symbol represented by the given shape
+TShapeType get_shape_type(Visio::IVShapePtr shape);
+
class CDrawingExtractor
{
public:
@@ -72,29 +95,6 @@
typedef std::map<std::string,MscPtr,nocase_comparator> MscCacheMap;
MscCacheMap m_msc_cache;
- enum TShapeType
- {
- ST_BMSC_INSTANCE,
- ST_BMSC_MESSAGE,
- ST_BMSC_MESSAGE_LOST,
- ST_BMSC_MESSAGE_FOUND,
- ST_BMSC_COREGION,
- ST_BMSC_ORDER_LINE,
- ST_BMSC_ORDER_ARROW,
- ST_COMMENT,
- ST_TEXT,
- ST_HMSC_CONNECTION,
- ST_HMSC_START,
- ST_HMSC_END,
- ST_HMSC_REFERENCE,
- ST_HMSC_LINE,
- ST_HMSC_ARROW,
- ST_UNKNOWN
- };
-
- //! determine MSC symbol represented by the given shape
- TShapeType get_shape_type(Visio::IVShapePtr shape);
-
enum TDrawingType
{
DT_UNKNOWN = 0,
@@ -124,6 +124,9 @@
//! get coordinates of the given Connect element
SPoint get_connect_point(Visio::IVConnectPtr connect);
+ Point GetLineBegin(Visio::IVShapePtr shape);
+ Point GetLineEnd(Visio::IVShapePtr shape);
+
//! assert the given shape has no connections to its sub-shapes
void assert_no_nested_FromConnects(Visio::IVShapePtr shape);
void assert_no_FromConnects(Visio::IVShapePtr shape);
@@ -145,7 +148,8 @@
struct SStrictOrder
{
- double event_time;
+ double event_offset;
+ double event_height;
enum
{
ET_INCOMING,
@@ -157,7 +161,7 @@
bool operator < (const SStrictOrder& s2) const
{
- int cres = fcmp(event_time, s2.event_time);
+ int cres = fcmp(event_height, s2.event_height);
// no other connection allowed with coregion begin/end
if(shape_type == ST_BMSC_COREGION || s2.shape_type == ST_BMSC_COREGION)
return cres < 0;
@@ -166,6 +170,8 @@
}
};
+ InstancePtr new_instance_ptr(Visio::IVShapePtr shape);
+
//! process the given page and build a relevant BMsc
BMscPtr extract_bmsc(Visio::IVPagePtr vsoPage);
Modified: trunk/src/view/visio/addon/reportview.cpp
===================================================================
--- trunk/src/view/visio/addon/reportview.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/reportview.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -21,7 +21,37 @@
#include "reportview.h"
#include "errors.h"
+CRichList::CRichList(CReportView *reporter)
+{
+ m_reporter = reporter;
+}
+
+LRESULT CRichList::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ LRESULT lRet = DefWindowProc(uMsg, wParam, lParam);
+ if(lRet == -1)
+ return lRet; // error
+
+ long mask = GetEventMask();
+ // enable the EN_LINK notification
+ SetEventMask(mask | ENM_LINK);
+
+ return lRet;
+}
+
+LRESULT CRichList::OnLButtonDblClk(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ POINT pos = { LOWORD(lParam), HIWORD(lParam) };
+ // convert pixel position [x,y] to a character position
+ int ch = CharFromPos(pos);
+ int line = LineFromChar(ch);
+
+ TRACE("CRichList::OnLButtonDblClk() called at line " << line);
+ return m_reporter->OnLineDblClk(line);
+}
+
CReportView::CReportView(CDocumentMonitor *monitor)
+ : m_edit(this)
{
m_documentMonitor = monitor;
memset(m_statistics, 0, sizeof(m_statistics));
@@ -30,7 +60,7 @@
void CReportView::Reset()
{
// reset the view
- SetTextEx(NULL);
+ m_edit.SetTextEx(NULL);
// reset the internal data
memset(m_statistics, 0, sizeof(m_statistics));
m_references.clear();
@@ -55,7 +85,7 @@
return 0;
}
-int CReportView::__Print(TSeverity severity, const std::string& message)
+int CReportView::__Print(TSeverity severity, const std::string& message, int hasLink)
{
static const char *rtfPrefix =
"{\\rtf1\\ansi"
@@ -66,9 +96,9 @@
m_statistics[severity]++;
- long pos = GetWindowTextLength();
+ long pos = m_edit.GetWindowTextLength();
// put caret after the last character
- SetSel(pos, pos);
+ m_edit.SetSel(pos, pos);
std::string sstr = rtfPrefix;
// depending on severity, change the text style
@@ -79,15 +109,19 @@
sstr += message;
break;
case RS_NOTICE:
- sstr += "\\b " + message + "\\b0";
+ sstr += "\\b " + message + "\\b0 ";
break;
case RS_WARNING:
- sstr += "\\cf1 " + message + "\\cf0";
+ sstr += "\\cf1 " + message + "\\cf0 ";
break;
case RS_ERROR:
- sstr += "\\cf1\\b " + message + "\\b0\\cf0";
+ sstr += "\\cf1\\b " + message + "\\b0\\cf0 ";
break;
}
+
+ if(hasLink)
+ sstr += " [show]";
+
sstr += "\\line";
sstr += rtfSuffix;
@@ -95,15 +129,27 @@
EDITSTREAM es = {(DWORD_PTR)&pstr, 0, EditStreamCallBack};
// append RTF to the list
- StreamIn(SF_RTF | SFF_SELECTION, es);
+ m_edit.StreamIn(SF_RTF | SFF_SELECTION, es);
- LineScroll(1);
+ if(hasLink)
+ {
+ int linkpos = m_edit.GetTextLengthEx(GTL_NUMCHARS);
+
+ m_edit.SetSel(linkpos-6, linkpos-2);
+ CHARFORMAT2 cf;
+ cf.cbSize = sizeof(cf);
+ cf.dwMask = CFM_LINK;
+ cf.dwEffects = CFE_LINK;
+ m_edit.SetSelectionCharFormat(cf);
+ }
+
+ m_edit.LineScroll(1);
return 0;
}
int CReportView::Print(TSeverity severity, const std::string& message, const std::vector<_bstr_t>& shapelist)
{
- __Print(severity, message);
+ __Print(severity, message, !shapelist.empty());
Reference reference;
reference.shapes = shapelist;
@@ -115,7 +161,7 @@
int CReportView::Print(TSeverity severity, const std::string& message, const MscPtr& msc)
{
- __Print(severity, message);
+ __Print(severity, message, msc != NULL);
Reference reference;
reference.drawing = msc;
@@ -125,22 +171,58 @@
return 0;
}
-LRESULT CReportView::OnLButtonDblClk(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+LRESULT CReportView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
- POINT pos = { LOWORD(lParam), HIWORD(lParam) };
- // convert pixel position [x,y] to a character position
- int ch = CharFromPos(pos);
- int line = LineFromChar(ch);
+ LRESULT lRet = DefWindowProc(uMsg, wParam, lParam);
+ if(lRet == -1)
+ return lRet; // error
- TRACE("CReportView::OnLButtonDblClk() called at line " << line);
+ HWND hwndTV = m_edit.Create(
+ m_hWnd,
+ 0, NULL,
+ WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
+ ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY,
+ WS_EX_STATICEDGE);
- if (m_references[line].shapes.size() > 0)
+ return lRet;
+}
+
+LRESULT CReportView::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ int nWidth = LOWORD(lParam);
+ int nHeight = HIWORD(lParam);
+
+ m_edit.MoveWindow(0, 0, nWidth, nHeight, 1);
+ return 0;
+}
+
+LRESULT CReportView::OnLink(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
+{
+ ENLINK *link = (ENLINK *)pnmh;
+ if (link->msg == WM_LBUTTONDOWN)
+ {
+ int line = m_edit.LineFromChar(link->chrg.cpMin);
+
+ TRACE("CReportView::OnLink() called on line " << line);
+ OnLineDblClk(line);
+ }
+
+ return 0;
+}
+
+LRESULT CReportView::OnLineDblClk(size_t line)
+{
+ // the user might have clicked beyond the last line
+ if(line >= m_references.size())
+ return 0;
+
+ if(m_references[line].shapes.size() > 0)
m_documentMonitor->SelectShapes(m_references[line].shapes);
- if (m_references[line].drawing != 0)
+ if(m_references[line].drawing != 0)
m_documentMonitor->DisplayDocument(m_references[line].drawing);
- return 1;
+ return 0;
}
void CReportView::OnFinalMessage(HWND hWnd)
Modified: trunk/src/view/visio/addon/reportview.h
===================================================================
--- trunk/src/view/visio/addon/reportview.h 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/reportview.h 2009-01-29 22:26:55 UTC (rev 178)
@@ -22,14 +22,40 @@
// Include libraries from the Windows Template Library (WTL).
// http://wtl.sourceforge.net
#include <atlctrls.h>
+#include <atlwin.h>
#include <sstream>
#include <vector>
#include "data/msc.h"
+class CReportView;
class CDocumentMonitor;
+class CRichList
+ : public ATL::CWindowImpl<CRichList, CRichEditCtrl>
+{
+public:
+ CRichList(CReportView *reporter);
+
+protected:
+BEGIN_MSG_MAP(CRichList)
+ MESSAGE_HANDLER(WM_CREATE, OnCreate)
+ MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
+END_MSG_MAP()
+
+// Handler prototypes:
+// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
+
+ LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnLButtonDblClk(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+private:
+ CReportView *m_reporter;
+};
+
//! Helper class to construct a message for CReportView::Print()
/*!
* reporter->Print(stringize() << "string" << number);
@@ -82,7 +108,7 @@
};
class CReportView
- : public ATL::CWindowImpl<CReportView, CRichEditCtrl, ATL::CControlWinTraits>
+ : public ATL::CWindowImpl<CReportView, ATL::CWindow, ATL::CNullTraits>
{
public:
CReportView(CDocumentMonitor *monitor);
@@ -94,7 +120,9 @@
protected:
BEGIN_MSG_MAP(CReportView)
- MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
+ MESSAGE_HANDLER(WM_CREATE, OnCreate)
+ MESSAGE_HANDLER(WM_SIZE, OnSize)
+ NOTIFY_CODE_HANDLER(EN_LINK, OnLink)
END_MSG_MAP()
// Handler prototypes:
@@ -102,15 +130,21 @@
// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
- LRESULT OnLButtonDblClk(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+ LRESULT OnLink(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
+
+ LRESULT OnLineDblClk(size_t line);
void OnFinalMessage(HWND hWnd);
private:
CDocumentMonitor *m_documentMonitor;
+ CRichList m_edit;
int m_statistics[__RS_LAST];
- int __Print(TSeverity severity, const std::string& message);
+ int __Print(TSeverity severity, const std::string& message, int hasLink);
struct Reference
{
Modified: trunk/src/view/visio/addon/visualize.cpp
===================================================================
--- trunk/src/view/visio/addon/visualize.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/visualize.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -34,8 +34,12 @@
m_page_height = align5(vsoPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
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_instance_master = stencil->Masters->Item["Line Instance"];
+ m_lost_message_master = stencil->Masters->Item["Lost Message"];
+ m_found_message_master = stencil->Masters->Item["Found Message"];
}
void CDrawingVisualizer::visualize_msc(const MscPtr& drawing)
@@ -48,10 +52,116 @@
m_page->Application->ActiveWindow->DeselectAll();
}
-void CDrawingVisualizer::visualize_instance(const InstancePtr& instance)
+void CDrawingVisualizer::SetLineBegin(Visio::IVShapePtr what, const Point& pos)
{
+ what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX]->Result[visMillimeters] = pos.get_x();
+ what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters] = m_page_height-pos.get_y();
}
+void CDrawingVisualizer::SetLineEnd(Visio::IVShapePtr what, const Point& pos)
+{
+ what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX]->Result[visMillimeters] = pos.get_x();
+ what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters] = m_page_height-pos.get_y();
+}
+
+void MarkShape(Visio::IVShapePtr what)
+{
+ what->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 2;
+ what->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 2;
+}
+
+void GlueBeginToPos(Visio::IVShapePtr what, Visio::IVShapePtr where, const Point& pos)
+{
+ double height = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters];
+ double width = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters];
+
+ Visio::IVCellPtr cell = what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
+ // 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));
+}
+
+void GlueEndToPos(Visio::IVShapePtr what, Visio::IVShapePtr where, const Point& pos)
+{
+ double height = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters];
+ double width = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters];
+
+ Visio::IVCellPtr cell = what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX];
+ // 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));
+}
+
+template <class Ptr>
+void push_back_if_unique(std::list<Ptr>& list, const Ptr& item)
+{
+ if(std::find(list.begin(), list.end(), item) == list.end())
+ list.push_back(item);
+}
+
+Visio::IVShapePtr CDrawingVisualizer::drop_message(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);
+
+ msg->Text = message->get_label().c_str();
+ messages[message] = msg;
+ }
+
+ return msg;
+}
+
+void CDrawingVisualizer::show_event(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);
+
+ if(complete_message->get_send_event() == event)
+ GlueBeginToPos(msg, parent, event->get_position());
+ else if(complete_message->get_receive_event() == event)
+ GlueEndToPos(msg, parent, event->get_position());
+ }
+
+ IncompleteMessagePtr incomplete_message = event->get_incomplete_message();
+ if(incomplete_message != NULL)
+ {
+ if(incomplete_message->is_lost())
+ {
+ Visio::IVShapePtr msg = drop_message(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);
+ SetLineBegin(msg, incomplete_message->get_dot_position());
+ GlueEndToPos(msg, parent, event->get_position());
+ }
+ }
+
+ if(event->get_marked())
+ {
+ Visio::IVMasterPtr marker_master = m_page->Document->Masters->Item["Event Marker"];
+
+ double posX;
+ double posY;
+
+ // 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),
+ &posX, &posY);
+
+ Visio::IVShapePtr marker = m_page->Drop(marker_master, posX, posY);
+ }
+}
+
void CDrawingVisualizer::visualize_bmsc(const BMscPtr& bmsc)
{
std::map<InstancePtr,Visio::IVShapePtr> instances;
@@ -61,18 +171,16 @@
{
Visio::IVShapePtr inst = m_page->Drop(m_instance_master, 0, m_page_height-0);
if((*ipos)->get_marked())
- inst->CellsSRC[visSectionObject][visRowLine][visLineColor]->Result[visNoCast] = 2;
+ MarkShape(inst);
inst->Text = (*ipos)->get_label().c_str();
- inst->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX]->Result[visMillimeters] = (*ipos)->get_line_begin().get_x();
- inst->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters] = m_page_height-(*ipos)->get_line_begin().get_y();
- inst->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX]->Result[visMillimeters] = (*ipos)->get_line_end().get_x();
- inst->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters] = m_page_height-(*ipos)->get_line_end().get_y();
+ SetLineBegin(inst, (*ipos)->get_line_begin());
+ SetLineEnd(inst, (*ipos)->get_line_end());
instances[*ipos] = inst;
}
- std::map<CompleteMessagePtr,Visio::IVShapePtr> messages;
+ MessagePtrMap messages;
for(InstancePtrList::const_iterator ipos = bmsc->get_instances().begin();
ipos != bmsc->get_instances().end(); ipos++)
@@ -90,32 +198,49 @@
for(StrictEventPtr event = strict_area->get_first();
event != NULL; event = event->get_successor())
{
- CompleteMessagePtr message = event->get_complete_message();
+ show_event(messages, inst, event);
+ }
+ }
- Visio::IVShapePtr msg = messages[message];
- if(msg == NULL)
- {
- msg = m_page->Drop(m_message_master, 0, m_page_height-0);
- if(message->get_marked() || event->get_marked())
- msg->CellsSRC[visSectionObject][visRowLine][visLineColor]->Result[visNoCast] = 2;
- msg->Text = message->get_label().c_str();
- messages[message] = msg;
- }
+ 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);
+ if(coregion_area->get_marked())
+ MarkShape(coregion);
- if(message->get_send_event() == event)
- {
- Visio::IVCellPtr cell = msg->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
- cell->GlueToPos(inst, event->get_y()/(*ipos)->get_height(), 0);
- }
- else if(message->get_receive_event() == event)
- {
- Visio::IVCellPtr cell = msg->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX];
- cell->GlueToPos(inst, event->get_y()/(*ipos)->get_height(), 0);
- }
+ GlueBeginToPos(coregion, inst, Point(0,coregion_area->get_begin_height()));
+ GlueEndToPos(coregion, inst, Point(0,coregion_area->get_end_height()));
+
+ // events to be processed; this is to avoid recursion
+ std::list<CoregionEventPtr> event_stack;
+
+ for(CoregionEventPSet::const_iterator mpos = coregion_area->get_minimal_events().begin();
+ mpos != coregion_area->get_minimal_events().end(); mpos++)
+ {
+ // initialize the stack with events with no predecessors
+ push_back_if_unique<CoregionEventPtr>(event_stack, *mpos);
}
+
+ // process all events in the stack
+ for(std::list<CoregionEventPtr>::const_iterator epos = event_stack.begin();
+ epos != event_stack.end(); epos++)
+ {
+ show_event(messages, coregion, *epos);
+ }
}
}
}
+
+ for(MessagePtrMap::const_iterator mpos = messages.begin();
+ mpos != messages.end(); mpos++)
+ {
+ Visio::IVShapePtr msg = mpos->second;
+
+ // correct text alignment for left-headed messages
+ if(fabs(msg->CellsSRC[visSectionObject][visRowXFormOut][visXFormAngle]->Result[visDegrees]) > 90)
+ msg->CellsSRC[visSectionParagraph][visRowParagraph][visHorzAlign]->ResultIU = visHorzRight;
+ }
}
// $Id$
Modified: trunk/src/view/visio/addon/visualize.h
===================================================================
--- trunk/src/view/visio/addon/visualize.h 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/visualize.h 2009-01-29 22:26:55 UTC (rev 178)
@@ -30,10 +30,23 @@
Visio::IVPagePtr m_page;
double m_page_height;
+ Visio::IVMasterPtr m_instance_master;
+ Visio::IVMasterPtr m_coregion_master;
Visio::IVMasterPtr m_message_master;
- Visio::IVMasterPtr m_instance_master;
+ Visio::IVMasterPtr m_lost_message_master;
+ Visio::IVMasterPtr m_found_message_master;
- void visualize_instance(const InstancePtr& instance);
+ typedef std::map<MscMessagePtr,Visio::IVShapePtr> MessagePtrMap;
+ typedef std::map<InstancePtr,Visio::IVShapePtr> InstancePtrMap;
+
+ void SetLineBegin(Visio::IVShapePtr what, const Point& pos);
+ void SetLineEnd(Visio::IVShapePtr what, const Point& pos);
+
+ Visio::IVShapePtr drop_message(MessagePtrMap& messages,
+ MscMessagePtr message, Visio::IVMasterPtr master);
+ void show_event(MessagePtrMap& messages,
+ Visio::IVShapePtr parent, EventPtr event);
+
void visualize_bmsc(const BMscPtr& bmsc);
};
Modified: trunk/src/view/visio/stencils/Sequence Chart Studio/Basic MSC.vsx
===================================================================
--- trunk/src/view/visio/stencils/Sequence Chart Studio/Basic MSC.vsx 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/stencils/Sequence Chart Studio/Basic MSC.vsx 2009-01-29 22:26:55 UTC (rev 178)
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8' ?>
-<VisioDocument key='FF54E758BE104959707163B149D850117B093C2F8DAAE5358C63FBF243A102BE40FF032CAC3CD91D4075FA6CB260157ACAAF0B527B4288C47CAB3560B1FB0FA3' start='190' xmlns='http://schemas.microsoft.com/visio/2003/core' metric='0' DocLangID='1033' buildnum='8161' version='11.0' xml:space='preserve'><DocumentProperties><Title>Basic MSC</Title><Creator>Petr Gotthard</Creator><Company>Brno</Company><BuildNumberCreated>738205665</BuildNumberCreated><BuildNumberEdited>738205665</BuildNumberEdited><TimeCreated>2008-12-14T11:32:13</TimeCreated><TimeSaved>2009-01-08T22:29:41</TimeSaved><TimeEdited>2009-01-08T22:29:27</TimeEdited><TimePrinted>2008-12-14T11:32:13</TimePrinted></DocumentProperties><DocumentSettings TopPage='0' DefaultTextStyle='3' DefaultLineStyle='3' DefaultFillStyle='3' DefaultGuideStyle='4'><GlueSettings>9</GlueSettings><SnapSettings>65847</SnapSettings><SnapExtensions>34</SnapExtensions><DynamicGridEnabled>0</DynamicGridEnabled><ProtectStyles>0</ProtectStyles><ProtectShapes>0</ProtectShapes><ProtectMasters>0</ProtectMasters><ProtectBkgnds>0</ProtectBkgnds></DocumentSettings><Colors><ColorEntry IX='0' RGB='#000000'/><ColorEntry IX='1' RGB='#FFFFFF'/><ColorEntry IX='2' RGB='#FF0000'/><ColorEntry IX='3' RGB='#00FF00'/><ColorEntry IX='4' RGB='#0000FF'/><ColorEntry IX='5' RGB='#FFFF00'/><ColorEntry IX='6' RGB='#FF00FF'/><ColorEntry IX='7' RGB='#00FFFF'/><ColorEntry IX='8' RGB='#800000'/><ColorEntry IX='9' RGB='#008000'/><ColorEntry IX='10' RGB='#000080'/><ColorEntry IX='11' RGB='#808000'/><ColorEntry IX='12' RGB='#800080'/><ColorEntry IX='13' RGB='#008080'/><ColorEntry IX='14' RGB='#C0C0C0'/><ColorEntry IX='15' RGB='#E6E6E6'/><ColorEntry IX='16' RGB='#CDCDCD'/><ColorEntry IX='17' RGB='#B3B3B3'/><ColorEntry IX='18' RGB='#9A9A9A'/><ColorEntry IX='19' RGB='#808080'/><ColorEntry IX='20' RGB='#666666'/><ColorEntry IX='21' RGB='#4D4D4D'/><ColorEntry IX='22' RGB='#333333'/><ColorEntry IX='23' RGB='#1A1A1A'/></Colors><FaceNames><FaceName ID='1' Name='Arial Unicode MS' UnicodeRanges='-1 -369098753 63 0' CharSets='1614741759 -65536' Panos='2 11 6 4 2 2 2 2 2 4' Flags='357'/><FaceName ID='2' Name='Symbol' UnicodeRanges='0 0 0 0' CharSets='-2147483648 0' Panos='5 5 1 2 1 7 6 2 5 7' Flags='261'/><FaceName ID='3' Name='Wingdings' UnicodeRanges='0 0 0 0' CharSets='-2147483648 0' Panos='5 0 0 0 0 0 0 0 0 0' Flags='261'/><FaceName ID='4' Name='Arial' UnicodeRanges='31367 -2147483648 8 0' CharSets='1073742335 -65536' Panos='2 11 6 4 2 2 2 2 2 4' Flags='325'/><FaceName ID='5' Name='SimSun' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='6' Name='PMingLiU' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='7' Name='MS PGothic' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='8' Name='Dotum' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='9' Name='Sylfaen' UnicodeRanges='67110535 0 0 0' CharSets='536871071 0' Panos='1 10 5 2 5 3 6 3 3 3' Flags='325'/><FaceName ID='10' Name='Estrangelo Edessa' UnicodeRanges='-2147459008 0 128 0' CharSets='0 0' Panos='3 8 6 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='11' Name='Vrinda' UnicodeRanges='65539 0 0 0' CharSets='1 0' Panos='1 1 6 0 1 1 1 1 1 1' Flags='325'/><FaceName ID='12' Name='Shruti' UnicodeRanges='262144 0 0 0' CharSets='0 0' Panos='2 0 5 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='13' Name='Mangal' UnicodeRanges='32768 0 0 0' CharSets='0 0' Panos='0 0 4 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='14' Name='Tunga' UnicodeRanges='4194304 0 0 0' CharSets='0 0' Panos='0 0 4 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='15' Name='Sendnya' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='16' Name='Raavi' UnicodeRanges='131072 0 0 0' CharSets='0 0' Panos='2 0 5 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='17' Name='Dhenu' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='18' Name='Latha' UnicodeRanges='1048576 0 0 0' CharSets='0 0' Panos='2 0 4 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='19' Name='Gautami' UnicodeRanges='2097152 0 0 0' CharSets='0 0' Panos='2 0 5 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='20' Name='Cordia New' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='21' Name='MS Farsi' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='22' Name='Gulim' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='23' Name='Times New Roman' UnicodeRanges='31367 -2147483648 8 0' CharSets='1073742335 -65536' Panos='2 2 6 3 5 4 5 2 3 4' Flags='325'/></FaceNames><StyleSheets><StyleSheet ID='0' NameU='No Style' Name='No Style'><StyleProp><EnableLineProps>1</EnableLineProps><EnableFillProps>1</EnableFillProps><EnableTextProps>1</EnableTextProps><HideForApply>0</HideForApply></StyleProp><Line><LineWeight>0.01</LineWeight><LineColor>0</LineColor><LinePattern>1</LinePattern><Rounding>0</Rounding><EndArrowSize>2</EndArrowSize><BeginArrow>0</BeginArrow><EndArrow>0</EndArrow><LineCap>0</LineCap><BeginArrowSize>2</BeginArrowSize><LineColorTrans>0</LineColorTrans></Line><Fill><FillForegnd>1</FillForegnd><FillBkgnd>0</FillBkgnd><FillPattern>1</FillPattern><ShdwForegnd>0</ShdwForegnd><ShdwBkgnd>1</ShdwBkgnd><ShdwPattern>0</ShdwPattern><FillForegndTrans>0</FillForegndTrans><FillBkgndTrans>0</FillBkgndTrans><ShdwForegndTrans>0</ShdwForegndTrans><ShdwBkgndTrans>0</ShdwBkgndTrans><ShapeShdwType>0</ShapeShdwType><ShapeShdwOffsetX>0</ShapeShdwOffsetX><ShapeShdwOffsetY>0</ShapeShdwOffsetY><ShapeShdwObliqueAngle>0</ShapeShdwObliqueAngle><ShapeShdwScaleFactor>1</ShapeShdwScaleFactor></Fill><TextBlock><LeftMargin>0</LeftMargin><RightMargin>0</RightMargin><TopMargin>0</TopMargin><BottomMargin>0</BottomMargin><VerticalAlign>1</VerticalAlign><TextBkgnd>0</TextBkgnd><DefaultTabStop>0.5</DefaultTabStop><TextDirection>0</TextDirection><TextBkgndTrans>0</TextBkgndTrans></TextBlock><Protection><LockWidth>0</LockWidth><LockHeight>0</LockHeight><LockMoveX>0</LockMoveX><LockMoveY>0</LockMoveY><LockAspect>0</LockAspect><LockDelete>0</LockDelete><LockBegin>0</LockBegin><LockEnd>0</LockEnd><LockRotate>0</LockRotate><LockCrop>0</LockCrop><LockVtxEdit>0</LockVtxEdit><LockTextEdit>0</LockTextEdit><LockFormat>0</LockFormat><LockGroup>0</LockGroup><LockCalcWH>0</LockCalcWH><LockSelect>0</LockSelect><LockCustProp>0</LockCustProp></Protection><Misc><NoObjHandles>0</NoObjHandles><NonPrinting>0</NonPrinting><NoCtlHandles>0</NoCtlHandles><NoAlignBox>0</NoAlignBox><UpdateAlignBox>0</UpdateAlignBox><HideText>0</HideText><DynFeedback>0</DynFeedback><GlueType>0</GlueType><WalkPreference>0</WalkPreference><BegTrigger F='No Formula'>0</BegTrigger><EndTrigger F='No Formula'>0</EndTrigger><ObjType>0</ObjType><Comment V='null'/><IsDropSource>0</IsDropSource><NoLiveDynamics>0</NoLiveDynamics><LocalizeMerge>0</LocalizeMerge><Calendar>0</Calendar><LangID>1033</LangID><ShapeKeywords V='null'/><DropOnPageScale>1</DropOnPageScale></Misc><Event><TheData F='No Formula'>0</TheData><TheText F='No Formula'>0</TheText><EventDblClick F='No Formula'>0</EventDblClick><EventXFMod F='No Formula'>0</EventXFMod><EventDrop F='No Formula'>0</EventDrop></Event><Help><HelpTopic V='null'/><Copyright V='null'/></Help><LayerMem><LayerMember V='null'/></LayerMem><RulerGrid><XRulerDensity>32</XRulerDensity><YRulerDensity>32</YRulerDensity><XRulerOrigin>0</XRulerOrigin><YRulerOrigin>0</YRulerOrigin><XGridDensity>8</XGridDensity><YGridDensity>8</YGridDensity><XGridSpacing>0</XGridSpacing><YGridSpacing>0</YGridSpacing><XGridOrigin>0</XGridOrigin><YGridOrigin>0</YGridOrigin></RulerGrid><Image><Gamma>1</Gamma><Contrast>0.5</Contrast><Brightness>0.5</Brightness><Sharpen>0</Sharpen><Blur>0</Blur><Denoise>0</Denoise><Transparency>0</Transparency></Image><Group><SelectMode>1</SelectMode><DisplayMode>2</DisplayMode><IsDropTarget>0</IsDropTarget><IsSnapTarget>1</IsSnapTarget><IsTextEditTarget>1</IsTextEditTarget><DontMoveChildren>0</DontMoveChildren></Group><Layout><ShapePermeableX>0</ShapePermeableX><ShapePermeableY>0</ShapePermeableY><ShapePermeablePlace>0</ShapePermeablePlace><ShapeFixedCode>0</ShapeFixedCode><ShapePlowCode>0</ShapePlowCode><ShapeRouteStyle>0</ShapeRouteStyle><ConFixedCode>0</ConFixedCode><ConLineJumpCode>0</ConLine...
[truncated message content] |