/* === M A C R O S ========================================================= */
+#define CURRENT_CANVAS_VERSION "0.2"
+
/* === T Y P E D E F S ===================================================== */
/* === C L A S S E S & S T R U C T S ======================================= */
/*! \see set_description(), get_description() */
String description_;
+ //! Contains the canvas' version string
+ /*! \see set_version(), get_version() */
+ String version_;
+
//! Contains the author's name
/*! \see set_author(), get_author() */
String author_;
//! Sets the name of the canvas
void set_name(const String &x);
+ //! Gets the version string of the canvas
+ const String get_version()const { return version_; }
+
+ //! Sets the version string of the canvas
+ void set_version(const String &x) { version_ = x; }
+
//! Gets the author of the canvas
const String & get_author()const { return author_; }
else
error_unexpected_element(child,child->get_name());
}
+
+ // in canvas version 0.1, angles used to wrap, so to get from -179
+ // degrees to 180 degrees meant a 1 degree change
+ // in canvas version 0.2 they don't, so that's a 359 degree change
+
+ // when loading a version 0.1 canvas, modify constant angle
+ // waypoints to that they are within 180 degrees of the previous
+ // waypoint's value
+ if (type == ValueBase::TYPE_ANGLE)
+ {
+ Canvas::Handle parent = canvas;
+ while (!parent->is_root())
+ parent = parent->parent();
+
+ if (parent->get_version() == "0.1")
+ {
+ bool first = true;
+ Real angle, prev;
+ WaypointList &wl = value_node->waypoint_list();
+ for (WaypointList::iterator iter = wl.begin(); iter != wl.end(); iter++)
+ {
+ angle = Angle::deg(iter->get_value(iter->get_time()).get(Angle())).get();
+ if (first)
+ first = false;
+ else if (iter->get_value_node()->get_name() == "constant")
+ if (angle - prev > 180)
+ {
+ while (angle - prev > 180) angle -= 360;
+ iter->set_value(Angle::deg(angle));
+ }
+ else if (prev - angle > 180)
+ {
+ while (prev - angle > 180) angle += 360;
+ iter->set_value(Angle::deg(angle));
+ }
+ prev = angle;
+ }
+ }
+ }
+
value_node->changed();
return value_node;
}
canvas->set_guid(guid);
}
+ if(element->get_attribute("version"))
+ canvas->set_version(element->get_attribute("version")->get_value());
+
if(element->get_attribute("width"))
canvas->rend_desc().set_w(atoi(element->get_attribute("width")->get_value().c_str()));
nodes.c_str()));
}
+ canvas->set_version(CURRENT_CANVAS_VERSION);
return canvas;
}
root->set_name("canvas");
if(canvas->is_root())
- root->set_attribute("version","0.1");
+ root->set_attribute("version",canvas->get_version());
if(!canvas->get_id().empty() && !canvas->is_root() && !canvas->is_inline())
root->set_attribute("id",canvas->get_id());