1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
48 #include "OSGImageFileHandler.h"
50 #include "OSGFileGrabForeground.h"
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) :
66 FileGrabForeground::FileGrabForeground(const FileGrabForeground
&source
) :
71 FileGrabForeground::~FileGrabForeground(void)
75 /*----------------------------- class specific ----------------------------*/
77 void FileGrabForeground::initMethod(InitPhase ePhase
)
79 Inherited::initMethod(ePhase
);
82 void FileGrabForeground::changed(ConstFieldMaskArg whichField
,
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)
104 if(getName().empty())
106 FWARNING(("FileGrabForeground::draw: no name ?!?\n"));
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);
120 Inherited::draw(pEnv
);
122 Char8
*name
= new Char8
[getName().size() + 32]; // this is really
125 sprintf(name
, getName().c_str(), getFrame());
127 Image
*i
= getImage();
129 ImageFileHandler::the()->write(i
, name
);
133 if(getIncrement() != false)
135 setFrame(getFrame() + 1);