WhipExamples/ObjectNode.cpp

00001 //
00002 //  Copyright (c) 2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 #include "whiptk/whip_toolkit.h"
00023 #include "whiptk/w2d_class_factory.h"
00024 
00025 extern WT_File *whip_file; //Assume this has been opened for writing elsewhere.
00026 
00027 WT_Result ObjectNode()
00028 {
00029     WT_W2D_Class_Factory cf;
00030 
00031     //Store the current object node.
00032     WT_Object_Node *current_node = cf.Create_Object_Node(whip_file->desired_rendition().object_node());
00033     if (current_node == NULL)
00034         return WT_Result::Out_Of_Memory_Error;
00035     //Define some polylines.
00036     int x=0,y=0;
00037     WT_Logical_Point vP[4];
00038     vP[0] = WT_Logical_Point(x,y);
00039     vP[1] = WT_Logical_Point(x+50,y);
00040     vP[2] = WT_Logical_Point(x,y+100);
00041     vP[3] = WT_Logical_Point(x+50,y+100);
00042     vP[4] = WT_Logical_Point(x,y+200);
00043     vP[5] = WT_Logical_Point(x+50,y+200);
00044     //Create the polylines.
00045     WT_Polyline *p1 = cf.Create_Polyline(2, vP, WD_True);
00046     if (p1 == NULL)
00047         return WT_Result::Out_Of_Memory_Error;
00048     WT_Polyline *p2 = cf.Create_Polyline(2, &vP[2], WD_True);
00049     if (p2 == NULL)
00050         return WT_Result::Out_Of_Memory_Error;
00051     WT_Polyline *p3 = cf.Create_Polyline(2, &vP[4], WD_True);
00052     if (p3 == NULL)
00053         return WT_Result::Out_Of_Memory_Error;
00054     //Serialize line 1, associated with node 1.
00055     whip_file->desired_rendition().object_node().set(*whip_file, 1, "Node 1");
00056     WD_CHECK(p1->serialize (*whip_file));
00057     //Serialize line 2, associated with node 2.
00058     whip_file->desired_rendition().object_node().set(*whip_file, 2, "Node 2");
00059     WD_CHECK(p2->serialize (*whip_file));
00060     //Serialize line 3, associated with node 1 (no need to specify the name again.)
00061     whip_file->desired_rendition().object_node().set(*whip_file, 1);
00062     WD_CHECK(p3->serialize (*whip_file));
00063     //Restore the saved object node.
00064     whip_file->desired_rendition().object_node() = *current_node;
00065 
00066     cf.Destroy( p1 );
00067     cf.Destroy( p2 );
00068     cf.Destroy( p3 );
00069     cf.Destroy( current_node );
00070     return WT_Result::Success;
00071 }

Generated on Tue Jan 6 22:41:12 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5