/* Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved. */ /*--------------------------------------------------------------------*\ Pro/Toolkit includes \*--------------------------------------------------------------------*/ #include <ProToolkit.h> #include <ProGraphic.h> #include <ProLayer.h> #include <ProObjects.h> #include <ProSelection.h> #include <ProMenu.h> #include <TestError.h> /*==========================================================================*\ FUNCTION : UserLayerItemAction() PURPOSE : Closes menu, reports selected menu action. \*==========================================================================*/ int UserLayerItemAction (ProAppData dummy, int action) { ProMenuDeleteWithStatus(action); } /*==========================================================================*\ FUNCTION : UserLayerItemTypeChoose() PURPOSE : Prompts the user to select an element type for adding to layer. \*==========================================================================*/ int UserLayerItemTypeChoose() { int menu_id; int action; ProError err; err=ProMenuFileRegister("ublank6","ublank6.mnu",&menu_id); ERROR_CHECK("UserLayerItemTypeChoose","ProMenuFileRegister",err); err=ProMenubuttonActionSet("ublank6","Part", UserLayerItemAction,NULL,PRO_PART); ERROR_CHECK("UserLayerItemTypeChoose","ProMenubuttonActionSet(Part)",err); err=ProMenubuttonActionSet("ublank6","Feature", UserLayerItemAction,NULL,PRO_FEATURE); ERROR_CHECK("UserLayerItemTypeChoose","ProMenubuttonActionSet(Feature)" ,err); err=ProMenubuttonActionSet("ublank6","Curve", UserLayerItemAction,NULL,PRO_CURVE); ERROR_CHECK("UserLayerItemTypeChoose","ProMenubuttonActionSet(Curve)",err); err=ProMenubuttonActionSet("ublank6","Quilt", UserLayerItemAction,NULL,PRO_QUILT); ERROR_CHECK("UserLayerItemTypeChoose","ProMenubuttonActionSet(Quilt)",err); err=ProMenubuttonActionSet("ublank6","Point", UserLayerItemAction,NULL,PRO_POINT); ERROR_CHECK("UserLayerItemTypeChoose","ProMenubuttonActionSet(Point)",err); err=ProMenubuttonActionSet("ublank6","ublank6", UserLayerItemAction,NULL,-1); ERROR_CHECK("UserLayerItemTypeChoose","ProMenubuttonActionSet(ublank)",err); ProMenuCreate(PROMENUTYPE_MAIN,"ublank6",&menu_id); ProMenuProcess("",&action); return(action); } /*=========================================================================*\ FUNCTION : UserLayerCreate() PURPOSE : Function to create a layer and add items to it. \*==========================================================================*/ int UserLayerCreate() { #define MAX_BUFFER_LENGTH 20 ProLayer layer; ProLayerItem layer_item; ProMdl object, member; ProSelection *sel; ProModelitem model_item; int type; int nsel; int m; char *option; ProFileName msg_file ; ProCharName str1 ; ProCharLine str2 ; ProError err; /* PHILIPPE : The Layer examples have to be changed for rev 20 Until then, I make it unavailable */ return (PRO_TK_NO_ERROR); #if 0 ProStringToWstring(msg_file, "msg_ugfund.txt"); /*-------------------------------------------------------------------------*\ Get handle for the active model. \*-------------------------------------------------------------------------*/ err=ProMdlCurrentGet(&object); ERROR_CHECK("UserLayerCreate","ProMdlCurrentGet",err); if (err != PRO_TK_NO_ERROR) { ProMessageDisplay(msg_file, "USER %0s F", "Error getting current model."); return(err) ; } /*-------------------------------------------------------------------------*\ Get layer name from user. \*-------------------------------------------------------------------------*/ ProMessageDisplay(msg_file, "USER %0s F", "Enter name of new layer: ") ; ProMessageStringRead(MAX_BUFFER_LENGTH, layer.layer_name) ; /*-------------------------------------------------------------------------*\ Load model information into layer struct. \*-------------------------------------------------------------------------*/ layer.owner=object; /*-------------------------------------------------------------------------*\ Create the new layer \*-------------------------------------------------------------------------*/ err=ProLayerCreate(&layer); ERROR_CHECK("UserLayerCreate","ProLayerCreate",err); sprintf(str2, "New layer %s created.", ProWstringToString(str1, layer.layer_name) ) ; if (err == PRO_TK_NO_ERROR) { ProMessageDisplay(msg_file, "USER %0s F", str2) ; } else { ProMessageDisplay(msg_file, "USER %0s F", "Error creating new layer.") ; return(err) ; } /*--------------------------------------------------------------------------*\ Choose the type of element to be selected. \*--------------------------------------------------------------------------*/ ProMessageDisplay(msg_file, "USER %0s F", "Select type of items to add.") ; type = UserLayerItemTypeChoose(); if (type < 0) return(0); layer_item.type=type; /*-------------------------------------------------------------------------*\ Set the ProSelect() option accordingly. \*-------------------------------------------------------------------------*/ switch (type) { case PRO_PART : option = "part" ; break; case PRO_FEATURE : option = "feature" ; break; case PRO_CURVE : option = "curve" ; break; case PRO_QUILT : option = "dtmqlt" ; break; case PRO_POINT : option = "point" ; break; } while ( ProSelect(option,1,NULL,NULL,NULL,NULL,&sel,&nsel)==PRO_TK_NO_ERROR && nsel>0 ) { err=ProSelectionModelitemGet(sel[0],&model_item); ERROR_CHECK("UserLayerCreate","ProSelectionModelitemGet",err); layer_item.id = model_item.id; err=ProLayerItemAdd(&layer,&layer_item); ERROR_CHECK("UserLayerCreate","ProLayerItemAdd",err); ProWindowRepaint(-1); } return(0); #endif }