--- a/src/netanim/examples/resources_demo.cc Sat Jan 11 07:35:34 2014 -0800
+++ b/src/netanim/examples/resources_demo.cc Sun Jan 12 10:06:27 2014 -0800
@@ -168,8 +168,10 @@
// Create the animation object and configure for specified output
pAnim = new AnimationInterface (animFile, true); // true --> Enable 3.105 behavior
- resourceId1 = pAnim->AddResource ("/home/john/Desktop/star1.png");
- resourceId2 = pAnim->AddResource ("/home/john/Desktop/star2.png");
+ // Provide the absolute path to the resource
+ resourceId1 = pAnim->AddResource ("./ns-3-logo1.png");
+ resourceId2 = pAnim->AddResource ("./ns-3-logo2.png");
+ pAnim->SetBackgroundImage ("./ns-3-background.png", 0, 0, 1, 1);
Simulator::Schedule (Seconds (0.1), modify);
// Set up the acutal simulation
--- a/src/netanim/model/animation-interface.cc Sat Jan 11 07:35:34 2014 -0800
+++ b/src/netanim/model/animation-interface.cc Sun Jan 12 10:06:27 2014 -0800
@@ -1798,6 +1798,14 @@
userBoundary->yMin = minY;
}
+void AnimationInterface::SetBackgroundImage (std::string fileName, double x, double y, double scaleX, double scaleY)
+{
+ std::ostringstream oss;
+ oss << GetXMLOpenCloseUpdateBackground (fileName, x, y, scaleX, scaleY);
+ WriteN (oss.str (), m_f);
+}
+
+
void AnimationInterface::SetNodeColor (Ptr <Node> n, uint8_t r, uint8_t g, uint8_t b)
{
if (initialized)
@@ -2256,6 +2264,18 @@
return oss.str ();
}
+std::string AnimationInterface::GetXMLOpenCloseUpdateBackground (std::string fileName, double x, double y, double scaleX, double scaleY)
+{
+ std::ostringstream oss;
+ oss << "<bg f=\"" << fileName << "\""
+ << " x=\"" << x << "\""
+ << " y=\"" << y << "\""
+ << " sx=\"" << scaleX << "\""
+ << " sy=\"" << scaleY << "\""
+ << "/>" << std::endl;
+ return oss.str ();
+}
+
std::string AnimationInterface::GetXMLOpenClose_NonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType)
{
--- a/src/netanim/model/animation-interface.h Sat Jan 11 07:35:34 2014 -0800
+++ b/src/netanim/model/animation-interface.h Sun Jan 12 10:06:27 2014 -0800
@@ -346,6 +346,16 @@
static void SetNodeColor (NodeContainer nc, uint8_t r, uint8_t g, uint8_t b);
/**
+ * \brief Helper function to set the background image
+ * \param fileName File name of the background image
+ * \param x X co-ordinate of the image
+ * \param y Y co-ordinate of the image
+ * \param scaleX X scale of the image
+ * \param scaleY Y scale of the image
+ */
+ void SetBackgroundImage (std::string fileName, double x, double y, double scaleX=1, double scaleY=1);
+
+ /**
* \brief Helper function to set the description for a link
* \param fromNode Node Id of the "from Node" of the p2p link
* \param toNode Node Id of the "to Node" of the p2p link
@@ -702,6 +712,7 @@
std::string GetXMLOpenClose_NonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType);
std::string GetXMLOpenClose_routing (uint32_t id, std::string routingInfo);
std::string GetXMLOpenClose_rp (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
+ std::string GetXMLOpenCloseUpdateBackground (std::string fileName, double x, double y, double scaleX, double scaleY);
void AppendXMLNodeDescription (std::ostream& ostream, uint32_t id) const;
void AppendXMLNodeColor (std::ostream& ostream, const Rgb& color) const;