Equipment & Systems |
Schematics Platform Modeler |
Creating Schematic Application ComponentsWorking with Schematic Components |
Use Case |
AbstractThis article discusses the CAASchAppSample2 use case. |
This use case is intended to help you understand how to use the CAA Schematic Platform Interfaces to manipulate Graphical Representations (GRRS) of Schematic components.
[Top]
CAASchAppSample2 is a use case of the CAASchPlatformModeler.edu framework that illustrates CAASchPlatformModeler framework capabilities. The use case demonstrates the creation of a component for a sample Schematics application, CAASCHEDU_SamplePID.
[Top]
The sample demonstrates the use of multiple Graphical Representations (GRRs) of a component and the ability to swap these representations among the instances of the component.
[Top]
To launch CAASchAppSample2, you will need to set up the build time environment, then compile CAASchAppSample2 along with its prerequisites, set up the run time environment, and then execute the sample. This is fully described in the referenced article [1]. When launching the use case, you must pass the following arguments:
[Top]
CAASchAppSample2 code is located in the CAASchAppSample2.m use case module of the CAASchPlatformModeler.edu framework:
Windows | InstallRootDirectory\CAASchPlatformModeler.edu\CAASchAppSample2.m |
Unix | InstallRootDirectory/CAASchPlatformModeler.edu/CAASchAppSample2.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of a two unique source files named
CAASchAppSample2Main.cpp and CAASchAppSample2.cpp.
Additional prerequisite code is located in the CAASchAppUtilities.m and CAASchAppBase.m modules of the same framework.
[Top]
These are the logical steps in CAASchAppSample2:
[Top]
In this use case, we open an input drawing containing one main sheet and one detail sheet. The main sheet contains one component instantiated from a reference object. The detail sheet contains three views. The use case will create a new .CATProduct drawing for the sample application.
[Top]
The CAASchAppSample2 code is derived from the CAASchAppBaseEnv base class. The base class contains functionality common to the other CAASchApp samples. Initializing the environment involves the following methods:
CAASchAppSample2::InitEnvironment CAASchAppSample2::GetAppReference CreateCATProductEnv::CreateCATProductEnv |
These methods perform the following functions:
[Top]
In order to add to the list of GRRs for the component reference, we first obtain the current list of GRRs. We don’t want to add a duplicate GRR to our component reference. To obtain the list of GRRs, the code uses the CATISchCompGraphic interface method ListGraphicalRepresentations. From this method we obtain a list of GRR, each of which we can query for the CATIView interface pointer.
Since the drawing was created by CAASchAppSample1, we know there is only one GRR in the list.
//------------------------------------------------------------------------- // Using the reference object, find CATISchCompGraphic interface. //------------------------------------------------------------------------- HRESULT rc = _spAppRef->QueryInterface (IID_CATISchCompGraphic,(void **) &piCompGraphic); if (!SUCCEEDED(rc)) { cout << "cannot get CATISchCompGraphic interface " << endl; return 0; } //------------------------------------------------------------------------- // Use the CATISchCompGraphic's method, ListGraphicalRepresentations, to // find the current graphical representations for the object. // // Since this object was created in sample1, we know it will only have // one GRR. Use this to find the detail sheet and view of the GRR. //------------------------------------------------------------------------- int NbGRR = 0; if (SUCCEEDED (piCompGraphic->ListGraphicalRepresentations (&pLIGRRs))) { unsigned int uSize = 0; if (SUCCEEDED (pLIGRRs->Count(&uSize))) { cout << "Size of GRR List = " << uSize << endl; NbGRR = uSize; if (uSize) { IUnknown *piUK = NULL; if (SUCCEEDED (pLIGRRs->Item(0,&piUK))) { if ( SUCCEEDED (piUK->QueryInterface (IID_CATIView,(void **) &piViewGRR1))) { spDtlSheet = piViewGRR1->GetSheet(); if (!!spDtlSheet) { cout << "Got detail sheet containing the GRR detail " << endl; } } rc = piUK->QueryInterface (IID_CATISchGRRComp,(void **) &piGRRComp1); CAASchAppDeleteBaseUnknown (piUK); } } } } |
[Top]
To add a GRR to a component reference we use the the CATISchCompGraphic
interface method AddGraphicalRepresentation
. This method has one
argument which is of type CATISchGRRComp*. The code loops through all the view
in the detail sheet. When it finds a view, it checks to see if it matches the
view of the original GRR. If not, it adds the GRR to the component. Since the CATISchGRRComp
interface is tied to the view object, we can obtain the CATISchGRRComp* for each
view.
for (int iView = 3; iView <= SizeOfLView; iView++) { if (LView[iView] != spSpecView) { if (SUCCEEDED ( (LView[iView])->QueryInterface (IID_CATISchGRRComp,(void **) &piGRRComp))) { if (SUCCEEDED (piCompGraphic->AddGraphicalRepresentation (piGRRComp))) { cout << "successfully added GRR at position " << iView << endl; NbGRR ++; if ( NbGRR == 2 ) piGRRComp2 = piGRRComp; if ( NbGRR == 3 ) piGRRComp3 = piGRRComp; } } } } |
[Top]
Placing an instance of the component reference is done using the PlaceInSpace method of the CATISchComponent interface. The coding is similar to that of CAASchAppSample1.
if ( SUCCEEDED(_spAppRef->QueryInterface (IID_CATISchComponent,(void **) &piComponent)) ) { double aDb6Axis[6] = {1.0,0.0, 0.0,1.0, 50.0,200.0}; rc = piComponent->PlaceInSpace (NULL, aDb6Axis, &piSchComp); if (SUCCEEDED (rc)) { CATISpecObject *piSchCompInst = NULL; if (SUCCEEDED (piSchComp->QueryInterface (IID_CATISpecObject,(void **) &piSchCompInst))) { piSchCompInst->SetName (SCHEDUPart_TestInst2); // Name the instance CAASchAppDeleteBaseUnknown (piSchCompInst); } |
[Top]
A component may have more than one occurrence shown on the drawing. This is
not the same as instantiating the component reference another time. Rather, it
is useful for allowing the representation of a component to be shown in
different locations on a drawing with the same or a different GRR. Our component
reference object now has three GRRs. The code below shows the activating of
another occurrence of our component at a new location and using the second GRR.
This is done using the CATISchCompGraphic interface Activate
method from our placed component.
double Db2Loc[2] = {220.0,200.0}; char *pGRRName = NULL; if ( SUCCEEDED (piGRRComp2->QueryInterface(IID_CATISchGRR,(void**)&piSchGRR) ) ) { if ( SUCCEEDED (piSchGRR->GetGRRName(&pGRRName)) ) { rc = piSchComp->QueryInterface (IID_CATISchCompGraphic,(void **) &piCompGraphic); if ( SUCCEEDED(rc) ) { rc = piCompGraphic->Activate(pGRRName,Db2Loc,&piNewGRRComp); } |
[Top]
The CATISchCompGraphic interface also has methods to allow switching
of the GRRs for a given occurrence or all occurrences of an object. The sample
shows using the SwitchAll
method to change all the occurrences of
our new placed component to the second GRR.
if ( SUCCEEDED(piCompGraphic->SwitchAll(pGRRName)) ) { cout << "Successfully switched all images" << endl; } else cout << "Failed to switch all images" << endl; |
[Top]
This use case has demonstrated how to get a component reference object from a drawing, manipulate it's GRRs, instantiate and activate more than one occurrence. Specifically, it has illustrated:
[Top]
[1] | Building and Launching a CAA V5 Use Case |
Version: 1 [April 2001] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.