|
From: <ob...@us...> - 2013-05-26 17:54:37
|
Revision: 1823
http://sourceforge.net/p/scstudio/code/1823
Author: obouda
Date: 2013-05-26 17:54:35 +0000 (Sun, 26 May 2013)
Log Message:
-----------
unhacked conditions - now, ConditionEvent is used, and Condition 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/Condition.h
branches/conditions/src/data/msc/MessageEvent.cpp
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/visualize.cpp
Added Paths:
-----------
branches/conditions/src/data/msc/Condition.cpp
branches/conditions/src/data/msc/ConditionEvent.h
Modified: branches/conditions/src/data/CMakeLists.txt
===================================================================
--- branches/conditions/src/data/CMakeLists.txt 2013-05-26 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/data/CMakeLists.txt 2013-05-26 17:54:35 UTC (rev 1823)
@@ -46,7 +46,9 @@
msc/Commentable.h
msc/CompleteMessage.cpp
msc/CompleteMessage.h
+ msc/Condition.cpp
msc/Condition.h
+ msc/ConditionEvent.h
msc/ConditionNode.cpp
msc/ConditionNode.h
msc/ConnectionNode.h
Modified: branches/conditions/src/data/Z120/Context.cpp
===================================================================
--- branches/conditions/src/data/Z120/Context.cpp 2013-05-26 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/data/Z120/Context.cpp 2013-05-26 17:54:35 UTC (rev 1823)
@@ -704,17 +704,17 @@
*/
void add_condition_fun(struct Context* context)
{
- ContextEventFactory<MessageEvent>::create_event(context);
+ ContextEventFactory<ConditionEvent>::create_event(context);
if(context->condition_shared_inst.size() > 1)
context->z->print_report(RS_WARNING,
stringize() << "Warning 34: Condition across multiple instances is not supported yet.");
- ConditionPtr local_condition = new Condition(TOWSTRING(context->condition_name));
- MessageEventPtr cur_ev = boost::dynamic_pointer_cast<MessageEvent>(context->current_event);
+ ConditionPtr condition = new Condition(TOWSTRING(context->condition_name));
+ ConditionEventPtr cur_ev = boost::dynamic_pointer_cast<ConditionEvent>(context->current_event);
if (cur_ev == NULL)
- throw std::runtime_error("expecting a condition event");
- local_condition->glue_event(cur_ev);
+ throw std::runtime_error("expecting a condition event, got " + std::string(typeid(*context->current_event.get()).name()));
+ condition->glue_event(cur_ev.get());
}
/*
Modified: branches/conditions/src/data/Z120/z120_save.cpp
===================================================================
--- branches/conditions/src/data/Z120/z120_save.cpp 2013-05-26 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/data/Z120/z120_save.cpp 2013-05-26 17:54:35 UTC (rev 1823)
@@ -382,15 +382,9 @@
print_element_attributes(stream, incomplete_message);
if(incomplete_message->is_lost())
{
- // REF: unhack
- //hack until the object model is being fixed
- Condition* cond = dynamic_cast<Condition*>(incomplete_message.get());
- if(cond != NULL)
- stream << "condition " << VALID_NAME(cond->get_label()) << " shared";
- else
- stream << "out " << VALID_NAME(incomplete_message->get_label())
- << "," << message_id_map.get_id(incomplete_message)
- << " to lost";
+ stream << "out " << VALID_NAME(incomplete_message->get_label())
+ << "," << message_id_map.get_id(incomplete_message)
+ << " to lost";
}
if(incomplete_message->is_found())
stream << "in " << VALID_NAME(incomplete_message->get_label())
@@ -408,6 +402,16 @@
stream << "action '" << VALID_NAME(act->get_statement()) << "'";
}
}
+ else if (boost::dynamic_pointer_cast<ConditionEvent>(event) != NULL)
+ {
+ ConditionEventPtr ce = boost::dynamic_pointer_cast<ConditionEvent>(event);
+ ConditionPtr cond = ce->get_condition();
+ if(cond != NULL)
+ {
+ print_element_attributes(stream, cond);
+ stream << "condition " << VALID_NAME(cond->get_text()) << " shared";
+ }
+ }
else
{
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 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/data/beautify/layout_optimizer.cpp 2013-05-26 17:54:35 UTC (rev 1823)
@@ -178,26 +178,17 @@
if(m_user_condition)
{
- MessageEvent* me = dynamic_cast<MessageEvent*>(e);
- if(me != NULL && !me->is_matched())
+ ConditionEvent* ce = dynamic_cast<ConditionEvent*>(e);
+ if (ce != NULL)
{
- IncompleteMessagePtr in_mess = me->get_incomplete_message();
- if(in_mess != NULL)
+ ConditionPtr cond = ce->get_condition();
+ if (cond != NULL)
{
- // REF: unhack
- // NOTE: a hack for conditions support - until object model is fixed
- Condition* cond = dynamic_cast<Condition*>(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);
- }
- }
+ 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);
}
}
}
@@ -365,28 +356,7 @@
MessageEvent* msg_event = dynamic_cast<MessageEvent*>(event);
if (msg_event != NULL)
{
- if(msg_event->is_matched())
- {
- add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance);
- }
- else
- {
- IncompleteMessagePtr in_mess = msg_event->get_incomplete_message();
- if(in_mess != NULL)
- {
- // REF: unhack
- // NOTE: a hack for conditions support - until object model is fixed
- Condition* cond = dynamic_cast<Condition*>(in_mess.get());
- if(cond != NULL)
- {
- add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance+cond->get_height());
- }
- else
- add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance);
- }
- else
- add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance);
- }
+ add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance);
}
else if (dynamic_cast<LocalActionEvent*>(event) != NULL)
{
@@ -395,6 +365,13 @@
if(act != NULL)
add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance+act->get_height());
}
+ else if (dynamic_cast<ConditionEvent*>(event) != NULL)
+ {
+ ConditionEvent* ce = dynamic_cast<ConditionEvent*>(event);
+ ConditionPtr cond = ce->get_condition();
+ if (cond != NULL)
+ add_relative_distance_constraint(m_lp, e1, e2, m_successor_distance+cond->get_height());
+ }
else
{
throw std::runtime_error("unknown type of event");
@@ -442,31 +419,25 @@
if(in_mess->is_lost())
{
// LOST MESSAGE EVENT
- // REF: unhack
- // NOTE: a hack for conditions support - until object model is fixed
- Condition* cond = dynamic_cast<Condition*>(in_mess.get());
- 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())
{
- float horizontal_space = std::sqrt(std::pow(m_incomplete_message_length,2) - std::pow(m_send_receive_distance,2));
- while(i < m_instances.size())
+ double next_inst_space = m_instances.at(i)->get_line_begin().get_x() - me->get_instance()->get_line_begin().get_x();
+ if(next_inst_space <= horizontal_space)
{
- double next_inst_space = m_instances.at(i)->get_line_begin().get_x() - me->get_instance()->get_line_begin().get_x();
- if(next_inst_space <= horizontal_space)
- {
- double crossing = m_send_receive_distance* (next_inst_space / horizontal_space);
- if(me->get_incomplete_message()->is_found())
- crossing = -crossing;
- UnoverlayingMessages unoverlaying(m_lp, m_indexer, me, crossing);
- unoverlaying.m_successor_distance = m_successor_distance;
- DFSInstanceEventsTraverser traverser;
- traverser.add_white_event_found_listener(&unoverlaying);
- traverser.traverse((m_instances.at(i)).get());
- horizontal_space = horizontal_space - (float)next_inst_space;
- i++;
- }
- else
- break;
+ double crossing = m_send_receive_distance* (next_inst_space / horizontal_space);
+ if(me->get_incomplete_message()->is_found())
+ crossing = -crossing;
+ UnoverlayingMessages unoverlaying(m_lp, m_indexer, me, crossing);
+ unoverlaying.m_successor_distance = m_successor_distance;
+ DFSInstanceEventsTraverser traverser;
+ traverser.add_white_event_found_listener(&unoverlaying);
+ traverser.traverse((m_instances.at(i)).get());
+ horizontal_space = horizontal_space - (float)next_inst_space;
+ i++;
}
+ else
+ break;
}
}
else
@@ -545,9 +516,9 @@
}
}
}
- else if (dynamic_cast<LocalActionEvent*>(e) != NULL)
+ else if (dynamic_cast<LocalActionEvent*>(e) != NULL || dynamic_cast<ConditionEvent*>(e) != NULL)
{
- // LOCAL ACTION
+ // LOCAL ACTION or CONDITION
// update the objective function for unmatched events:
set_obj(m_lp, e1, 1.0/(m_indexer->get_event_count()+2*m_size));
}
@@ -658,17 +629,13 @@
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)
+
+ ConditionEventPtr strictTmpCond = boost::dynamic_pointer_cast<ConditionEvent>(strictTmp);
+ if (strictTmpCond != NULL)
{
- IncompleteMessagePtr in_mess = strictTmpMsg->get_incomplete_message();
- if (in_mess->is_lost())
- {
- ConditionPtr cond = boost::dynamic_pointer_cast<Condition>(in_mess);
- if (cond != NULL)
- extra_height = cond->get_height();
- }
+ ConditionPtr cond = strictTmpCond->get_condition();
+ if (cond != NULL)
+ extra_height = cond->get_height();
}
add_relative_distance_constraint(m_lp, level, begin, m_successor_distance + extra_height);
@@ -785,31 +752,7 @@
else
{
// note: var element 0 contains the first variable, etc.
- IncompleteMessagePtr in_mess = msg_ev->get_incomplete_message();
- if(in_mess.get())
- {
- if(in_mess->is_lost())
- {
- // REF: unhack
- // NOTE: a hack for conditions support - until object model is fixed
- Condition* cond = dynamic_cast<Condition*>(in_mess.get());
- 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)
- max_y = ((instance_head_distance+var[epos->second-1])*proportion) + tmp_height;
- }
- else
- msg_ev->set_position(MscPoint(0, (instance_head_distance+var[epos->second-1])*proportion));
- }
- //message found
- else
- msg_ev->set_position(MscPoint(0, (instance_head_distance+var[epos->second-1])*proportion));
- }
- //complete message
- else
- msg_ev->set_position(MscPoint(0, (instance_head_distance+var[epos->second-1])*proportion));
+ msg_ev->set_position(MscPoint(0, (instance_head_distance+var[epos->second-1])*proportion));
}
}
else if (boost::dynamic_pointer_cast<LocalActionEvent>(epos->first) != NULL)
@@ -825,6 +768,19 @@
max_y = std::max(max_y, lae->get_position().get_y());
}
}
+ else if (boost::dynamic_pointer_cast<ConditionEvent>(epos->first) != NULL)
+ {
+ // condition
+ ConditionEventPtr ce = boost::dynamic_pointer_cast<ConditionEvent>(epos->first);
+ assert(dynamic_cast<StrictOrderArea*>(ce->get_area()) != NULL);
+ ConditionPtr cond = ce->get_condition();
+ if (cond != NULL)
+ {
+ double tmp_height = cond->get_height();
+ ce->set_position(MscPoint(0, ((instance_head_distance+var[epos->second-1])*proportion) + tmp_height));
+ max_y = std::max(max_y, ce->get_position().get_y());
+ }
+ }
else
{
throw std::runtime_error("unknown type of event");
@@ -845,17 +801,9 @@
if(in_mess.get())
{
if(in_mess->is_lost())
- {
- // NOTE: a hack for local conditions support - until object model is fixed
- Condition* cond = dynamic_cast<Condition*>(in_mess.get());
- if(cond == NULL)
- in_mess->set_dot_position(MscPoint(incomplete_message_length, send_receive_distance));
-
- }
- else if(in_mess->is_found())
- {
+ in_mess->set_dot_position(MscPoint(incomplete_message_length, send_receive_distance));
+ else
in_mess->set_dot_position(MscPoint(-incomplete_message_length, -send_receive_distance));
- }
}
}
}
@@ -1091,21 +1039,6 @@
{
max_y = var[indexer.get_event_index(last_msg_event)-1] + m_instance_head_distance;
}
- else
- {
- IncompleteMessagePtr in_mess = last_msg_event->get_incomplete_message();
- if(in_mess.get() && in_mess->is_lost())
- {
- // REF: unhack
- // NOTE: a hack for local conditions support - until object model is fixed
- Condition* cond = dynamic_cast<Condition*>(in_mess.get());
- if (cond != NULL)
- {
- double tmp_height = cond->get_height();
- max_y = var[indexer.get_event_index(last_event)-1] + m_instance_head_distance+tmp_height;
- }
- }
- }
}
else if (boost::dynamic_pointer_cast<LocalActionEvent>(last_event) != NULL)
{
@@ -1117,6 +1050,16 @@
max_y = var[indexer.get_event_index(last_event)-1] + m_instance_head_distance+tmp_height;
}
}
+ else if (boost::dynamic_pointer_cast<ConditionEvent>(last_event) != NULL)
+ {
+ ConditionEventPtr ce = boost::dynamic_pointer_cast<ConditionEvent>(last_event);
+ ConditionPtr cond = boost::dynamic_pointer_cast<Condition>(ce->get_condition());
+ if (cond != NULL)
+ {
+ double tmp_height = cond->get_height();
+ max_y = var[indexer.get_event_index(last_event)-1] + m_instance_head_distance+tmp_height;
+ }
+ }
else
{
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 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/data/exporttex/exportTex.cpp 2013-05-26 17:54:35 UTC (rev 1823)
@@ -452,23 +452,12 @@
}
}
- //only complete message is printed on send event(receive event is skiped)
+ //only complete message is printed on send event (receive event is skipped)
//for all other items we can print color
print_color(event->get_marked());
if (msg_event != NULL)
{
- // REF: unhack
- //temporary solution - Condition not implemented yet
- ConditionPtr localCondition = boost::dynamic_pointer_cast<Condition>(msg_event->get_incomplete_message());
- if(localCondition!=NULL)
- {
- m_stream << m_local_condition_height_map.printLength(localCondition->get_height());
- m_stream << m_local_condition_width_map.printLength(localCondition->get_width()/2);
- m_stream << "\\condition*{" << ExportTex::print_wchar(localCondition->get_label()) << "}{" << m_instance_id_map.get_id(inst_pos(msg_event->get_instance())) << "_inst}" << std::endl;
- return;
- }
-
IncompleteMessagePtr incomplete_message = msg_event->get_incomplete_message();
if(incomplete_message != NULL)
{
@@ -498,6 +487,18 @@
m_stream << "\\action*{" << ExportTex::print_wchar(act->get_statement()) << "}{" << m_instance_id_map.get_id(inst_pos(lae->get_instance())) << "_inst}" << std::endl;
}
}
+ else if (boost::dynamic_pointer_cast<ConditionEvent>(event) != NULL)
+ {
+ ConditionEventPtr ce = boost::dynamic_pointer_cast<ConditionEvent>(event);
+ ConditionPtr cond = ce->get_condition();
+ if(cond != NULL)
+ {
+ assert(ce->get_instance() != NULL);
+ m_stream << m_local_condition_height_map.printLength(cond->get_height());
+ m_stream << m_local_condition_width_map.printLength(cond->get_width()/2);
+ m_stream << "\\condition*{" << ExportTex::print_wchar(cond->get_text()) << "}{" << m_instance_id_map.get_id(inst_pos(ce->get_instance())) << "_inst}" << std::endl;
+ }
+ }
else
{
throw std::runtime_error("unknown type of event");
@@ -873,6 +874,7 @@
{
MessageEventPtr msg_event = boost::dynamic_pointer_cast<MessageEvent>(event);
LocalActionEventPtr local_action_event = boost::dynamic_pointer_cast<LocalActionEvent>(event);
+ ConditionEventPtr condition_event = boost::dynamic_pointer_cast<ConditionEvent>(event);
Coordinate coor = event->get_position().get_y()+coordinate; //! event absolute position in diagram
@@ -884,16 +886,13 @@
if (act != NULL)
coor -= act->get_height();
}
- if (msg_event != NULL)
+ if (condition_event != NULL)
{
- // REF: unhack
- //temporary solution - Condition not implemented yet
- ConditionPtr local_condition = boost::dynamic_pointer_cast<Condition>(msg_event->get_incomplete_message());
- if(local_condition!=NULL)
- {
- coor -= local_condition->get_height();
- }
+ ConditionPtr cond = condition_event->get_condition();
+ if (cond != NULL)
+ coor -= cond->get_height();
}
+
insert_pointer(event,coor);
insert_time_relations(event,coor);
//print orderings associated with event
@@ -955,17 +954,6 @@
}
}
- //temporary solution - Condition not implemented yet
- // REF: unhack
- ConditionPtr local_condition = boost::dynamic_pointer_cast<Condition>(msg_event->get_incomplete_message());
- if(local_condition!=NULL)
- {
- edge_point(local_condition->get_event()->get_instance()->get_line_begin().get_x(),local_condition->get_width());
- m_local_condition_width_map.addDistance(local_condition->get_width()/2);
- m_local_condition_height_map.addDistance(local_condition->get_height());
- return;
- }
-
IncompleteMessagePtr incomplete_message = msg_event->get_incomplete_message();
if(incomplete_message != NULL)
{
@@ -979,11 +967,23 @@
LocalActionPtr act = local_action_event->get_local_action();
if (act != NULL)
{
+ assert(local_action_event->get_instance() != 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 if (condition_event != NULL)
+ {
+ ConditionPtr cond = condition_event->get_condition();
+ if (cond != NULL)
+ {
+ assert(condition_event->get_instance() != NULL);
+ edge_point(condition_event->get_instance()->get_line_begin().get_x(), cond->get_width());
+ m_local_condition_width_map.addDistance(cond->get_width()/2);
+ m_local_condition_height_map.addDistance(cond->get_height());
+ }
+ }
else
{
throw std::runtime_error("unknown type of event");
Added: branches/conditions/src/data/msc/Condition.cpp
===================================================================
--- branches/conditions/src/data/msc/Condition.cpp (rev 0)
+++ branches/conditions/src/data/msc/Condition.cpp 2013-05-26 17:54:35 UTC (rev 1823)
@@ -0,0 +1,34 @@
+/*
+ * 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 Condition::glue_event(ConditionEvent* event)
+{
+ if(event != m_event)
+ {
+ // unglue, if already glued
+ if(m_event != NULL)
+ m_event->set_condition(NULL);
+
+ if(event != NULL)
+ event->set_condition(this);
+
+ m_event = event;
+ }
+}
Property changes on: branches/conditions/src/data/msc/Condition.cpp
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Modified: branches/conditions/src/data/msc/Condition.h
===================================================================
--- branches/conditions/src/data/msc/Condition.h 2013-05-26 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/data/msc/Condition.h 2013-05-26 17:54:35 UTC (rev 1823)
@@ -20,26 +20,74 @@
#define _CONDITION_H
/**
- * \brief Local condition on an instance in Basic MSC.
+ * \brief Condition on an instance in Basic MSC.
+ * TODO: support multiple instances bound to a single condition
*/
-class SCMSC_EXPORT Condition : public IncompleteMessage
-// NOTE: just a quick hack until the object model is fixed; Condition behaves just like a lost message
+class SCMSC_EXPORT Condition : public MscElementTmpl<Condition>
{
+ /**
+ * Condition text.
+ */
+ std::wstring m_text;
+
+ /**
+ * Peer event.
+ * @warning boost::intrusive_ptr mustn't be used because of possible cyclic dependency
+ */
+ ConditionEvent* m_event;
+
Coordinate m_width;
Coordinate m_height;
public:
- Condition(const std::wstring& label = L"", Coordinate width = 0.0, Coordinate height = 0.0) :
- IncompleteMessage(LOST, label), m_width(width), m_height(height)
+ Condition(const std::wstring& text = L"", Coordinate width = 0.0, Coordinate height = 0.0) :
+ m_text(text), m_event(NULL), m_width(width), m_height(height)
{
}
+
+ Condition(Condition* original)
+ : MscElementTmpl<Condition>(original),
+ m_text(original->m_text), m_event(NULL),
+ m_width(original->m_width), m_height(original->m_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; }
+ const std::wstring& get_text() const
+ {
+ return m_text;
+ }
+
+ void glue_event(ConditionEvent* event);
+
+ ConditionEvent* 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<Condition> ConditionPtr;
-
#endif // #ifndef _CONDITION_H
Added: branches/conditions/src/data/msc/ConditionEvent.h
===================================================================
--- branches/conditions/src/data/msc/ConditionEvent.h (rev 0)
+++ branches/conditions/src/data/msc/ConditionEvent.h 2013-05-26 17:54:35 UTC (rev 1823)
@@ -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 _CONDITIONEVENT_H
+#define _CONDITIONEVENT_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 condition.
+ */
+class SCMSC_EXPORT ConditionEvent : public EventTmpl<Condition>
+{
+protected:
+ ConditionEvent(ConditionEvent* original) : EventTmpl<Condition>(original)
+ {
+ }
+
+public:
+
+ ConditionEvent() : EventTmpl<Condition>()
+ {
+ }
+
+ Event* clone()
+ {
+ return new ConditionEvent(this);
+ }
+
+ const std::wstring to_string()
+ {
+ if (get_condition() != NULL)
+ return L"Event of " + get_condition()->get_text() + L" condition";
+ else
+ return L"An unattached condition event";
+ }
+
+ /**
+ * Sets the condition this event is attached to.
+ * Just a convenience method - alias for set_element().
+ */
+ void set_condition(const ConditionPtr& condition)
+ {
+ set_element(condition);
+ }
+
+ /**
+ * Gets the condition this event is attached to.
+ * Just a convenience method - alias for get_element().
+ */
+ const ConditionPtr& get_condition() const
+ {
+ return get_element();
+ }
+};
+
+#endif // #ifndef _CONDITIONEVENT_H
Property changes on: branches/conditions/src/data/msc/ConditionEvent.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 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/data/msc/MessageEvent.cpp 2013-05-26 17:54:35 UTC (rev 1823)
@@ -23,22 +23,14 @@
{
CompleteMessagePtr complete = get_complete_message();
if (complete != NULL)
- return complete->get_send_event() == this;
+ return (complete->get_send_event() == this);
IncompleteMessage* incomplete = dynamic_cast<IncompleteMessage*>(get_message().get());
-
- // note: hack until object model is fixed
- if (incomplete == NULL || dynamic_cast<Condition*>(incomplete) != NULL)
- return false;
-
return incomplete->is_lost();
}
bool MessageEvent::is_receive() const
{
- // FIXME: should return !is_send(); when the hack is eliminated
- if (!is_matched() && (get_message().get() == NULL || dynamic_cast<Condition*>(get_message().get()) != NULL)) // NOTE: hack until object model is fixed
- return false;
return !is_send();
}
Modified: branches/conditions/src/data/msc.h
===================================================================
--- branches/conditions/src/data/msc.h 2013-05-26 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/data/msc.h 2013-05-26 17:54:35 UTC (rev 1823)
@@ -57,6 +57,7 @@
class Event;
class MessageEvent;
class LocalActionEvent;
+class ConditionEvent;
class CoregionEventRelation;
class Msc;
class BMsc;
@@ -66,6 +67,7 @@
class CompleteMessage;
class IncompleteMessage;
class LocalAction;
+class Condition;
class EventArea;
class StrictOrderArea;
class CoregionArea;
@@ -134,9 +136,11 @@
typedef std::list<MessageEventPtr> MessageEventPtrList;
typedef boost::intrusive_ptr<LocalActionEvent> LocalActionEventPtr;
+typedef boost::intrusive_ptr<ConditionEvent> ConditionEventPtr;
typedef boost::intrusive_ptr<MscMessage> MscMessagePtr;
typedef boost::intrusive_ptr<LocalAction> LocalActionPtr;
+typedef boost::intrusive_ptr<Condition> ConditionPtr;
typedef boost::intrusive_ptr<EventArea> EventAreaPtr;
typedef std::list<EventAreaPtr> EventAreaPtrList;
@@ -200,6 +204,7 @@
#include "data/msc/EventTmpl.h"
#include "data/msc/MessageEvent.h"
#include "data/msc/LocalActionEvent.h"
+#include "data/msc/ConditionEvent.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 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/data/time_relevant_ordering/time_relevant_ordering.cpp 2013-05-26 17:54:35 UTC (rev 1823)
@@ -208,26 +208,8 @@
MessageEventPtr first_msg_event = boost::dynamic_pointer_cast<MessageEvent>(first_event);
if (first_msg_event != NULL)
{
- if(!first_msg_event->is_matched())
+ if(first_msg_event->is_matched())
{
- IncompleteMessagePtr in_mess = first_msg_event->get_incomplete_message();
- if(in_mess != NULL)
- {
- // REF: unhack
- // NOTE: a hack for conditions support - until object model is fixed
- ConditionPtr cond = boost::dynamic_pointer_cast<Condition>(in_mess);
- if(cond != NULL)
- {
- double tmp_height = cond->get_height();
- double tmp_width = cond->get_width();
- double area = tmp_width * tmp_height;
- cond->set_height(area / settings.m_condition_width);
- cond->set_width(settings.m_condition_width);
- }
- }
- }
- else
- {
MessageEventPtr e = first_msg_event->get_matching_event();
if(instance_map.find(e->get_instance()) == instance_map.end())
continue;
@@ -249,6 +231,17 @@
act->set_width(settings.m_action_width);
act->set_height(area / settings.m_action_width);
}
+ else if (boost::dynamic_pointer_cast<ConditionEvent>(first_event) != NULL)
+ {
+ ConditionEventPtr first_cond_event = boost::dynamic_pointer_cast<ConditionEvent>(first_event);
+ ConditionPtr cond = first_cond_event->get_condition();
+
+ double tmp_height = cond->get_height();
+ double tmp_width = cond->get_width();
+ double area = tmp_width * tmp_height;
+ cond->set_height(area / settings.m_condition_width);
+ cond->set_width(settings.m_condition_width);
+ }
else
{
throw std::runtime_error("unknown type of event");
@@ -292,17 +285,12 @@
MessageEventPtr msg_ev = boost::dynamic_pointer_cast<MessageEvent>(*it);
if (msg_ev != NULL)
{
- // REF: unhack
IncompleteMessagePtr in_mess = msg_ev->get_incomplete_message();
if(in_mess.get())
{
if(in_mess->is_lost())
{
- ConditionPtr cond = boost::dynamic_pointer_cast<Condition>(in_mess);
- if(cond == NULL)
- {
- in_mess->set_dot_position(MscPoint(settings.m_instance_space/3,0));
- }
+ in_mess->set_dot_position(MscPoint(settings.m_instance_space/3,0));
}
else if(in_mess->is_found())
{
@@ -377,17 +365,12 @@
MessageEventPtr msg_ev = boost::dynamic_pointer_cast<MessageEvent>(*it);
if (msg_ev != NULL)
{
- // REF: unhack
IncompleteMessagePtr in_mess = msg_ev->get_incomplete_message();
if(in_mess.get())
{
if(in_mess->is_lost())
{
- ConditionPtr cond = boost::dynamic_pointer_cast<Condition>(in_mess);
- if(cond == NULL)
- {
- in_mess->set_dot_position(MscPoint(ins->get_line_begin().get_x()+(settings.m_instance_space/3),0));
- }
+ in_mess->set_dot_position(MscPoint(ins->get_line_begin().get_x()+(settings.m_instance_space/3),0));
}
else if(in_mess->is_found())
{
Modified: branches/conditions/src/view/visio/addon/extract.cpp
===================================================================
--- branches/conditions/src/view/visio/addon/extract.cpp 2013-05-26 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/view/visio/addon/extract.cpp 2013-05-26 17:54:35 UTC (rev 1823)
@@ -38,7 +38,7 @@
case ST_BMSC_MESSAGE_LOST:
case ST_BMSC_MESSAGE_FOUND:
case ST_BMSC_ACTION:
- case ST_BMSC_CONDITION:
+ case ST_BMSC_CONDITION:
case ST_BMSC_COREGION:
case ST_BMSC_ORDER_LINE:
case ST_BMSC_ORDER_ARROW:
@@ -633,13 +633,13 @@
case ST_BMSC_CONDITION:
{
- Condition* new_local_condition = new Condition((const wchar_t*)shape->Text);
+ Condition* new_condition = new Condition((const wchar_t*)shape->Text);
// note: this shape is rotated by 90 degrees
- new_local_condition->set_width(GetHeight(shape));
- new_local_condition->set_height(GetWidth(shape));
+ new_condition->set_width(GetHeight(shape));
+ new_condition->set_height(GetWidth(shape));
//new_local_condition->set_width(GetControlPos(shape, _T("Height")));
//new_local_condition->set_height(GetControlPos(shape, _T("Width")));
- elements[shape->ID] = new_local_condition; // NOTE: hack - local condition behaves like a lost message
+ elements[shape->ID] = new_condition;
break;
}
@@ -752,7 +752,7 @@
// local action connections each should have two connection points
std::map<long,int> local_action_connections;
- std::map<long,int> local_condition_connections;
+ std::map<long,int> condition_connections;
typedef std::multiset<SStrictOrder> TEventSet;
TEventSet strict_events; // events in this strict area
@@ -815,7 +815,6 @@
break;
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())
@@ -829,36 +828,33 @@
}
else
{
- PrintError(stringize() << page_name << ": "
- << "Wrongly connected local action '" << shape->Name << "'",
+ PrintError(stringize() << page_name << ": " << "Wrongly connected local action '" << shape->Name << "'",
shapelist() << shape << instance);
continue;
}
}
break;
- case ST_BMSC_CONDITION:
- //local condition are just hacked for the moment
- {
- std::map<long,int>::iterator connections = local_condition_connections.find(event.shape_id);
- if (connections == local_condition_connections.end())
- {
- local_condition_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 condition '" << shape->Name << "'",
- shapelist() << shape << instance);
+ case ST_BMSC_CONDITION:
+ {
+ std::map<long,int>::iterator connections = condition_connections.find(event.shape_id);
+ if (connections == condition_connections.end())
+ {
+ condition_connections[event.shape_id] = 1;
continue;
- }
- }
- break;
+ }
+ else if (connections->second == 1)
+ {
+ event.event_type = SStrictOrder::ET_OUTGOING;
+ }
+ else
+ {
+ PrintError(stringize() << page_name << ": " << "Wrongly connected condition '" << shape->Name << "'",
+ shapelist() << shape << instance);
+ continue;
+ }
+ }
+ break;
case ST_TIME_INTERVAL:
case ST_TIME_DIRECTED:
@@ -967,7 +963,6 @@
case ST_BMSC_MESSAGE_LOST:
case ST_BMSC_MESSAGE_FOUND:
- case ST_BMSC_CONDITION: // NOTE: hack - condition behaves like a lost message
switch(state)
{
case ST_EXPECTING_AREA:
@@ -1023,6 +1018,34 @@
}
break;
+ case ST_BMSC_CONDITION:
+ switch(state)
+ {
+ case ST_EXPECTING_AREA:
+ ipos->second->add_area(strict_area = new StrictOrderArea());
+ state = ST_STRICT;
+ /* no break */
+ case ST_STRICT:
+ {
+ ConditionPtr cond = find_element<Condition>(elements, epos->shape_id);
+ if(cond == NULL)
+ continue;
+
+ ConditionEventPtr event = strict_area->add_event(new ConditionEvent());
+ event->set_position(ConvertEventPoint(instance, epos->event_pos));
+ cond->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:
{
switch(state)
@@ -1077,7 +1100,7 @@
}
}
- // walk through detected elements: check all glueable elements are connected
+ // walk through detected elements: check all gluable elements are connected
for(MscElementMap::const_iterator epos = elements.begin(); epos != elements.end(); mpos++)
{
Visio::IVShapePtr shape = vsoPage->Shapes->ItemFromID[mpos->first];
@@ -1096,10 +1119,19 @@
if (act_el != NULL)
{
if (!act_el->is_glued())
- PrintError(stringize() << page_name << ": " << "Disconnected message '" << shape->Name << "'",
+ PrintError(stringize() << page_name << ": " << "Disconnected local action '" << shape->Name << "'",
shapelist() << shape);
continue;
}
+
+ ConditionPtr cond_el = boost::dynamic_pointer_cast<Condition>(el);
+ if (cond_el != NULL)
+ {
+ if (!cond_el->is_glued())
+ PrintError(stringize() << page_name << ": " << "Disconnected condition '" << shape->Name << "'",
+ shapelist() << shape);
+ continue;
+ }
}
// walk though all detected time relations: create measurements
Modified: branches/conditions/src/view/visio/addon/visualize.cpp
===================================================================
--- branches/conditions/src/view/visio/addon/visualize.cpp 2013-05-26 15:54:24 UTC (rev 1822)
+++ branches/conditions/src/view/visio/addon/visualize.cpp 2013-05-26 17:54:35 UTC (rev 1823)
@@ -292,6 +292,8 @@
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 if (boost::dynamic_pointer_cast<Condition>(element) != NULL)
+ shape->Text = boost::dynamic_pointer_cast<Condition>(element)->get_text().c_str();
else
throw std::runtime_error("Error: unknown element type");
@@ -322,24 +324,9 @@
{
if(incomplete_message->is_lost())
{
- // NOTE: hack - for conditions, a lost message is (mis)used until the object model is fixed
- // REF: unhack
- Condition* local_condition = dynamic_cast<Condition*>(incomplete_message.get());
- if(local_condition != NULL)
- {
- Visio::IVShapePtr cond = drop_shape(vsoPage, shapes, incomplete_message, find_master(ST_BMSC_CONDITION));
- // note: local actions are rotated by 90' in Visio, height is the 'x' coordinate
- CShapeUtils::GlueBeginToPos(cond, parent, event->get_position() - MscPoint(0, local_condition->get_height()));
- CShapeUtils::GlueEndToPos(cond, parent, event->get_position());
- cond->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->PutResult(visMillimeters, local_condition->get_width());
- cond->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->PutResult(visMillimeters, local_condition->get_height());
- }
- else
- {
- Visio::IVShapePtr msg = drop_shape(vsoPage, shapes, incomplete_message, find_master(ST_BMSC_MESSAGE_LOST));
- CShapeUtils::GlueBeginToPos(msg, parent, event->get_position());
- SetLineEnd(msg, GetLineBegin(msg)+incomplete_message->get_dot_position());
- }
+ Visio::IVShapePtr msg = drop_shape(vsoPage, shapes, incomplete_message, find_master(ST_BMSC_MESSAGE_LOST));
+ CShapeUtils::GlueBeginToPos(msg, parent, event->get_position());
+ SetLineEnd(msg, GetLineBegin(msg)+incomplete_message->get_dot_position());
}
else if(incomplete_message->is_found())
{
@@ -361,6 +348,17 @@
act_shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->PutResult(visMillimeters, act->get_width());
act_shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->PutResult(visMillimeters, act->get_height());
}
+ else if (boost::dynamic_pointer_cast<ConditionEvent>(event) != NULL)
+ {
+ ConditionEventPtr cond_event = boost::dynamic_pointer_cast<ConditionEvent>(event);
+ ConditionPtr cond = cond_event->get_condition();
+ Visio::IVShapePtr cond_shape = drop_shape(vsoPage, shapes, cond, find_master(ST_BMSC_CONDITION));
+ // note: conditions are rotated by 90' in Visio, height is the 'x' coordinate
+ CShapeUtils::GlueBeginToPos(cond_shape, parent, event->get_position() - MscPoint(0, cond->get_height()));
+ CShapeUtils::GlueEndToPos(cond_shape, parent, event->get_position());
+ cond_shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->PutResult(visMillimeters, cond->get_width());
+ cond_shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->PutResult(visMillimeters, cond->get_height());
+ }
else
{
throw std::runtime_error("Error: unknown type of event");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|