constraints/constraintdeformer/orconstraintdeformer_layout.cxx

constraints/constraintdeformer/orconstraintdeformer_layout.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 "orconstraintdeformer_layout.h"
//--- Registration defines
#define ORCONSTRAINTDEFORMER__LAYOUT ORConstraintDeformerLayout
//--- implementation and registration
FBConstraintLayoutImplementation( ORCONSTRAINTDEFORMER__LAYOUT );
FBRegisterConstraintLayout ( ORCONSTRAINTDEFORMER__LAYOUT,
ORCONSTRAINTDEFORMER__CLASSSTR,
FB_DEFAULT_SDK_ICON ); // Icon filename (default=Open Reality icon)
/************************************************
* Creation function..
************************************************/
bool ORConstraintDeformerLayout::FBCreate()
{
// Assign handle onto constraint (cast generic pointer).
mConstraint = (ORConstraintDeformer*) (FBConstraint*) Constraint;
// build & configure layout
UICreate ();
UIConfigure ();
return true;
}
/************************************************
* Destructor for layout.
************************************************/
void ORConstraintDeformerLayout::FBDestroy()
{
}
/************************************************
* UI Creation function.
* Create UI regions and assign them to UI elements
************************************************/
void ORConstraintDeformerLayout::UICreate()
{
int lS, lH; // space, width, height
lS = 4;
lH = 18;
// Create regions
AddRegion ("LabelDirections", "LabelDirections",
lS, kFBAttachTop, "", 1.0,
lS, kFBAttachLeft, "", 1.0,
-lS, kFBAttachRight, "", 1.0,
150, kFBAttachNone, NULL, 1.0 );
AddRegion ("LabelMultiplier", "LabelMultiplier",
lS, kFBAttachLeft, "", 1.00,
lS, kFBAttachBottom,"LabelDirections", 1.00,
125, kFBAttachNone, NULL, 1.00,
lH, kFBAttachNone, NULL, 1.00 );
AddRegion ("EditNumberMultiplier","EditNumberMultiplier",
lS, kFBAttachRight, "LabelMultiplier", 1.00,
0, kFBAttachTop, "LabelMultiplier", 1.00,
100, kFBAttachNone, NULL, 1.00,
0, kFBAttachHeight,"LabelMultiplier", 1.00 );
// Assign regions
SetControl( "LabelDirections", mLabelDirections );
SetControl( "LabelMultiplier", mLabelMultiplier );
SetControl( "EditNumberMultiplier", mEditNumberMultiplier );
}
/************************************************
* UI Configuration function.
* Assign properties & callbacks for UI elements
************************************************/
void ORConstraintDeformerLayout::UIConfigure()
{
mLabelDirections.Caption = "1. Create two models (markers are not models!).\n"
"2. Drag one to be the source, and one to be the destination\n"
"for the constraint.\n"
"3. Activate the constraint.\n"
"4. By dragging the source model around, you will some of the vertices\n"
"move according to the relation in the DeformerNotify() callback.\n"
"\n"
"N.B. The layout is under the \"Custom Setup\" panel because some reference\n"
"groups have been created for the constraint in the FBCreate() function.";
mLabelMultiplier.Caption = "Displacement Multiplier";
mEditNumberMultiplier.Value = mConstraint->GetMultiplier();
mEditNumberMultiplier.Precision = 3.3;
mEditNumberMultiplier.SmallStep = 0.001;
mEditNumberMultiplier.LargeStep = 0.010;
mEditNumberMultiplier.Min = 0.00;
mEditNumberMultiplier.Max = 10.00;
mEditNumberMultiplier.OnChange.Add( this, (FBCallback) &ORConstraintDeformerLayout::EventEditNumberChange );
}
/************************************************
* Edit multiplier callback.
************************************************/
void ORConstraintDeformerLayout::EventEditNumberChange( HISender pSender, HKEvent pEvent)
{
// Send the value to the constraint
mConstraint->SetMultiplier( mEditNumberMultiplier.Value );
// Update the UI with the accepted (actually used) value.
mEditNumberMultiplier.Value = mConstraint->GetMultiplier();
}