tools/toolgrabview3d/ortoolgrabview3d_tool.cxx

tools/toolgrabview3d/ortoolgrabview3d_tool.cxx
/***************************************************************************************
Autodesk(R) Open Reality(R) Samples
(C) 2009 Autodesk, Inc. and/or its licensors
All rights reserved.
AUTODESK SOFTWARE LICENSE AGREEMENT
Autodesk, Inc. licenses this Software to you only upon the condition that
you accept all of the terms contained in the Software License Agreement ("Agreement")
that is embedded in or that is delivered with this Software. By selecting
the "I ACCEPT" button at the end of the Agreement or by copying, installing,
uploading, accessing or using all or any portion of the Software you agree
to enter into the Agreement. A contract is then formed between Autodesk and
either you personally, if you acquire the Software for yourself, or the company
or other legal entity for which you are acquiring the software.
AUTODESK, INC., MAKES NO WARRANTY, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE REGARDING THESE MATERIALS, AND MAKES SUCH MATERIALS AVAILABLE SOLELY ON AN
"AS-IS" BASIS.
IN NO EVENT SHALL AUTODESK, INC., BE LIABLE TO ANYONE FOR SPECIAL, COLLATERAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH OR ARISING OUT OF PURCHASE
OR USE OF THESE MATERIALS. THE SOLE AND EXCLUSIVE LIABILITY TO AUTODESK, INC.,
REGARDLESS OF THE FORM OF ACTION, SHALL NOT EXCEED THE PURCHASE PRICE OF THE
MATERIALS DESCRIBED HEREIN.
Autodesk, Inc., reserves the right to revise and improve its products as it sees fit.
Autodesk and Open Reality are registered trademarks or trademarks of Autodesk, Inc.,
in the U.S.A. and/or other countries. All other brand names, product names, or
trademarks belong to their respective holders.
GOVERNMENT USE
Use, duplication, or disclosure by the U.S. Government is subject to restrictions as
set forth in FAR 12.212 (Commercial Computer Software-Restricted Rights) and
DFAR 227.7202 (Rights in Technical Data and Computer Software), as applicable.
Manufacturer is Autodesk, Inc., 10 Duke Street, Montreal, Quebec, Canada, H3C 2L7.
***************************************************************************************/
//--- Class declaration
#include "ortoolgrabview3d_tool.h"
//--- Registration defines
#define ORTOOLGRABVIEW3D__CLASS ORTOOLGRABVIEW3D__CLASSNAME
#define ORTOOLGRABVIEW3D__LABEL "GrabView3D"
#define ORTOOLGRABVIEW3D__DESC "OR - Grab 3D Viewer Tool"
//--- Implementation and registration
FBToolImplementation( ORTOOLGRABVIEW3D__CLASS );
FBRegisterTool ( ORTOOLGRABVIEW3D__CLASS,
ORTOOLGRABVIEW3D__LABEL,
ORTOOLGRABVIEW3D__DESC,
FB_DEFAULT_SDK_ICON ); // Icon filename (default=Open Reality icon)
/************************************************
* Constructor.
************************************************/
bool ORToolGrabView3D::FBCreate()
{
StartSize[0] = 617;
StartSize[1] = 401;
// Manage UI
UICreate ();
UIConfigure ();
UIReset ();
// Add tool callbacks
OnShow.Add ( this, (FBCallback) &ORToolGrabView3D::EventToolShow );
OnIdle.Add ( this, (FBCallback) &ORToolGrabView3D::EventToolIdle );
OnResize.Add( this, (FBCallback) &ORToolGrabView3D::EventToolResize );
OnPaint.Add ( this, (FBCallback) &ORToolGrabView3D::EventToolPaint );
OnInput.Add ( this, (FBCallback) &ORToolGrabView3D::EventToolInput );
return true;
}
/************************************************
* Create, configure & reset UI.
************************************************/
void ORToolGrabView3D::UICreate()
{
// Tool options
int lS = 4;
// Configure layout
AddRegion( "LabelDirections", "LabelDirections",
lS, kFBAttachLeft, "", 1.0 ,
lS, kFBAttachTop, "", 1.0,
-lS,kFBAttachRight, "", 1.0,
42, kFBAttachNone, "", 1.0 );
AddRegion( "ButtonFilePopup", "ButtonFilePopup",
lS, kFBAttachLeft, "", 1.0 ,
lS, kFBAttachBottom, "LabelDirections", 1.0,
-lS,kFBAttachRight, "", 1.0,
18, kFBAttachNone, "", 1.0 );
AddRegion( "View3D", "View3D",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachBottom, "ButtonFilePopup", 1.0,
-lS, kFBAttachRight, "",1.0,
-lS, kFBAttachBottom, "",1.0 );
// Assign regions
SetControl ( "LabelDirections", mLabelDirections );
SetControl ( "ButtonFilePopup", mButtonFilePopup );
SetView ( "View3D", mView );
}
void ORToolGrabView3D::UIConfigure()
{
int lWidth = mView.Region.Position.X[1] - mView.Region.Position.X[0];
int lHeight = mView.Region.Position.Y[1] - mView.Region.Position.Y[0];
char lTmp[2048];
sprintf( lTmp, "This is a demonstration of the FBVideoGrabber capabilities. It renders from frame 0 to 150.\n"
"Double-click in the window to start. Note: some codec must have width aligned to 4. Render size is %dx%d",
lWidth, lHeight );
mLabelDirections.Caption = lTmp;
mFilePopup.Caption = "Where to save the rendering...";
mFilePopup.Style = kFBFilePopupSave;
mFilePopup.Filter = "*.*";
mFilePopup.Path = mView.GetFilePath();
mFilePopup.FileName = mView.GetFileName();
// We have to explicitely set the caption this way because the property 'FBFilePopup::FullFilename'
// Is not set until e 'FBFilePopup::Execute()' has been done... Unfortunate.
mButtonFilePopup.Caption = mView.GetFilePath() + FBString( "\\" ) + mView.GetFileName();
mButtonFilePopup.OnClick.Add( this, (FBCallback) &ORToolGrabView3D::EventButtonFilePopup );
}
void ORToolGrabView3D::UIReset()
{
}
/************************************************
* Destruction function.
************************************************/
void ORToolGrabView3D::FBDestroy()
{
// Remove tool callbacks
OnShow.Remove ( this, (FBCallback) &ORToolGrabView3D::EventToolShow );
OnIdle.Remove ( this, (FBCallback) &ORToolGrabView3D::EventToolIdle );
OnPaint.Remove ( this, (FBCallback) &ORToolGrabView3D::EventToolPaint );
OnInput.Remove ( this, (FBCallback) &ORToolGrabView3D::EventToolInput );
OnResize.Remove ( this, (FBCallback) &ORToolGrabView3D::EventToolResize );
// Free user allocated memory
}
void ORToolGrabView3D::EventButtonFilePopup( HISender pSender, HKEvent pEvent )
{
//
// Show the folder popup to select the folder
//
mFilePopup.Execute();
//
// Set the path in the edit box
//
mButtonFilePopup.Caption = (const char*)mFilePopup.FullFilename;
mView.SetFilePath( mFilePopup.Path );
mView.SetFileName( mFilePopup.FileName );
}
/************************************************
* UI Idle callback.
************************************************/
void ORToolGrabView3D::EventToolIdle( HISender pSender, HKEvent pEvent )
{
RefreshView();
}
void ORToolGrabView3D::RefreshView()
{
mView.Refresh(true);
}
/************************************************
* Handle tool activation (selection/unselection).
************************************************/
void ORToolGrabView3D::EventToolShow( HISender pSender, HKEvent pEvent )
{
FBEventShow lEvent( pEvent );
if( lEvent.Shown )
{
}
}
/************************************************
* Paint callback for tool (on expose).
************************************************/
void ORToolGrabView3D::EventToolPaint( HISender pSender, HKEvent pEvent )
{
}
/************************************************
* Tool resize callback.
************************************************/
void ORToolGrabView3D::EventToolResize( HISender pSender, HKEvent pEvent )
{
int Width = mView.Region.Position.X[1] - mView.Region.Position.X[0];
int Height = mView.Region.Position.Y[1] - mView.Region.Position.Y[0];
char Tmp[2048];
sprintf(Tmp, "This is a demonstration of the FBVideoGrabber capabilities. It renders from frame 0 to 150.\nRender size is %dx%d. Double-click in the window to start.\nNote: some codecs have width and height requirements/limitations.", Width, Height);
mLabelDirections.Caption = Tmp;
}
/************************************************
* Handle input into the tool.
************************************************/
void ORToolGrabView3D::EventToolInput( HISender pSender, HKEvent pEvent )
{
}
/************************************************
* FBX Storage.
************************************************/
bool ORToolGrabView3D::FbxStore ( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat )
{
pFbxObject->FieldWriteBegin( "ORToolGrabView3DSection" );
{
}
pFbxObject->FieldWriteEnd();
return true;
}
/************************************************
* FBX Retrieval.
************************************************/
bool ORToolGrabView3D::FbxRetrieve( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat )
{
pFbxObject->FieldReadBegin( "ORToolGrabView3DSection" );
{
}
pFbxObject->FieldReadEnd();
return true;
}