|
From: <ob...@us...> - 2013-05-26 14:36:25
|
Revision: 1821
http://sourceforge.net/p/scstudio/code/1821
Author: obouda
Date: 2013-05-26 14:36:20 +0000 (Sun, 26 May 2013)
Log Message:
-----------
unhacked local actions - now, LocalActionEvent is used, and LocalAction does not inherit from IncompleteMessage
Modified Paths:
--------------
branches/conditions/src/data/CMakeLists.txt
branches/conditions/src/data/Z120/Context.cpp
branches/conditions/src/data/Z120/z120_save.cpp
branches/conditions/src/data/beautify/layout_optimizer.cpp
branches/conditions/src/data/exporttex/exportTex.cpp
branches/conditions/src/data/msc/Event.h
branches/conditions/src/data/msc/LocalAction.h
branches/conditions/src/data/msc/MessageEvent.cpp
branches/conditions/src/data/msc/MessageEvent.h
branches/conditions/src/data/msc/MscMessage.h
branches/conditions/src/data/msc.h
branches/conditions/src/data/time_relevant_ordering/time_relevant_ordering.cpp
branches/conditions/src/view/visio/addon/extract.cpp
branches/conditions/src/view/visio/addon/extract.h
branches/conditions/src/view/visio/addon/visualize.cpp
branches/conditions/src/view/visio/addon/visualize.h
Added Paths:
-----------
branches/conditions/src/data/msc/LocalAction.cpp
branches/conditions/src/data/msc/LocalActionEvent.h
Modified: branches/conditions/src/data/CMakeLists.txt
===================================================================
--- branches/conditions/src/data/CMakeLists.txt 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/CMakeLists.txt 2013-05-26 14:36:20 UTC (rev 1821)
@@ -69,7 +69,9 @@
msc/IncompleteMessage.h
msc/Instance.cpp
msc/Instance.h
+ msc/LocalAction.cpp
msc/LocalAction.h
+ msc/LocalActionEvent.h
msc/Msc.h
msc/MscElement.h
msc/MscElementTmpl.h
Modified: branches/conditions/src/data/Z120/Context.cpp
===================================================================
--- branches/conditions/src/data/Z120/Context.cpp 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/Z120/Context.cpp 2013-05-26 14:36:20 UTC (rev 1821)
@@ -577,65 +577,69 @@
}
/**
- * A helper function for creating a new event in the given context.
+ * A helper class for creating a new event of type EventType in the given context.
* The pointer to the event will be available in context->current_event.
*/
-void create_event(struct Context* context)
+template<typename EventType>
+class ContextEventFactory
{
- InstancePtr instance;
-
- std::map<std::string, InstancePtr>::iterator inst_it = context->instances.find(context->element_name);
-
- if(inst_it == context->instances.end())
+public:
+ static void create_event(struct Context* context)
{
- instance = new Instance(TOWSTRING(context->element_name));
- context->instances.insert(std::make_pair(context->element_name, instance));
- context->myBmsc->add_instance(instance);
- context->open_instance++;
- context->z->print_report(RS_WARNING,
- stringize() << "Warning 23: Instance (" << TOWSTRING(context->element_name) << ") has not been started (e.g. " << TOWSTRING(context->element_name) << ": instance;)");
+ InstancePtr instance;
+
+ std::map<std::string, InstancePtr>::iterator inst_it = context->instances.find(context->element_name);
+
+ if(inst_it == context->instances.end())
+ {
+ instance = new Instance(TOWSTRING(context->element_name));
+ context->instances.insert(std::make_pair(context->element_name, instance));
+ context->myBmsc->add_instance(instance);
+ context->open_instance++;
+ context->z->print_report(RS_WARNING,
+ stringize() << "Warning 23: Instance (" << TOWSTRING(context->element_name) << ") has not been started (e.g. " << TOWSTRING(context->element_name) << ": instance;)");
+ }
+ else
+ {
+ instance = inst_it->second;
+ }
+
+ if (instance->is_empty() ||
+ context->coregion_area_finished.find(context->element_name) != context->coregion_area_finished.end())
+ {
+ StrictOrderAreaPtr strict(new StrictOrderArea());
+ instance->add_area(strict);
+ context->coregion_area_finished.erase(context->element_name);
+ }
+
+ std::map<std::string, EventPtr>::iterator event_it;
+ EventPtr event;
+
+ //if the event was created prematurely
+ if(context->event_name == "" ||
+ (event_it = context->future_events.find(context->event_name)) == context->future_events.end())
+ {
+ event = instance->get_last_area()->add_event(new EventType());
+ }
+ else
+ {
+ event = event_it->second;
+ context->future_events.erase(event_it);
+ }
+
+ context->current_event = event;
+
+ //if event is named, it adds event to named_events
+ if(context->event_name != "")
+ {
+ context->named_events.insert(std::make_pair(context->event_name, event));
+ }
+
+ create_future_time_relations(context);
+ context->event_name = "";
}
- else
- {
- instance = inst_it->second;
- }
-
- if (instance->is_empty() ||
- context->coregion_area_finished.find(context->element_name) != context->coregion_area_finished.end())
- {
- StrictOrderAreaPtr strict(new StrictOrderArea());
- instance->add_area(strict);
- context->coregion_area_finished.erase(context->element_name);
- }
-
- std::map<std::string, EventPtr>::iterator event_it;
- EventPtr event;
-
- //if the event was created prematurely
- if(context->event_name == "" ||
- (event_it = context->future_events.find(context->event_name)) == context->future_events.end())
- {
- event = instance->get_last_area()->add_event(new MessageEvent());
- }
- else
- {
- event = event_it->second;
- context->future_events.erase(event_it);
- }
-
- context->current_event = event;
+};
- //if event is named, it adds event to named_events
- if(context->event_name != "")
- {
- context->named_events.insert(std::make_pair(context->event_name, event));
- }
-
- create_future_time_relations(context);
- context->event_name = "";
-}
-
-
/*
* Create incomplete message. Type of message is defined in parameter "kind"
* output: LOST message
@@ -669,7 +673,7 @@
}
}
- create_event(context);
+ ContextEventFactory<MessageEvent>::create_event(context);
IncompleteMsgType type = (kind == output ? LOST : FOUND);
IncompleteMessagePtr message = new IncompleteMessage(type, TOWSTRING(msg_name));
@@ -686,13 +690,13 @@
{
std::string statement(action_statement);
- create_event(context);
+ ContextEventFactory<LocalActionEvent>::create_event(context);
LocalActionPtr action = new LocalAction(TOWSTRING(statement));
- MessageEventPtr cur_ev = boost::dynamic_pointer_cast<MessageEvent>(context->current_event);
+ LocalActionEventPtr cur_ev = boost::dynamic_pointer_cast<LocalActionEvent>(context->current_event);
if (cur_ev == NULL)
- throw std::runtime_error("expecting a local action event");
- action->glue_event(cur_ev);
+ throw std::runtime_error("expecting a local action event, got " + std::string(typeid(*context->current_event.get()).name()));
+ action->glue_event(cur_ev.get());
}
/*
@@ -700,7 +704,7 @@
*/
void add_condition_fun(struct Context* context)
{
- create_event(context);
+ ContextEventFactory<MessageEvent>::create_event(context);
if(context->condition_shared_inst.size() > 1)
context->z->print_report(RS_WARNING,
@@ -821,7 +825,7 @@
}
}
- create_event(context);
+ ContextEventFactory<MessageEvent>::create_event(context);
std::multimap<std::string, CompleteMessagePtr>::iterator message_it;
message_it = context->messages.find(msg_identification);
@@ -896,7 +900,7 @@
else
{
InstancePtr instance = context->instances.find(context->element_name)->second;
- event1 = instance->get_last_area()->add_event(new MessageEvent()); // FIXME: really new MessageEvent? (might be, but I don't see any sense)
+ event1 = instance->get_last_area()->add_event(new MessageEvent()); // NOTE: should be some generic event, but there may only be message events in coregion anyway...
context->future_events.insert(std::make_pair(*it, event1));
}
Modified: branches/conditions/src/data/Z120/z120_save.cpp
===================================================================
--- branches/conditions/src/data/Z120/z120_save.cpp 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/Z120/z120_save.cpp 2013-05-26 14:36:20 UTC (rev 1821)
@@ -384,11 +384,8 @@
{
// REF: unhack
//hack until the object model is being fixed
- LocalAction* act = dynamic_cast<LocalAction*>(incomplete_message.get());
LocalCondition* cond = dynamic_cast<LocalCondition*>(incomplete_message.get());
- if(act != NULL)
- stream << "action '" << VALID_NAME(act->get_label()) << "'";
- else if(cond != NULL)
+ if(cond != NULL)
stream << "condition " << VALID_NAME(cond->get_label()) << " shared";
else
stream << "out " << VALID_NAME(incomplete_message->get_label())
@@ -401,9 +398,18 @@
<< " from found";
}
}
+ else if (boost::dynamic_pointer_cast<LocalActionEvent>(event) != NULL)
+ {
+ LocalActionEventPtr lae = boost::dynamic_pointer_cast<LocalActionEvent>(event);
+ LocalActionPtr act = lae->get_local_action();
+ if (act != NULL)
+ {
+ print_element_attributes(stream, act);
+ stream << "action '" << VALID_NAME(act->get_statement()) << "'";
+ }
+ }
else
{
- // TODO: process other types of events
throw std::runtime_error("unknown type of event");
}
}
Modified: branches/conditions/src/data/beautify/layout_optimizer.cpp
===================================================================
--- branches/conditions/src/data/beautify/layout_optimizer.cpp 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/beautify/layout_optimizer.cpp 2013-05-26 14:36:20 UTC (rev 1821)
@@ -147,7 +147,7 @@
long m_user_condition;
public:
- EventIndexer(long user_action, long user_condition, double action_width, double condition_width) :
+ EventIndexer(long user_action, long user_condition, double action_width, double condition_width) :
m_action_width(action_width), m_condition_width(condition_width),
m_user_action(user_action), m_user_condition(user_condition)
{
@@ -158,44 +158,49 @@
int index = m_events.size()+1;
m_events.insert(std::make_pair(e, index));
- if(m_user_action || m_user_condition)
- {
- //computing of size of actions and condition
- MessageEvent* me = dynamic_cast<MessageEvent*>(e);
- if(me != NULL && !me->is_matched())
- {
- IncompleteMessagePtr in_mess = me->get_incomplete_message();
- if(in_mess != NULL)
- {
+ //computing of size of actions and condition
+ if(m_user_action)
+ {
+ LocalActionEvent* lae = dynamic_cast<LocalActionEvent*>(e);
+ if (lae != NULL)
+ {
+ LocalActionPtr act = lae->get_local_action();
+ if (act != NULL)
+ {
+ double tmp_height = act->get_height();
+ double tmp_width = act->get_width();
+ double area = tmp_width * tmp_height;
+ act->set_width(m_action_width);
+ act->set_height(area / m_action_width);
+ }
+ }
+ }
+
+ if(m_user_condition)
+ {
+ MessageEvent* me = dynamic_cast<MessageEvent*>(e);
+ if(me != NULL && !me->is_matched())
+ {
+ IncompleteMessagePtr in_mess = me->get_incomplete_message();
+ if(in_mess != NULL)
+ {
// REF: unhack
- // NOTE: a hack for local actions and conditions support - until object model is fixed
- LocalAction* act = dynamic_cast<LocalAction*>(in_mess.get());
- LocalCondition* cond = dynamic_cast<LocalCondition*>(in_mess.get());
- if(act != NULL)
- {
- if(m_user_action)
- {
- double tmp_height = act->get_height();
- double tmp_width = act->get_width();
- double area = tmp_width * tmp_height;
- act->set_width(m_action_width);
- act->set_height(area / m_action_width);
- }
- }
- else if(cond != NULL)
- {
- if(m_user_condition)
- {
- double tmp_height = cond->get_height();
- double tmp_width = cond->get_width();
- double area = tmp_width * tmp_height;
- cond->set_height(area / m_condition_width);
- cond->set_width(m_condition_width);
- }
- }
- }
- }
- }
+ // NOTE: a hack for conditions support - until object model is fixed
+ LocalCondition* cond = dynamic_cast<LocalCondition*>(in_mess.get());
+ if(cond != NULL)
+ {
+ if(m_user_condition)
+ {
+ double tmp_height = cond->get_height();
+ double tmp_width = cond->get_width();
+ double area = tmp_width * tmp_height;
+ cond->set_height(area / m_condition_width);
+ cond->set_width(m_condition_width);
+ }
+ }
+ }
+ }
+ }
}
size_t get_event_count() const
@@ -370,15 +375,10 @@
if(in_mess != NULL)
{
// REF: unhack
- // NOTE: a hack for local actions and conditions support - until object model is fixed
- LocalAction* act = dynamic_cast<LocalAction*>(in_mess.get());
+ // NOTE: a hack for conditions support - until object model is fixed
LocalCondition* cond = dynamic_cast<LocalCondition*>(in_mess.get());
- if(act != NULL)
+ if(cond != NULL)
{
- add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance+act->get_height());
- }
- else if(cond != NULL)
- {
add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance+cond->get_height());
}
else
@@ -388,9 +388,15 @@
add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance);
}
}
+ else if (dynamic_cast<LocalActionEvent*>(event) != NULL)
+ {
+ LocalActionEvent* lae = dynamic_cast<LocalActionEvent*>(event);
+ LocalActionPtr act = lae->get_local_action();
+ if(act != NULL)
+ add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance+act->get_height());
+ }
else
{
- // TODO: process other event types
throw std::runtime_error("unknown type of event");
}
}
@@ -428,18 +434,18 @@
// update the objective function for unmatched events:
set_obj(m_lp, e1, 1.0/(m_indexer->get_event_count()+2*m_size));
+ assert(me->get_instance() != NULL);
unsigned i = me->get_instance()->get_attribute("id",i);
i++;
//double e_pos = e->get_instance()->get_line_begin().get_x();
IncompleteMessagePtr in_mess = me->get_incomplete_message();
if(in_mess->is_lost())
{
+ // LOST MESSAGE EVENT
// REF: unhack
- // NOTE: a hack for local actions and conditions support - until object model is fixed
- LocalAction* act = dynamic_cast<LocalAction*>(in_mess.get());
+ // NOTE: a hack for conditions support - until object model is fixed
LocalCondition* cond = dynamic_cast<LocalCondition*>(in_mess.get());
-
- if((act == NULL)&&(cond == NULL))
+ if(cond == NULL)
{
float horizontal_space = std::sqrt(std::pow(m_incomplete_message_length,2) - std::pow(m_send_receive_distance,2));
while(i < m_instances.size())
@@ -465,6 +471,7 @@
}
else
{
+ // FOUND MESSAGE EVENT
float horizontal_space = std::sqrt(std::pow(m_incomplete_message_length,2) - std::pow(m_send_receive_distance,2));
while(i < m_instances.size())
{
@@ -489,6 +496,7 @@
}
else
{
+ // COMPLETE MESSAGE EVENT
// solving the unoverlaying two messages or unoverlaying message and coregion edge
if(me->is_send())
{
@@ -537,9 +545,14 @@
}
}
}
+ else if (dynamic_cast<LocalActionEvent*>(e) != NULL)
+ {
+ // LOCAL ACTION
+ // update the objective function for unmatched events:
+ set_obj(m_lp, e1, 1.0/(m_indexer->get_event_count()+2*m_size));
+ }
else
{
- // TODO: process other types of events
throw std::runtime_error("unknown type of event");
}
}
@@ -635,34 +648,30 @@
if(level != 0)
{
//in level is set index of predecessor of coregion
- MessageEventPtr strictTmpMsg = boost::dynamic_pointer_cast<MessageEvent>(strictTmp);
+ // some events may define extra height
+ double extra_height = 0;
+
+ LocalActionEventPtr strictTmpAct = boost::dynamic_pointer_cast<LocalActionEvent>(strictTmp);
+ if (strictTmpAct != NULL)
+ {
+ LocalActionPtr act = strictTmpAct->get_local_action();
+ if (act != NULL)
+ extra_height = act->get_height();
+ }
+ // NOTE: a hack for conditions support - until object model is fixed
+ MessageEventPtr strictTmpMsg = boost::dynamic_pointer_cast<MessageEvent>(strictTmp);
if (strictTmpMsg != NULL && strictTmpMsg->get_incomplete_message() != NULL)
- {
+ {
IncompleteMessagePtr in_mess = strictTmpMsg->get_incomplete_message();
- if(in_mess->is_lost())
- {
- // REF: unhack
- // NOTE: a hack for local actions and conditions support - until object model is fixed
- LocalAction* act = dynamic_cast<LocalAction*>(in_mess.get());
- LocalCondition* cond = dynamic_cast<LocalCondition*>(in_mess.get());
- if (act != NULL)
- {
- double tmp_height = act->get_height();
- add_relative_distance_constraint(m_lp, level, begin, m_successor_distance + tmp_height);
- }
- else if(cond != NULL)
- {
- double tmp_height = cond->get_height();
- add_relative_distance_constraint(m_lp, level, begin, m_successor_distance + tmp_height);
- }
- else
- add_relative_distance_constraint(m_lp, level, begin, m_successor_distance);
- }
- else
- add_relative_distance_constraint(m_lp, level, begin, m_successor_distance);
- }
- else
- add_relative_distance_constraint(m_lp, level, begin, m_successor_distance);
+ if (in_mess->is_lost())
+ {
+ LocalConditionPtr cond = boost::dynamic_pointer_cast<LocalCondition>(in_mess);
+ if (cond != NULL)
+ extra_height = cond->get_height();
+ }
+ }
+
+ add_relative_distance_constraint(m_lp, level, begin, m_successor_distance + extra_height);
}
level = begin+1;
}
@@ -782,18 +791,10 @@
if(in_mess->is_lost())
{
// REF: unhack
- // NOTE: a hack for local actions and conditions support - until object model is fixed
- LocalAction* act = dynamic_cast<LocalAction*>(in_mess.get());
+ // NOTE: a hack for conditions support - until object model is fixed
LocalCondition* cond = dynamic_cast<LocalCondition*>(in_mess.get());
- if(act != NULL)
+ if(cond != NULL)
{
- double tmp_height = act->get_height();
- msg_ev->set_position(MscPoint(0, ((instance_head_distance+var[epos->second-1])*proportion) + tmp_height));
- if(((instance_head_distance+var[epos->second-1])*proportion) + tmp_height > max_y)
- max_y = ((instance_head_distance+var[epos->second-1])*proportion) + tmp_height;
- }
- else if(cond != NULL)
- {
double tmp_height = cond->get_height();
msg_ev->set_position(MscPoint(0, ((instance_head_distance+var[epos->second-1])*proportion) + tmp_height));
if(((instance_head_distance+var[epos->second-1])*proportion) + tmp_height > max_y)
@@ -811,9 +812,21 @@
msg_ev->set_position(MscPoint(0, (instance_head_distance+var[epos->second-1])*proportion));
}
}
+ else if (boost::dynamic_pointer_cast<LocalActionEvent>(epos->first) != NULL)
+ {
+ // local action
+ LocalActionEventPtr lae = boost::dynamic_pointer_cast<LocalActionEvent>(epos->first);
+ assert(dynamic_cast<StrictOrderArea*>(lae->get_area()) != NULL);
+ LocalActionPtr act = lae->get_local_action();
+ if (act != NULL)
+ {
+ double tmp_height = act->get_height();
+ lae->set_position(MscPoint(0, ((instance_head_distance+var[epos->second-1])*proportion) + tmp_height));
+ max_y = std::max(max_y, lae->get_position().get_y());
+ }
+ }
else
{
- // TODO: other types of events
throw std::runtime_error("unknown type of event");
}
@@ -833,17 +846,9 @@
{
if(in_mess->is_lost())
{
- // NOTE: a hack for local actions support - until object model is fixed
- LocalAction* act = dynamic_cast<LocalAction*>(in_mess.get());
- if(act != NULL)
- ;
- else
- in_mess->set_dot_position(MscPoint(incomplete_message_length, send_receive_distance));
// NOTE: a hack for local conditions support - until object model is fixed
LocalCondition* cond = dynamic_cast<LocalCondition*>(in_mess.get());
- if(cond != NULL)
- ;
- else
+ if(cond == NULL)
in_mess->set_dot_position(MscPoint(incomplete_message_length, send_receive_distance));
}
@@ -853,11 +858,6 @@
}
}
}
- else
- {
- // TODO: process other types of events
- throw std::runtime_error("unknown type of event");
- }
}
return max_y;
}
@@ -1097,13 +1097,6 @@
if(in_mess.get() && in_mess->is_lost())
{
// REF: unhack
- // NOTE: a hack for local actions support - until object model is fixed
- LocalAction* act = dynamic_cast<LocalAction*>(in_mess.get());
- if (act != NULL)
- {
- double tmp_height = act->get_height();
- max_y = var[indexer.get_event_index(last_event)-1] + m_instance_head_distance+tmp_height;
- }
// NOTE: a hack for local conditions support - until object model is fixed
LocalCondition* cond = dynamic_cast<LocalCondition*>(in_mess.get());
if (cond != NULL)
@@ -1114,9 +1107,18 @@
}
}
}
+ else if (boost::dynamic_pointer_cast<LocalActionEvent>(last_event) != NULL)
+ {
+ LocalActionEventPtr lae = boost::dynamic_pointer_cast<LocalActionEvent>(last_event);
+ LocalActionPtr act = boost::dynamic_pointer_cast<LocalAction>(lae->get_local_action());
+ if (act != NULL)
+ {
+ double tmp_height = act->get_height();
+ max_y = var[indexer.get_event_index(last_event)-1] + m_instance_head_distance+tmp_height;
+ }
+ }
else
{
- // TODO: other types of events - local actions and conditions handling should be moved here
throw std::runtime_error("unknown type of event");
}
}
Modified: branches/conditions/src/data/exporttex/exportTex.cpp
===================================================================
--- branches/conditions/src/data/exporttex/exportTex.cpp 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/exporttex/exportTex.cpp 2013-05-26 14:36:20 UTC (rev 1821)
@@ -459,15 +459,7 @@
if (msg_event != NULL)
{
// REF: unhack
- //temporary solution Action and Condition not implemented yet
- LocalActionPtr localAction = boost::dynamic_pointer_cast<LocalAction>(msg_event->get_incomplete_message());
- if(localAction!=NULL){
- m_stream << m_local_action_width_map.printLength(localAction->get_width());
- m_stream << m_local_action_height_map.printLength(localAction->get_height());
- m_stream << "\\action*{" << ExportTex::print_wchar(localAction->get_label()) << "}{" << m_instance_id_map.get_id(inst_pos(msg_event->get_instance())) << "_inst}" << std::endl;
- return;
- }
-
+ //temporary solution - Condition not implemented yet
LocalConditionPtr localCondition = boost::dynamic_pointer_cast<LocalCondition>(msg_event->get_incomplete_message());
if(localCondition!=NULL)
{
@@ -494,9 +486,20 @@
<< "{" << m_instance_id_map.get_id(inst_pos(msg_event->get_instance())) << "_inst}" << std::endl;
}
}
+ else if (boost::dynamic_pointer_cast<LocalActionEvent>(event) != NULL)
+ {
+ LocalActionEventPtr lae = boost::dynamic_pointer_cast<LocalActionEvent>(event);
+ LocalActionPtr act = lae->get_local_action();
+ if (act != NULL)
+ {
+ assert(lae->get_instance() != NULL);
+ m_stream << m_local_action_width_map.printLength(act->get_width());
+ m_stream << m_local_action_height_map.printLength(act->get_height());
+ m_stream << "\\action*{" << ExportTex::print_wchar(act->get_statement()) << "}{" << m_instance_id_map.get_id(inst_pos(lae->get_instance())) << "_inst}" << std::endl;
+ }
+ }
else
{
- // TODO: process other types of event
throw std::runtime_error("unknown type of event");
}
};
@@ -869,21 +872,22 @@
void insert_event(EventPtr event, Coordinate coordinate = 0)
{
MessageEventPtr msg_event = boost::dynamic_pointer_cast<MessageEvent>(event);
+ LocalActionEventPtr local_action_event = boost::dynamic_pointer_cast<LocalActionEvent>(event);
Coordinate coor = event->get_position().get_y()+coordinate; //! event absolute position in diagram
CoregionArea* coregion = dynamic_cast<CoregionArea*>(event->get_area());
- if (msg_event != NULL) // FIXME: fix local actions and conditions
+ if (local_action_event != NULL)
{
+ LocalActionPtr act = local_action_event->get_local_action();
+ if (act != NULL)
+ coor -= act->get_height();
+ }
+ if (msg_event != NULL)
+ {
// REF: unhack
- //temporary solution Action and Condition not implemented yet
- LocalActionPtr local_action = boost::dynamic_pointer_cast<LocalAction>(msg_event->get_incomplete_message());
- if(local_action!=NULL)
- {
- coor -= local_action->get_height();
- }
-
+ //temporary solution - Condition not implemented yet
LocalConditionPtr local_condition = boost::dynamic_pointer_cast<LocalCondition>(msg_event->get_incomplete_message());
if(local_condition!=NULL)
{
@@ -951,17 +955,8 @@
}
}
-
- //temporary solution Action and Condition not implemented yet
+ //temporary solution - Condition not implemented yet
// REF: unhack
- LocalActionPtr local_action = boost::dynamic_pointer_cast<LocalAction>(msg_event->get_incomplete_message());
- if(local_action!=NULL){
- edge_point(local_action->get_event()->get_instance()->get_line_begin().get_x(),local_action->get_width());
- m_local_action_width_map.addDistance(local_action->get_width());
- m_local_action_height_map.addDistance(local_action->get_height());
- return;
- }
-
LocalConditionPtr local_condition = boost::dynamic_pointer_cast<LocalCondition>(msg_event->get_incomplete_message());
if(local_condition!=NULL)
{
@@ -977,12 +972,20 @@
edge_point(incomplete_message->get_event()->get_instance()->get_line_begin().get_x()+incomplete_message->get_dot_position().get_x());
m_incomlete_mess_slope_map.addDistance(incomplete_message->get_dot_position().get_y());
m_lostfound_width_map.addDistance(fabs(incomplete_message_width_corection(incomplete_message->get_dot_position().get_x())));
- return;
}
}
+ else if (local_action_event != NULL)
+ {
+ LocalActionPtr act = local_action_event->get_local_action();
+ if (act != NULL)
+ {
+ edge_point(local_action_event->get_instance()->get_line_begin().get_x(), act->get_width());
+ m_local_action_width_map.addDistance(act->get_width());
+ m_local_action_height_map.addDistance(act->get_height());
+ }
+ }
else
{
- // TODO: process other event types
throw std::runtime_error("unknown type of event");
}
};
Modified: branches/conditions/src/data/msc/Event.h
===================================================================
--- branches/conditions/src/data/msc/Event.h 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/msc/Event.h 2013-05-26 14:36:20 UTC (rev 1821)
@@ -69,7 +69,11 @@
Event() : MscElementTmpl<Event>(), Commentable(), m_area(NULL), m_position()
{
}
-
+
+ virtual ~Event()
+ {
+ }
+
/**
* Duplicates the event. Returns a new, dynamically allocated object.
* NOTE: Especially useful for creating dynamic clones.
Added: branches/conditions/src/data/msc/LocalAction.cpp
===================================================================
--- branches/conditions/src/data/msc/LocalAction.cpp (rev 0)
+++ branches/conditions/src/data/msc/LocalAction.cpp 2013-05-26 14:36:20 UTC (rev 1821)
@@ -0,0 +1,35 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2013 Ondrej Bouda <ob...@ma...>
+ *
+ * $Id$
+ */
+
+#include "data/msc.h"
+
+void LocalAction::glue_event(LocalActionEvent* event)
+{
+ if(event != m_event)
+ {
+ // unglue, if already glued
+ if(m_event != NULL)
+ m_event->set_local_action(NULL);
+
+ if(event != NULL)
+ event->set_local_action(this);
+
+ m_event = event;
+ }
+}
+
Property changes on: branches/conditions/src/data/msc/LocalAction.cpp
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Modified: branches/conditions/src/data/msc/LocalAction.h
===================================================================
--- branches/conditions/src/data/msc/LocalAction.h 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/msc/LocalAction.h 2013-05-26 14:36:20 UTC (rev 1821)
@@ -22,24 +22,71 @@
/**
* \brief Local action on an instance in Basic MSC.
*/
-class SCMSC_EXPORT LocalAction : public IncompleteMessage
-// NOTE: just a quick hack until the object model is fixed; LocalAction behaves just like a lost message
+class SCMSC_EXPORT LocalAction : public MscElementTmpl<LocalAction>
{
+ /**
+ * Action statement.
+ */
+ std::wstring m_statement;
+
+ /**
+ * Peer event.
+ * @warning boost::intrusive_ptr mustn't be used because of possible cyclic dependency
+ */
+ LocalActionEvent* m_event;
+
Coordinate m_width;
Coordinate m_height;
public:
- LocalAction(const std::wstring& label = L"", Coordinate width = 0.0, Coordinate height = 0.0) :
- IncompleteMessage(LOST, label), m_width(width), m_height(height)
+ LocalAction(const std::wstring& statement = L"", Coordinate width = 0.0, Coordinate height = 0.0) :
+ m_statement(statement), m_event(NULL), m_width(width), m_height(height)
{
}
- Coordinate get_width() const { return m_width; }
- Coordinate get_height() const { return m_height; }
- void set_width(Coordinate width) { m_width = width; }
- void set_height(Coordinate height) { m_height = height; }
+ LocalAction(LocalAction* original)
+ : MscElementTmpl<LocalAction>(original),
+ m_statement(original->m_statement), m_event(NULL),
+ m_width(original->m_width), m_height(original->m_height)
+ {
+ }
+
+ const std::wstring& get_statement() const
+ {
+ return m_statement;
+ }
+
+ void glue_event(LocalActionEvent* event);
+
+ LocalActionEvent* get_event()
+ {
+ return m_event;
+ }
+
+ bool is_glued() const
+ {
+ return m_event != NULL;
+ }
+
+ Coordinate get_width() const
+ {
+ return m_width;
+ }
+
+ Coordinate get_height() const
+ {
+ return m_height;
+ }
+
+ void set_width(Coordinate width)
+ {
+ m_width = width;
+ }
+
+ void set_height(Coordinate height)
+ {
+ m_height = height;
+ }
};
-typedef boost::intrusive_ptr<LocalAction> LocalActionPtr;
-
#endif // #ifndef _LOCALACTION_H
Added: branches/conditions/src/data/msc/LocalActionEvent.h
===================================================================
--- branches/conditions/src/data/msc/LocalActionEvent.h (rev 0)
+++ branches/conditions/src/data/msc/LocalActionEvent.h 2013-05-26 14:36:20 UTC (rev 1821)
@@ -0,0 +1,75 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2013 Ondrej Bouda <ob...@ma...>
+ *
+ * $Id$
+ */
+
+#ifndef _LOCALACTIONEVENT_H
+#define _LOCALACTIONEVENT_H
+
+#include "data/msc/EventTmpl.h"
+#include "data/msc/EventArea.h"
+#include "data/msc/MscElementTmpl.h"
+#include "data/msc/Commentable.h"
+
+/**
+ * \brief An event caused by a local action.
+ */
+class SCMSC_EXPORT LocalActionEvent : public EventTmpl<LocalAction>
+{
+protected:
+ LocalActionEvent(LocalActionEvent* original) : EventTmpl<LocalAction>(original)
+ {
+ }
+
+public:
+
+ LocalActionEvent() : EventTmpl<LocalAction>()
+ {
+ }
+
+ Event* clone()
+ {
+ return new LocalActionEvent(this);
+ }
+
+ const std::wstring to_string()
+ {
+ if (get_local_action() != NULL)
+ return L"Event of " + get_local_action()->get_statement() + L" local action";
+ else
+ return L"An unattached local action event";
+ }
+
+ /**
+ * Sets the local action this event is attached to.
+ * Just a convenience method - alias for set_element().
+ */
+ void set_local_action(const LocalActionPtr& local_action)
+ {
+ set_element(local_action);
+ }
+
+ /**
+ * Gets the local action this event is attached to.
+ * Just a convenience method - alias for get_element().
+ */
+ const LocalActionPtr& get_local_action() const
+ {
+ return get_element();
+ }
+};
+
+#endif // #ifndef _LOCALACTIONEVENT_H
Property changes on: branches/conditions/src/data/msc/LocalActionEvent.h
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Modified: branches/conditions/src/data/msc/MessageEvent.cpp
===================================================================
--- branches/conditions/src/data/msc/MessageEvent.cpp 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/msc/MessageEvent.cpp 2013-05-26 14:36:20 UTC (rev 1821)
@@ -28,7 +28,7 @@
IncompleteMessage* incomplete = dynamic_cast<IncompleteMessage*>(get_message().get());
// note: hack until object model is fixed
- if (incomplete == NULL || dynamic_cast<LocalAction*>(incomplete) != NULL || dynamic_cast<LocalCondition*>(incomplete) != NULL)
+ if (incomplete == NULL || dynamic_cast<LocalCondition*>(incomplete) != NULL)
return false;
return incomplete->is_lost();
@@ -37,8 +37,8 @@
bool MessageEvent::is_receive() const
{
// FIXME: should return !is_send(); when the hack is eliminated
- if (!is_matched() && (get_message().get() == NULL || dynamic_cast<LocalAction*>(get_message().get()) != NULL ||
- dynamic_cast<LocalCondition*>(get_message().get()) != NULL)) return false; // note: hack until object model is fixed
+ if (!is_matched() && (get_message().get() == NULL || dynamic_cast<LocalCondition*>(get_message().get()) != NULL)) // NOTE: hack until object model is fixed
+ return false;
return !is_send();
}
Modified: branches/conditions/src/data/msc/MessageEvent.h
===================================================================
--- branches/conditions/src/data/msc/MessageEvent.h 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/msc/MessageEvent.h 2013-05-26 14:36:20 UTC (rev 1821)
@@ -42,10 +42,6 @@
{
}
- virtual ~MessageEvent()
- {
- }
-
Event* clone()
{
return new MessageEvent(this);
Modified: branches/conditions/src/data/msc/MscMessage.h
===================================================================
--- branches/conditions/src/data/msc/MscMessage.h 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/msc/MscMessage.h 2013-05-26 14:36:20 UTC (rev 1821)
@@ -46,10 +46,6 @@
m_label = original->get_label();
}
- virtual ~MscMessage()
- {
- }
-
const std::wstring& get_label() const
{
return m_label;
Modified: branches/conditions/src/data/msc.h
===================================================================
--- branches/conditions/src/data/msc.h 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/msc.h 2013-05-26 14:36:20 UTC (rev 1821)
@@ -56,6 +56,7 @@
class Instance;
class Event;
class MessageEvent;
+class LocalActionEvent;
class CoregionEventRelation;
class Msc;
class BMsc;
@@ -64,6 +65,7 @@
class MscMessage;
class CompleteMessage;
class IncompleteMessage;
+class LocalAction;
class EventArea;
class StrictOrderArea;
class CoregionArea;
@@ -131,7 +133,10 @@
typedef std::set<MessageEventPtr> MessageEventPtrSet;
typedef std::list<MessageEventPtr> MessageEventPtrList;
+typedef boost::intrusive_ptr<LocalActionEvent> LocalActionEventPtr;
+
typedef boost::intrusive_ptr<MscMessage> MscMessagePtr;
+typedef boost::intrusive_ptr<LocalAction> LocalActionPtr;
typedef boost::intrusive_ptr<EventArea> EventAreaPtr;
typedef std::list<EventAreaPtr> EventAreaPtrList;
@@ -194,6 +199,7 @@
#include "data/msc/Event.h"
#include "data/msc/EventTmpl.h"
#include "data/msc/MessageEvent.h"
+#include "data/msc/LocalActionEvent.h"
#include "data/msc/CoregionEventRelation.h"
#include "data/msc/EventArea.h"
#include "data/msc/StrictOrderArea.h"
Modified: branches/conditions/src/data/time_relevant_ordering/time_relevant_ordering.cpp
===================================================================
--- branches/conditions/src/data/time_relevant_ordering/time_relevant_ordering.cpp 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/data/time_relevant_ordering/time_relevant_ordering.cpp 2013-05-26 14:36:20 UTC (rev 1821)
@@ -214,19 +214,10 @@
if(in_mess != NULL)
{
// REF: unhack
- // NOTE: a hack for local actions and conditions support - until object model is fixed
- LocalActionPtr act = boost::dynamic_pointer_cast<LocalAction>(in_mess);
+ // NOTE: a hack for conditions support - until object model is fixed
LocalConditionPtr cond = boost::dynamic_pointer_cast<LocalCondition>(in_mess);
- if(act != NULL)
+ if(cond != NULL)
{
- double tmp_height = act->get_height();
- double tmp_width = act->get_width();
- double area = tmp_width * tmp_height;
- act->set_width(settings.m_action_width);
- act->set_height(area / settings.m_action_width);
- }
- else if(cond != NULL)
- {
double tmp_height = cond->get_height();
double tmp_width = cond->get_width();
double area = tmp_width * tmp_height;
@@ -247,12 +238,22 @@
}
}
}
+ else if (boost::dynamic_pointer_cast<LocalActionEvent>(first_event) != NULL)
+ {
+ LocalActionEventPtr first_act_event = boost::dynamic_pointer_cast<LocalActionEvent>(first_event);
+ LocalActionPtr act = first_act_event->get_local_action();
+
+ double tmp_height = act->get_height();
+ double tmp_width = act->get_width();
+ double area = tmp_width * tmp_height;
+ act->set_width(settings.m_action_width);
+ act->set_height(area / settings.m_action_width);
+ }
+ else
+ {
+ throw std::runtime_error("unknown type of event");
+ }
}
- else
- {
- // TODO: process other event types
- throw std::runtime_error("unknown type of event");
- }
}
return sorted_events;
@@ -297,9 +298,8 @@
{
if(in_mess->is_lost())
{
- LocalActionPtr act = boost::dynamic_pointer_cast<LocalAction>(in_mess);
LocalConditionPtr cond = boost::dynamic_pointer_cast<LocalCondition>(in_mess);
- if(act == NULL && cond == NULL)
+ if(cond == NULL)
{
in_mess->set_dot_position(MscPoint(settings.m_instance_space/3,0));
}
@@ -383,9 +383,8 @@
{
if(in_mess->is_lost())
{
- LocalActionPtr act = boost::dynamic_pointer_cast<LocalAction>(in_mess);
LocalConditionPtr cond = boost::dynamic_pointer_cast<LocalCondition>(in_mess);
- if(act == NULL && cond == NULL)
+ if(cond == NULL)
{
in_mess->set_dot_position(MscPoint(ins->get_line_begin().get_x()+(settings.m_instance_space/3),0));
}
Modified: branches/conditions/src/view/visio/addon/extract.cpp
===================================================================
--- branches/conditions/src/view/visio/addon/extract.cpp 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/view/visio/addon/extract.cpp 2013-05-26 14:36:20 UTC (rev 1821)
@@ -345,7 +345,7 @@
}
CoregionAreaPtr CDrawingExtractor::create_coregion_area(EventPointMap& events,
- const MscMessageMap& messages, Visio::IVShapePtr coregion)
+ const MscElementMap& elements, Visio::IVShapePtr coregion)
{
Visio::IVPagePtr vsoPage = coregion->ContainingPage;
std::wstring page_name = (const wchar_t*)vsoPage->Name;
@@ -376,7 +376,7 @@
{
case ST_BMSC_MESSAGE:
{
- CompleteMessagePtr message = find_message<CompleteMessage>(messages, shape->ID);
+ CompleteMessagePtr message = find_element<CompleteMessage>(elements, shape->ID);
if(message == NULL)
continue;
// create coregion event
@@ -404,7 +404,7 @@
case ST_BMSC_MESSAGE_LOST:
{
- IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
+ IncompleteMessagePtr message = find_element<IncompleteMessage>(elements, shape->ID);
if(message == NULL)
continue;
// create coregion event
@@ -425,7 +425,7 @@
}
case ST_BMSC_MESSAGE_FOUND:
{
- IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
+ IncompleteMessagePtr message = find_element<IncompleteMessage>(elements, shape->ID);
if(message == NULL)
continue;
// create coregion event
@@ -580,7 +580,7 @@
// temporary mappers Visio shape-id --> msc.h
EventPointMap events; // all events in the drawing
std::map<long,InstancePtr> instances;
- MscMessageMap messages;
+ MscElementMap elements;
TimeRelationEventMap time_relations;
std::map<long, AbsoluteTimePtrList> absolute_times;
std::map<long,CommentPtr> comments;
@@ -600,14 +600,14 @@
break;
case ST_BMSC_MESSAGE:
- messages[shape->ID] = new CompleteMessage((const wchar_t*)shape->Text);
+ elements[shape->ID] = new CompleteMessage((const wchar_t*)shape->Text);
break;
case ST_BMSC_MESSAGE_LOST:
{
IncompleteMessage *new_message = new IncompleteMessage(LOST, (const wchar_t*)shape->Text);
// lost message: glued on begin, dot on end
new_message->set_dot_position(GetLineEnd(shape)-GetLineBegin(shape));
- messages[shape->ID] = new_message;
+ elements[shape->ID] = new_message;
break;
}
case ST_BMSC_MESSAGE_FOUND:
@@ -615,7 +615,7 @@
IncompleteMessage *new_message = new IncompleteMessage(FOUND, (const wchar_t*)shape->Text);
// found message: glued on end, dot on begin
new_message->set_dot_position(GetLineBegin(shape)-GetLineEnd(shape));
- messages[shape->ID] = new_message;
+ elements[shape->ID] = new_message;
break;
}
@@ -623,11 +623,11 @@
{
LocalAction* new_local_action = new LocalAction((const wchar_t*)shape->Text);
// note: this shape is rotated by 90 degrees
- new_local_action->set_width(GetHeight(shape));
- new_local_action->set_height(GetWidth(shape));
+ new_local_action->set_width(GetHeight(shape));
+ new_local_action->set_height(GetWidth(shape));
//new_local_action->set_width(GetControlPos(shape, _T("Height")));
//new_local_action->set_height(GetControlPos(shape, _T("Width")));
- messages[shape->ID] = new_local_action; // NOTE: hack - local action behaves like a lost message
+ elements[shape->ID] = new_local_action;
break;
}
@@ -639,7 +639,7 @@
new_local_condition->set_height(GetWidth(shape));
//new_local_condition->set_width(GetControlPos(shape, _T("Height")));
//new_local_condition->set_height(GetControlPos(shape, _T("Width")));
- messages[shape->ID] = new_local_condition; // NOTE: hack - local condition behaves like a lost message
+ elements[shape->ID] = new_local_condition; // NOTE: hack - local condition behaves like a lost message
break;
}
@@ -817,24 +817,24 @@
case ST_BMSC_ACTION:
// local actions are just hacked for the moment
{
- std::map<long,int>::iterator connections = local_action_connections.find(event.shape_id);
- if (connections == local_action_connections.end())
- {
- local_action_connections[event.shape_id] = 1;
- continue;
+ std::map<long,int>::iterator connections = local_action_connections.find(event.shape_id);
+ if (connections == local_action_connections.end())
+ {
+ local_action_connections[event.shape_id] = 1;
+ continue;
+ }
+ else if (connections->second == 1)
+ {
+ event.event_type = SStrictOrder::ET_OUTGOING;
+ }
+ else
+ {
+ PrintError(stringize() << page_name << ": "
+ << "Wrongly connected local action '" << shape->Name << "'",
+ shapelist() << shape << instance);
+ continue;
+ }
}
- else if (connections->second == 1)
- {
- event.event_type = SStrictOrder::ET_OUTGOING;
- }
- else
- {
- PrintError(stringize() << page_name << ": "
- << "Wrongly connected local action '" << shape->Name << "'",
- shapelist() << shape << instance);
- continue;
- }
- }
break;
case ST_BMSC_CONDITION:
@@ -909,9 +909,8 @@
this_shapelist << vsoPage->Shapes->ItemFromID[cpos->shape_id];
}
- PrintError(stringize() << page_name << ": "
- << "Multiple events cannot be attached to one point.",
- this_shapelist << instance);
+ PrintError(stringize() << page_name << ": " << "Multiple events cannot be attached to one point.",
+ this_shapelist << instance);
}
}
@@ -932,6 +931,7 @@
{
Visio::IVShapePtr shape = vsoPage->Shapes->ItemFromID[epos->shape_id];
+ // TODO: many cases have very similar body, merge together
switch(epos->shape_type)
{
case ST_BMSC_MESSAGE:
@@ -943,7 +943,7 @@
/* no break */
case ST_STRICT:
{
- CompleteMessagePtr message = find_message<CompleteMessage>(messages, epos->shape_id);
+ CompleteMessagePtr message = find_element<CompleteMessage>(elements, epos->shape_id);
if(message == NULL)
continue;
@@ -959,17 +959,15 @@
}
case ST_COREGION:
- PrintError(stringize() << page_name << ": "
- << "Instance events cannot occur behind coregion.",
- shapelist() << shape << instance);
+ PrintError(stringize() << page_name << ": " << "Instance events cannot occur behind coregion.",
+ shapelist() << shape << instance);
break;
}
break;
case ST_BMSC_MESSAGE_LOST:
case ST_BMSC_MESSAGE_FOUND:
- case ST_BMSC_ACTION:
- case ST_BMSC_CONDITION: // NOTE: hack - local action and condition behaves like a lost message
+ case ST_BMSC_CONDITION: // NOTE: hack - condition behaves like a lost message
switch(state)
{
case ST_EXPECTING_AREA:
@@ -978,7 +976,7 @@
/* no break */
case ST_STRICT:
{
- IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, epos->shape_id);
+ IncompleteMessagePtr message = find_element<IncompleteMessage>(elements, epos->shape_id);
if(message == NULL)
continue;
@@ -991,12 +989,39 @@
}
case ST_COREGION:
- PrintError(stringize() << page_name << ": "
- << "Instance events cannot occur behind coregion.",
- shapelist() << shape << instance);
+ PrintError(stringize() << page_name << ": " << "Instance events cannot occur behind coregion.",
+ shapelist() << shape << instance);
break;
}
break;
+
+ case ST_BMSC_ACTION:
+ switch(state)
+ {
+ case ST_EXPECTING_AREA:
+ ipos->second->add_area(strict_area = new StrictOrderArea());
+ state = ST_STRICT;
+ /* no break */
+ case ST_STRICT:
+ {
+ LocalActionPtr act = find_element<LocalAction>(elements, epos->shape_id);
+ if(act == NULL)
+ continue;
+
+ LocalActionEventPtr event = strict_area->add_event(new LocalActionEvent());
+ event->set_position(ConvertEventPoint(instance, epos->event_pos));
+ act->glue_event(event);
+
+ events.insert(std::make_pair<SPoint,EventPtr>(point_to_page(instance, epos->event_pos), event));
+ break;
+ }
+
+ case ST_COREGION:
+ PrintError(stringize() << page_name << ": " << "Instance events cannot occur behind coregion.",
+ shapelist() << shape << instance);
+ break;
+ }
+ break;
case ST_BMSC_COREGION:
{
@@ -1006,15 +1031,14 @@
case ST_STRICT:
if(epos->event_type == SStrictOrder::ET_OUTGOING)
{
- ipos->second->add_area(coregion_area = create_coregion_area(events, messages, shape));
+ ipos->second->add_area(coregion_area = create_coregion_area(events, elements, shape));
coregion_area->set_begin_height(ConvertCoordinate(instance, epos->event_height));
coregion_area->set_width(shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters]);
}
else
{
- PrintError(stringize() << page_name << ": "
- << "Misdirected coregion.",
- shapelist() << shape);
+ PrintError(stringize() << page_name << ": " << "Misdirected coregion.",
+ shapelist() << shape);
}
state = ST_COREGION;
@@ -1024,9 +1048,8 @@
case ST_COREGION:
if(coregion_id != epos->shape_id)
{
- PrintError(stringize() << page_name << ": "
- << "Overlapping coregion.",
- shapelist() << shape);
+ PrintError(stringize() << page_name << ": " << "Overlapping coregion.",
+ shapelist() << shape);
}
else if(epos->event_type == SStrictOrder::ET_INCOMING)
{
@@ -1049,24 +1072,34 @@
{
Visio::IVShapePtr shape = vsoPage->Shapes->ItemFromID[coregion_id];
- PrintError(stringize() << page_name << ": "
- << "Disconnected coregion.",
- shapelist() << shape);
+ PrintError(stringize() << page_name << ": " << "Disconnected coregion.",
+ shapelist() << shape);
}
}
- // walk through detected messages: check all messages are connected
- for(MscMessageMap::const_iterator mpos = messages.begin();
- mpos != messages.end(); mpos++)
+ // walk through detected elements: check all glueable elements are connected
+ for(MscElementMap::const_iterator epos = elements.begin(); epos != elements.end(); mpos++)
{
Visio::IVShapePtr shape = vsoPage->Shapes->ItemFromID[mpos->first];
-
- if(!mpos->second->is_glued())
+ MscElementPtr el = epos->second;
+
+ MscMessagePtr msg_el = boost::dynamic_pointer_cast<MscMessage>(el);
+ if (msg_el != NULL)
{
- PrintError(stringize() << page_name << ": "
- << "Disconnected message '" << shape->Name << "'",
- shapelist() << shape);
+ if (!msg_el->is_glued())
+ PrintError(stringize() << page_name << ": " << "Disconnected message '" << shape->Name << "'",
+ shapelist() << shape);
+ continue;
}
+
+ LocalActionPtr act_el = boost::dynamic_pointer_cast<LocalAction>(el);
+ if (act_el != NULL)
+ {
+ if (!act_el->is_glued())
+ PrintError(stringize() << page_name << ": " << "Disconnected message '" << shape->Name << "'",
+ shapelist() << shape);
+ continue;
+ }
}
// walk though all detected time relations: create measurements
Modified: branches/conditions/src/view/visio/addon/extract.h
===================================================================
--- branches/conditions/src/view/visio/addon/extract.h 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/view/visio/addon/extract.h 2013-05-26 14:36:20 UTC (rev 1821)
@@ -164,22 +164,23 @@
// contains the sematically first event, if multiple events are attached
typedef std::map<SPoint,EventPtr> EventPointMap;
+ typedef std::map<long,MscElementPtr> MscElementMap;
typedef std::map<long,MscMessagePtr> MscMessageMap;
typedef std::map<long,TimeRelationEventPtr> TimeRelationEventMap;
typedef std::map<long,TimeRelationRefNodePtr> TimeRelationRefNodeMap;
template<class M>
- boost::intrusive_ptr<M> find_message(const MscMessageMap& messages, long id)
+ boost::intrusive_ptr<M> find_element(const MscElementMap& elements, long id)
{
- MscMessageMap::const_iterator mpos = messages.find(id);
- if(mpos == messages.end())
+ MscElementMap::const_iterator mpos = elements.find(id);
+ if(mpos == elements.end())
return NULL;
return boost::dynamic_pointer_cast<M>(mpos->second);
}
//! process the given coregion and build a relevant CoregionArea
- CoregionAreaPtr create_coregion_area(EventPointMap& events, const MscMessageMap& messages,
+ CoregionAreaPtr create_coregion_area(EventPointMap& events, const MscElementMap& elements,
Visio::IVShapePtr coregion);
struct SStrictOrder
Modified: branches/conditions/src/view/visio/addon/visualize.cpp
===================================================================
--- branches/conditions/src/view/visio/addon/visualize.cpp 2013-05-26 00:24:04 UTC (rev 1820)
+++ branches/conditions/src/view/visio/addon/visualize.cpp 2013-05-26 14:36:20 UTC (rev 1821)
@@ -270,31 +270,37 @@
}
}
-Visio::IVShapePtr CDrawingVisualizer::drop_message(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
- MscMessagePtr message, Visio::IVMasterPtr master)
+Visio::IVShapePtr CDrawingVisualizer::drop_shape(Visio::IVPagePtr vsoPage, ElementPtrMap& shapes,
+ MscElementPtr element, Visio::IVMasterPtr master)
{
- Visio::IVShapePtr msg = messages[message];
- if(msg != NULL)
- return msg;
+ Visio::IVShapePtr shape = shapes[element];
+ if(shape != NULL)
+ return shape;
- msg = vsoPage->Drop(master, 0, 0);
+ shape = vsoPage->Drop(master, 0, 0);
- switch(message->get_marked())
+ switch(element->get_marked())
{
- case NONE: CShapeUtils::MarkShape(msg, SC_BLACK); break;
- case MARKED: CShapeUtils::MarkShape(msg, SC_RED); break;
- case ADDED: CShapeUtils::MarkShape(msg, SC_DARK_GREEN); break;
- case REMOVED: CShapeUtils::MarkShape(msg, SC_RED); break;
+ case NONE: CShapeUtils::MarkShape(shape, SC_BLACK); break;
+ case MARKED: CShapeUtils::MarkShape(shape, SC_RED); break;
+ case ADDED: CShapeUtils::MarkShape(shape, SC_DARK_GREEN); break;
+ case REMOVED: CShapeUtils::MarkShape(shape, SC_RED); break;
default: throw std::runtime_error("Error: unexpected behaviour");
}
- msg->Text = message->get_label().c_str();
- messages[message] = msg;
+ if (boost::dynamic_pointer_cast<Message>(element) != NULL)
+ shape->Text = boost::dynamic_pointer_cast<Message>(element)->get_label().c_str();
+ else if (boost::dynamic_pointer_cast<LocalAction>(element) != NULL)
+ shape->Text = boost::dynamic_pointer_cast<LocalAction>(element)->get_statement().c_str();
+ else
+ throw std::runtime_error("Error: unknown element type");
+
+ shapes[element] = shape;
- return msg;
+ return shape;
}
-void CDrawingVisualizer::show_event(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
+void CDrawingVisualizer::show_event(Visio::IVPagePtr vsoPage, ElementPtrMap& shapes,
Visio::IVShapePtr parent, EventPtr event)
{
MessageEventPtr msg_event = boost::dynamic_pointer_cast<MessageEvent>(event);
@@ -303,7 +309,7 @@
CompleteMessagePtr complete_message = msg_event->get_complete_message();
if(complete_message != NULL)
{
- Visio::IVShapePtr msg = drop_message(vsoPage, messages, complete_message, find_master(ST_BMSC_MESSAGE));
+ Visio::IVShapePtr msg = drop_shape(vsoPage, shapes, complete_message, find_master(ST_BMSC_MESSAGE));
if(complete_message->get_send_event() == event)
CShapeUtils::GlueBeginToPos(msg, parent, event->get_position());
@@ -316,24 +322,13 @@
{
if(incomplete_message->is_lost())
{
- // NOTE: hack - for local actions, a lost message is (mis)used until the object model is fixed
+ // NOTE: hack - for conditions, a lost message is (mis)used until the object model is fixed
// REF: unhack
- LocalAction* local_action = dynamic_cast<LocalAction*>(incomplete_message.get());
LocalCondition* local_condition = dynamic_cas...
[truncated message content] |