3D PLM PPR Hub Open Gateway |
Knowledge Modeler |
Creating a Parameter EditorHow to build a basic parameter editor |
Use Case |
AbstractThis article discusses the CAALifParamFrame use case. This use case shows how to create a parameter, associate a manipulator with it and provide an editor to modify the value of this parameter. |
This use case is intended to show you how to create a parameter manipulator and build an editor allowing you to modify interactively a parameter value by using a spinner. The spinner operates according to the manipulator specifications (range, bounds and increment/decrement value).
[Top]
CAALifParamFrame is a use case of the CAALiteralFeatures.edu framework that illustrates KnowledgeInterfaces framework capabilities.
[Top]
CAALifParamFrame explains how to associate a manipulator with a length type parameter and create an editor whereby the parameter can be modified according to an increment/decrement amount and within a value range specified in the manipulator definition. The interactive tool which is used to increment or decrement the parameter value is a spinner. This spinner is an option of the editor object which is created.
In addition, this use case illustrates how to subscribe to a parameter "ChangeValue" notification. Each time the spinner is operated, the parameter value changes (except if either bound is reached) and an information box displays the new parameter value.
This use case can be worked through in three ways:
To the end-user, the parameter is displayed as an editable data. No f(x) push-button is displayed opposite the editor value field. |
GetInPanelEdition
method of the CATICkeParamFrame interface (see [2]).
To the end-user, the value field of the editor is grayed-out, the parameter value is not editable because it is constrained by a formula which is active. You can click f(x) but be aware that this use case does not provide any formula editor behind the f(x) icon. Clicking f(x) results in a crash. |
NULL_var
handler in the first argument of the GetInPanelEdition
method
of the CATICkeParamFrame interface (see [2]).
To the end-user, the value field of the editor is grayed-out, the parameter value is not editable because it is constrained by a formula which is active. The f(x) push button is inactive. |
[Top]
To launch CAALifParamFrame, you will need to set up the build time environment, then compile CAALifGettingStarted along with its prerequisites, set up the run time environment, and then execute the use case [1].
Once you have displayed the parameter editor as it is delivered by default, you can use the down arrow of the spinner to decrement the "Length1" parameter value. Here is the information box you get:
Note that you cannot use the up arrow of the spinner to increment the parameter value as the upper bound of the manipulator has been set to 5mm. Likewise, if you keep on decrementing the parameter value, you won't be able to reach a value less than 0.5 mm.
[Top]
The CAALifParamFrame use case is made of three files : two source files named CAALifApplication.cpp and CAALifWindow.cpp, both located in the CAALifParamFrame.m module of the CAALiteralFeatures.edu framework:
Windows | InstallRootDirectory\CAALiteralFeatures.edu\CAALifParamFrame.m\ |
Unix | InstallRootDirectory/CAALiteralFeatures.edu/CAALifParamFrame.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed, and one resource file named CAALifWindow.CATNls, located in :
Windows | InstallRootDirectory\CAALiteralFeatures.edu\CNext\resources\msgcatalog\ |
Unix | InstallRootDirectory/CAALiteralFeatures.edu/CNext/resources/msgcatalog/ |
[Top]
Here are the programming steps to create a parameter editor in a dialog window:
[Top]
The interactive application is made of the class CAALifApplication that derives from CATInteractiveApplication. In addition to the constructor and destructor, this interactive application class redefines two methods of CATInteractiveApplication:
BeginApplication
, called just after the application
constructor. This method creates the different objects managed by the
application, namely here the window to contain the parameters, the formula
and the parameter editor. None of these objects can be created without a
document. The preliminary declarations required to create a document and
initialize the environment are also done by this method.EndApplication
, called when the application destruction is
requested. This method is dedicated to deallocate objects or close files.
Note that the application window declared as the application class data
member is automatically deleted. The environment initialization is performed
in the BeginApplication
method as well as the parameter editor
creation, and the EndApplication
method removes the document
created and closes the session.
... void CAALifApplication::BeginApplication() { ... CAALifWindow * pMainWindow ; pMainWindow = new CAALifWindow(this); ... pMainWindow->Build(); pMainWindow->SetVisibility(CATDlgShow); } int CAALifApplication::EndApplication() { ... CAALifClose (); ... return 0; } ... CAALifApplication ApplicationInstance("CAALifAppplicationInstance"); ... |
[Top]
All the objects manipulated in this use case are created in the CAALifWindow::Build
method. Prior to creating a knowledgeware objects you must initialize the
environment and retrieve the CATICkeParmFactory smart pointer from the
document root container. See [2] for more information
on how to initialize the environment.
... _spParam1 = spFact->CreateLength("Length1",0); ... CATICkeParm_var spParam2 = NULL_var; spParam2 = spFact->CreateLength("Length2", 2.5/1000); ... |
Let's remind you that the second argument of the CreateLength
method must be expressed according to the International System of Units
(SI), that is, in meters. The initial value of "Length2" is 2.5mm.
See [3] for more information on how to create
parameters.
... CATCkeListOf(Parm) pParamList; pParamList.Append (_spParam1); pParamList.Append (spParam2); ... CATICkeRelation_var spFormula = spFact->CreateFormula ("Formula1", "", "", _spParam1, &pParamList, "a2*2", NULL_var, CATCke::False); ... |
See [4] for information on formulas. The formula
which is created specifies that
[Top]
The manipulator which is created defines:
... CATIParmManipulator_var spParmManip = NULL_var; spParmManip = spFact->CreateParmManipulator(); ... spParmManip->SetAccurateRange (0.5,1,5,1); // Set the manipulator increment/decrement value // spParmManip->SetStep (0.5); // Associate the manipulator with "Length1" // _spParam1->SetManipulator (spParmManip); ... |
After it is created, the manipulator is associated with the "Length1" parameter. See [6] for information on manipulators.
[Top]
A parameter which is created by using any of the relations provided by the CATICkeParmFactory
factory supports the CATICkeParamFrame interface. From this interface you
can create a CATDlgFrame object by using the GetInPanelEdition
method.
... CATICkeParamFrame_var spParamFrame1 = _spParam1; CATDlgFrame *pFrame1 = NULL; pFrame1 = spParamFrame1->GetInPanelEdition(NULL_var, this, CATCkeLabel|CATCkeWithSpinner, "MySpinner"); ... |
What the displayed editor looks like depends on the values passed as the arguments.
NULL_var
is specified, you will get a push button
opposite the parameter value field, but you won't be able to activate this
button. This is what happens with this use case when the formula is
activated.CATCkeNoFormula
identifier prevents
from displaying the formula push button.[Top]
This use case shows the objects and interfaces used when creating a parameter editor. There are two important points to remember about:
GetInPanelEdition
method allows you to create a
parameter editor with a specified style.[Top]
[1] | Building and Launching CAA V5 Samples |
[2] | Getting Started with LiteralFeatures |
[3] | Using Persistent Parameters |
[4] | Creating and Manipulating Formulas |
[5] | About Units |
[6] | Using Manipulators |
[Top] |
Version: 1 [Jan 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.