WhipExamples/SingleLine.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 
00026 #define PALETTE_RED 1 // Color in the default colormap is red.
00027         // The definition of the default color map is in
00028         // "palette.h". If you don't like the default palette,
00029         // you can set your own by setting the color map attribute
00030         // on the file's desired_rendition.
00031 void write_my_whip()
00032 {
00033     WT_W2D_Class_Factory cf;
00034     WT_File *my_file = cf.Create_File();
00035     if (my_file == NULL)
00036         return;
00037 
00038     my_file->set_filename("testfile.w2d");
00039     my_file->set_file_mode(WT_File::File_Write);
00040     my_file->open();
00041 
00042     my_file->desired_rendition().color().set(PALETTE_RED, my_file->desired_rendition().color_map());
00043 
00044     WT_Logical_Point my_points[2] = { WT_Logical_Point(0, 0),
00045                                      WT_Logical_Point(30, 30) };
00046     WT_Polyline *my_line = cf.Create_Polyline(2, my_points, WD_False);
00047     my_line->serialize(*my_file);
00048     my_file->close();
00049     
00050     cf.Destroy( my_file );
00051 }

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