Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

draw_Filter.cpp

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission :
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009  ---------------------------------------------------------------------------
00010     <Add other copyrights here> 
00011  ---------------------------------------------------------------------------
00012 
00013     This file is part of Phission.
00014 
00015     Phission is free software; you can redistribute it and/or modify
00016     it under the terms of the GNU Lesser General Public License as published by
00017     the Free Software Foundation; either version 2 of the License, or
00018     (at your option) any later version.
00019 
00020     Phission is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU Lesser General Public License for more details.
00024 
00025     You should have received a copy of the GNU Lesser General Public License
00026     along with Phission; if not, write to the Free Software
00027     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 
00029  ---------------------------------------------------------------------------*/
00030 #ifdef HAVE_CONFIG_H
00031     #include <phissionconfig.h>
00032 #endif
00033 
00034 #include <phStandard.h>
00035 #include <ImageGfx.h>
00036 #include <draw_Filter.h>
00037 
00038 #include <phError.h>
00039 #include <phMemory.h>
00040 #include <phPrint.h>
00041 
00042 /* ---------------------------------------------------------------------- */
00043 draw_Filter::draw_Filter( phDrawing drawing ) :
00044     phFilter("draw_Filter")
00045 
00046 {
00047     phFUNCTION("draw_Filter::draw_Filter")
00048         
00049     this->m_format = phImagePackedFormatMask;
00050    
00051     this->m_drawing = NULL;
00052     phDrawing_alloc(&this->m_drawing);
00053     
00054     if (drawing != NULL)
00055         this->set(drawing);
00056 }
00057 
00058 /* ---------------------------------------------------------------------- */
00059 draw_Filter::~draw_Filter()
00060 {
00061     phDrawing_free(&this->m_drawing);
00062 }
00063 
00064 /* ------------------------------------------------------------------------ */
00065 phFilter *draw_Filter::cloneFilter()
00066 {
00067     phFUNCTION("draw_Filter::cloneFilter")
00068     int locked = 0;
00069     draw_Filter *draw = new draw_Filter();
00070     
00071     phTHIS_LOOSE_LOCK(locked);
00072     
00073     draw->set(this->m_drawing);
00074 
00075     phTHIS_LOOSE_UNLOCK(locked);
00076 
00077     return (phFilter *)draw;
00078 }
00079 
00080 /* ---------------------------------------------------------------------- */
00081 int draw_Filter::set(phDrawing drawing)
00082 {
00083     phFUNCTION("draw_Filter::set")
00084     int locked = 0;
00085 
00086     /* LOOSE locking means that if it fails it won't adjust 'locked' and
00087      * it will continue with the main body of this method */
00088     phTHIS_LOOSE_LOCK(locked);
00089     
00090     rc = phDrawing_copy(drawing,this->m_drawing);
00091     phPRINT_RC(rc,NULL,"phDrawing_copy");
00092 
00093     phTHIS_LOOSE_UNLOCK(locked);
00094     
00095     return phSUCCESS;
00096 }
00097 
00098 /* ---------------------------------------------------------------------- */
00099 void draw_Filter::add( phPoint point, phColor color,
00100                        uint8_t  size,  uint8_t transparency )
00101 {
00102     phFUNCTION("draw_Filter::add(phPoint)")
00103     int locked = 0;
00104 
00105     phTHIS_LOOSE_LOCK(locked);
00106     
00107     rc = phDrawing_addPoint(this->m_drawing,point,color,
00108                              size, transparency );
00109     phPRINT_RC(rc,NULL,"phDrawing_addPoint");
00110 
00111     phTHIS_LOOSE_UNLOCK(locked);
00112     
00113     return;
00114 }
00115 
00116 /* ---------------------------------------------------------------------- */
00117 void draw_Filter::add( phLine line, phColor color,
00118                        uint8_t size,uint8_t transparency )
00119 {
00120     phFUNCTION("draw_Filter::add(phLine)")
00121     int locked = 0;
00122 
00123     phTHIS_LOOSE_LOCK(locked);
00124     
00125     rc = phDrawing_addLine(this->m_drawing,line,color,
00126                             size, transparency );
00127     phPRINT_RC(rc,NULL,"phDrawing_addLine");
00128 
00129     phTHIS_LOOSE_UNLOCK(locked);
00130     
00131     return;
00132 }
00133 
00134 /* ---------------------------------------------------------------------- */
00135 void draw_Filter::add( phCircle circle, phColor color,
00136                        uint8_t size, uint8_t fill,  uint8_t transparency )
00137 {
00138     phFUNCTION("draw_Filter::add(phCircle)")
00139     int locked = 0;
00140 
00141     phTHIS_LOOSE_LOCK(locked);
00142     
00143     rc = phDrawing_addCircle(this->m_drawing,circle,color,
00144                               size, fill, transparency );
00145     phPRINT_RC(rc,NULL,"phDrawing_addCircle");
00146 
00147     phTHIS_LOOSE_UNLOCK(locked);
00148     
00149     return;
00150 }
00151 
00152 /* ---------------------------------------------------------------------- */
00153 void draw_Filter::add( phRectangle rectangle, phColor color,
00154                        uint8_t size, uint8_t fill,  uint8_t transparency )
00155 {
00156     phFUNCTION("draw_Filter::add(phRectangle)")
00157     int locked = 0;
00158 
00159     phTHIS_LOOSE_LOCK(locked);
00160     
00161     rc = phDrawing_addRectangle(this->m_drawing,rectangle,color,
00162                                  size, fill, transparency );
00163     phPRINT_RC(rc,NULL,"phDrawing_addRectangle");
00164 
00165     phTHIS_LOOSE_UNLOCK(locked);
00166     
00167     return;
00168 }
00169 
00170 /* ---------------------------------------------------------------------- */
00171 void draw_Filter::add( phTriangle triangle, phColor color,
00172                        uint8_t size, uint8_t fill,  uint8_t transparency )
00173 {
00174     phFUNCTION("draw_Filter::add(phTriangle)")
00175     int locked = 0;
00176 
00177     phTHIS_LOOSE_LOCK(locked);
00178     
00179     rc = phDrawing_addTriangle(this->m_drawing,triangle,color,
00180                                 size, fill, transparency );
00181     phPRINT_RC(rc,NULL,"phDrawing_addTriangle");
00182 
00183     phTHIS_LOOSE_UNLOCK(locked);
00184     
00185     return;
00186 }
00187 
00188 /* ---------------------------------------------------------------------- */
00189 void draw_Filter::add( phCross cross, phColor color,
00190                        uint8_t size,  uint8_t transparency )
00191 {
00192     phFUNCTION("draw_Filter::add(phCross)")
00193     int locked = 0;
00194 
00195     phTHIS_LOOSE_LOCK(locked);
00196     
00197     rc = phDrawing_addCross(this->m_drawing,cross,color,
00198                              size, transparency );
00199     phPRINT_RC(rc,NULL,"phDrawing_addCross");
00200 
00201     phTHIS_LOOSE_UNLOCK(locked);
00202     
00203     return;
00204 }
00205 
00206 /* ---------------------------------------------------------------------- */
00207 int draw_Filter::filter()
00208 {
00209     phFUNCTION("draw_Filter::filter")
00210    
00211     /* defined before being called:
00212      *  width
00213      *  height
00214      *  depth
00215      *  Image
00216      */
00217     
00218     /* Begin Filter */
00219     phImageSurface surface = phImageSurface_new( width, height, format, Image );
00220 
00221     phDrawing_draw( this->m_drawing, &surface );
00222     
00223     /* End Filter */
00224     
00225     /* make sure to free up any space here, not including Image */
00226     
00227     return phSUCCESS;
00228     
00229 #if 0
00230 /* Comment this back in if you use any macros that jump to here, ie phCHECK_RC,
00231  * or phCHECK_PTR */
00232 
00233 error:
00234     /* make sure to free up any space here, not including Image */
00235     
00236     return phFAIL;
00237     
00238 #endif
00239 }
00240 
00241 




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:09 2007 for phission by  doxygen 1.4.4