fixed: compile issue
[opensg.git] / Source / System / Window / Foreground / OSGFileGrabForeground.cpp
blob78774b3546a7207ecbd3253ec124c3f618f25cf9
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
47 #include "OSGImage.h"
48 #include "OSGImageFileHandler.h"
50 #include "OSGFileGrabForeground.h"
52 OSG_USING_NAMESPACE
54 // Documentation for this class is emited in the
55 // OSGFileGrabForegroundBase.cpp file.
56 // To modify it, please change the .fcd file (OSGFileGrabForeground.fcd) and
57 // regenerate the base file.
59 /*----------------------- constructors & destructors ----------------------*/
61 FileGrabForeground::FileGrabForeground(void) :
62 Inherited()
66 FileGrabForeground::FileGrabForeground(const FileGrabForeground &source) :
67 Inherited(source)
71 FileGrabForeground::~FileGrabForeground(void)
75 /*----------------------------- class specific ----------------------------*/
77 void FileGrabForeground::initMethod(InitPhase ePhase)
79 Inherited::initMethod(ePhase);
82 void FileGrabForeground::changed(ConstFieldMaskArg whichField,
83 UInt32 origin,
84 BitVector details)
86 Inherited::changed(whichField, origin, details);
89 void FileGrabForeground::dump( UInt32 ,
90 const BitVector ) const
92 SLOG << "Dump FileGrabForeground NI" << std::endl;
96 /*! Grab the image and write it to the file. The name needs to be set.
99 void FileGrabForeground::draw(DrawEnv *pEnv)
101 if(getActive() == false)
102 return;
104 if(getName().empty())
106 FWARNING(("FileGrabForeground::draw: no name ?!?\n"));
107 return;
110 // do we have an image yet? If not, create one.
111 if(getImage() == NULL)
113 ImageUnrecPtr iPtr = Image::create();
115 iPtr->set(Image::OSG_RGB_PF, 1);
117 setImage(iPtr);
120 Inherited::draw(pEnv);
122 Char8 *name = new Char8[getName().size() + 32]; // this is really
123 // arbitrary... :(
125 sprintf(name, getName().c_str(), getFrame());
127 Image *i = getImage();
129 ImageFileHandler::the()->write(i, name);
131 delete [] name;
133 if(getIncrement() != false)
135 setFrame(getFrame() + 1);