WhipExamples/Viewport.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 Viewport()
00028 {
00029     WT_W2D_Class_Factory cf;
00030 
00031     //Store the current viewport.
00032     WT_Viewport *previous_viewport = cf.Create_Viewport( whip_file->desired_rendition().viewport() );
00033     if (previous_viewport == NULL)
00034         return WT_Result::Out_Of_Memory_Error;
00035     //Define a set of coordinates to use for the new viewport to use.
00036     WT_Logical_Point vP[4];
00037     vP[0] = WT_Logical_Point(-100,-100);
00038     vP[1] = WT_Logical_Point(-100,100);
00039     vP[2] = WT_Logical_Point(100,100);
00040     vP[3] = WT_Logical_Point(100,-100);
00041     WT_Contour_Set *boundary = cf.Create_Contour_Set(*whip_file, 4, vP);
00042     //Set the new viewport active.
00043     
00044     WT_Viewport* vport = cf.Create_Viewport(*whip_file, "Clip", *boundary);
00045     if (vport == NULL)
00046         return WT_Result::Out_Of_Memory_Error;
00047     whip_file->desired_rendition().viewport() = *vport;
00048     //Draw some geometry (e.g. polylines, an image, etc.) which should be clipped in the viewport.
00049     //...
00050     //Restore the previous viewport.
00051     whip_file->desired_rendition().viewport() = *previous_viewport;
00052     
00053     cf.Destroy( vport );
00054     cf.Destroy( previous_viewport );
00055 
00056     return WT_Result::Success;
00057 }

Generated on Tue Jan 6 22:40:02 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5