/*
Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
/*---------------------- Pro/Toolkit Includes ------------------------*/
#include <ProToolkit.h>
#include <ProNotify.h>
#include <ProPopupmenu.h>
#include <ProSelbuffer.h>
#include <ProMenuBar.h>
#include <ProUtil.h>
#include <ProMessage.h>
/*---------------------- Application Includes ------------------------*/
#include <TestError.h>
/*---------------------- Function Prototypes -------------------------*/
ProError UserPopupmenuNotification( const char*);
/*------------------------- External Data ----------------------------*/
int UserAsmcompConstraintsHighlight_OA();
uiCmdAccessState UserAsmcompConstraintsHighlight_TestMdlTree(uiCmdAccessMode);
uiCmdAccessState UserAsmcompConstraintsHighlight_TestPM(uiCmdCmdId,
ProAppData,
ProSelection*);
int UserFeatXMLWrite_OA();
uiCmdAccessState UserFeatXMLWrite_TestMdlTree (uiCmdAccessMode mode);
uiCmdAccessState UserFeatXMLWrite_TestPM (uiCmdCmdId id,
ProAppData data,
ProSelection* sels);
int UserPartInfoMass_OA();
uiCmdAccessState UserPartInfoMass_TestMdlTree (uiCmdAccessMode mode);
uiCmdAccessState UserPartInfoMass_TestPM (uiCmdCmdId id,
ProAppData data,
ProSelection* sels);
int UserApplyMaterial_OA();
uiCmdAccessState UserApplyMaterial_TestMdlTree (uiCmdAccessMode mode);
uiCmdAccessState UserApplyMaterial_TestPM (uiCmdCmdId id,
ProAppData data,
ProSelection* sels);
int UserSmtFlgWallCreate_OA_CreateISec();
int UserSmtFlgWallCreate_OA_CreateUserDefSec();
uiCmdAccessState UserSmtFlgWallCreate_TestMdlTree (uiCmdAccessMode mode);
uiCmdAccessState UserSmtFlgWallCreate_TestPM (uiCmdCmdId id,
ProAppData data,
ProSelection* sels);
int UserSmtFlatWallCreate_OA_CreateRectSec();
int UserSmtFlatWallCreate_OA_CreateUserDefSec();
uiCmdAccessState UserSmtFlatWallCreate_TestMdlTree (uiCmdAccessMode mode);
uiCmdAccessState UserSmtFlatWallCreate_TestPM (uiCmdCmdId id,
ProAppData data,
ProSelection* sels);
int UserSmtExtendWallCreate_OA_Thickness ();
uiCmdAccessState UserSmtExtendWallCreate_TestMdlTree (uiCmdAccessMode mode);
uiCmdAccessState UserSmtExtendWallCreate_TestPM (uiCmdCmdId id,
ProAppData data,
ProSelection* sels);
static int UserAdditionalPopupmenusSetup();
static ProError UserAdditionalPopupmenuNotification (const char* name);
#define OA_MSGFILE "pt_ug_oa.txt"
#define MDLTREE_MENU "ActionMenu"
#define CMD_UGASMCOMPCONSTRSHIGHLIGHT "UGAsmcompConstrsHighlight"
#define CMD_UGFEATXMLWRITE "UGFeatXMLWrite"
#define CMD_UGPARTINFOMASS "UGPartInfoMass"
#define CMD_UGSMTFLGCREATE_ISEC "UGSmtFlgWallCreate_ISec"
#define CMD_UGSMTFLGCREATE_USERDEFSEC "UGSmtFlgWallCreate_UserDefSec"
#define CMD_UGSMTFLATCREATE_RECTSEC "UGSmtFlatWallCreate_RectSec"
#define CMD_UGSMTFLATCREATE_USERDEFSEC "UGSmtFlatWallCreate_UserDefSec"
#define CMD_UGSMTEXTENDWALLCREATE "UGSmtExtendWallCreate"
#define CMD_UGAPPLYMATERIAL "UGApplyMaterial"
/*====================================================================*\
Function : UserPopupmenusSetup
Purpose : Setup popup menus for selected examples
\*====================================================================*/
int UserPopupmenusSetup()
{
ProError status;
uiCmdCmdId cmd_id;
ProFileName oa_msgfile;
ProStringToWstring (oa_msgfile, OA_MSGFILE);
/*--------------------------------------------------------------------*\
Create commands for Object/Action wrappers around old-style examples
that aren't setup for Object/Action
\*--------------------------------------------------------------------*/
status = ProCmdActionAdd (CMD_UGASMCOMPCONSTRSHIGHLIGHT,
(uiCmdCmdActFn)UserAsmcompConstraintsHighlight_OA,
uiProe2ndImmediate,
UserAsmcompConstraintsHighlight_TestMdlTree,
PRO_B_FALSE, PRO_B_FALSE, &cmd_id);
ERROR_CHECK ("UserPopupmenusSetup", "ProCmdActionAdd()", status);
/*--------------------------------------------------------------------*\
Add Object/Action commands to the model tree popup menu
\*--------------------------------------------------------------------*/
status = ProMenubarmenuPushbuttonAdd (MDLTREE_MENU,
"UGMdlTree.ConstrsHighlight",
"UGAsmcompConstrsHighlightLabel",
"UGAsmcompConstrsHighlightHelp",
NULL, PRO_B_TRUE, cmd_id, oa_msgfile);
ERROR_CHECK ("UserPopupmenusSetup", "ProMenubarmenuPushbuttonAdd()", status);
UserAdditionalPopupmenusSetup();
/*--------------------------------------------------------------------*\
Add the popup menu notification to the session
\*--------------------------------------------------------------------*/
status = ProNotificationSet (PRO_POPUPMENU_CREATE_POST,
(ProFunction)UserPopupmenuNotification);
ERROR_CHECK ("UserPopupmenusSetup", "ProNotificationSet()", status);
return(0);
}
/*====================================================================*\
Function : UserPopupmenuNotification
Purpose : Add buttons to popup menus when they are created.
\*====================================================================*/
ProError UserPopupmenuNotification (const char* name)
{
ProPopupMenuId menu_id;
uiCmdCmdId cmd_id;
ProError status;
ProLine label;
ProLine help;
ProFileName oa_msgfile;
ProStringToWstring (oa_msgfile, OA_MSGFILE);
/*--------------------------------------------------------------------*\
Check if the menu being created matches the menu name we want.
\*--------------------------------------------------------------------*/
if (strcmp (name, "Sel Obj Menu") == 0)
{
status = ProCmdCmdIdFind (CMD_UGASMCOMPCONSTRSHIGHLIGHT, &cmd_id);
/*--------------------------------------------------------------------*\
Extract the button label and helptext from a message file.
\*--------------------------------------------------------------------*/
status = ProMessageToBuffer (label, oa_msgfile,
"UGAsmcompConstrsHighlightLabel");
status = ProMessageToBuffer (help, oa_msgfile,
"UGAsmcompConstrsHighlightHelp");
/*--------------------------------------------------------------------*\
Add the button to the end of the popup menu.
\*--------------------------------------------------------------------*/
status = ProPopupmenuIdGet (name, &menu_id);
status = ProPopupmenuButtonAdd (menu_id, PRO_VALUE_UNUSED,
"UGPM.ConstrsHighlight",
label, help,
cmd_id,
UserAsmcompConstraintsHighlight_TestPM,
NULL);
ERROR_CHECK ("UserPopupmenuNotification",
"ProPopupmenuButtonAdd()", status);
}
UserAdditionalPopupmenuNotification(name);
return PRO_TK_NO_ERROR;
}
/*====================================================================*\
Function : UserAdditionalPopupmenusSetup
Purpose : Setup popup menus for selected examples
(Split from UserPopupmenusSetup so that the latter can be
extracted as an example to paste into the User Guide).
\*====================================================================*/
static int UserAdditionalPopupmenusSetup()
{
ProError status;
uiCmdCmdId cmd_id;
ProFileName oa_msgfile;
ProStringToWstring (oa_msgfile, OA_MSGFILE);
/*--------------------------------------------------------------------*\
Create commands for Object/Action wrappers around old-style examples
that aren't setup for Object/Action
\*--------------------------------------------------------------------*/
status = ProCmdActionAdd (CMD_UGFEATXMLWRITE,
(uiCmdCmdActFn)UserFeatXMLWrite_OA,
uiProe2ndImmediate,
UserFeatXMLWrite_TestMdlTree,
PRO_B_FALSE, PRO_B_FALSE, &cmd_id);
ERROR_CHECK ("UserPopupmenusSetup", "ProCmdActionAdd()", status);
/*--------------------------------------------------------------------*\
Add Object/Action commands to the model tree popup menu
\*--------------------------------------------------------------------*/
status = ProMenubarmenuPushbuttonAdd (MDLTREE_MENU,
"UGMdlTree.FeatXMLWrite",
"UGFeatXMLWriteLabel",
"UGFeatXMLWriteHelp",
NULL, PRO_B_TRUE, cmd_id, oa_msgfile);
ERROR_CHECK ("UserPopupmenusSetup", "ProMenubarmenuPushbuttonAdd()", status);
/*--------------------------------------------------------------------*\
Create commands for Object/Action wrappers around old-style examples
that aren't setup for Object/Action
\*--------------------------------------------------------------------*/
status = ProCmdActionAdd (CMD_UGPARTINFOMASS,
(uiCmdCmdActFn)UserPartInfoMass_OA,
uiProe2ndImmediate,
UserPartInfoMass_TestMdlTree,
PRO_B_FALSE, PRO_B_FALSE, &cmd_id);
ERROR_CHECK ("UserPopupmenusSetup", "ProCmdActionAdd()", status);
/*--------------------------------------------------------------------*\
Add Object/Action commands to the model tree popup menu
\*--------------------------------------------------------------------*/
status = ProMenubarmenuPushbuttonAdd (MDLTREE_MENU,
"UGMdlTree.PartInfoMass",
"UGPartInfoMassLabel",
"UGPartInfoMassHelp",
NULL, PRO_B_TRUE, cmd_id, oa_msgfile);
ERROR_CHECK ("UserPopupmenusSetup", "ProMenubarmenuPushbuttonAdd()", status);
/*--------------------------------------------------------------------*\
Create command for Object/Action Apply Material action
\*--------------------------------------------------------------------*/
status = ProCmdActionAdd (CMD_UGAPPLYMATERIAL,
(uiCmdCmdActFn)UserApplyMaterial_OA,
uiProe2ndImmediate,
UserApplyMaterial_TestMdlTree,
PRO_B_FALSE, PRO_B_FALSE, &cmd_id);
ERROR_CHECK ("UserPopupmenusSetup", "ProCmdActionAdd()", status);
/*--------------------------------------------------------------------*\
Add Object/Action commands to the model tree popup menu
\*--------------------------------------------------------------------*/
status = ProMenubarmenuPushbuttonAdd (MDLTREE_MENU,
"UGMdlTree.ApplyMaterial",
"UGApplyMaterialLabel",
"UGApplyMaterialHelp",
NULL, PRO_B_TRUE, cmd_id, oa_msgfile);
ERROR_CHECK ("UserPopupmenusSetup", "ProMenubarmenuPushbuttonAdd()", status);
/*--------------------------------------------------------------------*\
Create commands for sheetmetal flange wall creation.
This command requires selected
geometry and so is not added to the model tree.
\*--------------------------------------------------------------------*/
status = ProCmdActionAdd (CMD_UGSMTFLGCREATE_ISEC,
(uiCmdCmdActFn)UserSmtFlgWallCreate_OA_CreateISec,
uiProe2ndImmediate,
UserSmtFlgWallCreate_TestMdlTree,
PRO_B_FALSE, PRO_B_FALSE, &cmd_id);
ERROR_CHECK ("UserPopupmenusSetup", "ProCmdActionAdd()", status);
status = ProCmdActionAdd (CMD_UGSMTFLGCREATE_USERDEFSEC,
(uiCmdCmdActFn)UserSmtFlgWallCreate_OA_CreateUserDefSec,
uiProe2ndImmediate,
UserSmtFlgWallCreate_TestMdlTree,
PRO_B_FALSE, PRO_B_FALSE, &cmd_id);
ERROR_CHECK ("UserPopupmenusSetup", "ProCmdActionAdd()", status);
/*--------------------------------------------------------------------*\
Create commands for sheetmetal flat wall creation.
This command requires selected
geometry and so is not added to the model tree.
\*--------------------------------------------------------------------*/
status = ProCmdActionAdd (CMD_UGSMTFLATCREATE_RECTSEC,
(uiCmdCmdActFn)UserSmtFlatWallCreate_OA_CreateRectSec,
uiProe2ndImmediate,
UserSmtFlatWallCreate_TestMdlTree,
PRO_B_FALSE, PRO_B_FALSE, &cmd_id);
ERROR_CHECK ("UserPopupmenusSetup", "ProCmdActionAdd()", status);
status = ProCmdActionAdd (CMD_UGSMTFLATCREATE_USERDEFSEC,
(uiCmdCmdActFn)UserSmtFlatWallCreate_OA_CreateUserDefSec,
uiProe2ndImmediate,
UserSmtFlatWallCreate_TestMdlTree,
PRO_B_FALSE, PRO_B_FALSE, &cmd_id);
ERROR_CHECK ("UserPopupmenusSetup", "ProCmdActionAdd()", status);
/*--------------------------------------------------------------------*\
Create command for sheetmetal extend wall creation.
This command requires selected
geometry and so is not added to the model tree.
\*--------------------------------------------------------------------*/
status = ProCmdActionAdd (CMD_UGSMTEXTENDWALLCREATE,
(uiCmdCmdActFn)UserSmtExtendWallCreate_OA_Thickness,
uiProe2ndImmediate,
UserSmtExtendWallCreate_TestMdlTree,
PRO_B_FALSE, PRO_B_FALSE, &cmd_id);
ERROR_CHECK ("UserPopupmenusSetup", "ProCmdActionAdd()", status);
return (0);
}
/*====================================================================*\
Function : UserAdditionalPopupmenuNotification
Purpose : Add buttons to popup menus when they are created.
(Split from UserPopupmenuNotification so that the latter can be
extracted as an example to paste into the User Guide).
\*====================================================================*/
static ProError UserAdditionalPopupmenuNotification (const char* name)
{
ProPopupMenuId menu_id;
uiCmdCmdId cmd_id;
ProError status;
ProLine label;
ProLine help;
ProFileName oa_msgfile;
ProStringToWstring (oa_msgfile, OA_MSGFILE);
/*--------------------------------------------------------------------*\
Check if the menu being created matches the menu name we want.
\*--------------------------------------------------------------------*/
if (strcmp (name, "Sel Obj Menu") == 0)
{
status = ProCmdCmdIdFind (CMD_UGFEATXMLWRITE, &cmd_id);
/*--------------------------------------------------------------------*\
Extract the button label and helptext from a message file.
\*--------------------------------------------------------------------*/
status = ProMessageToBuffer (label, oa_msgfile,
"UGFeatXMLWriteLabel");
status = ProMessageToBuffer (help, oa_msgfile,
"UGFeatXMLWriteHelp");
/*--------------------------------------------------------------------*\
Add the button to the end of the popup menu.
\*--------------------------------------------------------------------*/
status = ProPopupmenuIdGet (name, &menu_id);
status = ProPopupmenuButtonAdd (menu_id, PRO_VALUE_UNUSED,
"UGPM.FeatXMLWrite",
label, help,
cmd_id,
UserFeatXMLWrite_TestPM,
NULL);
ERROR_CHECK ("UserPopupmenuNotification",
"ProPopupmenuButtonAdd()", status);
status = ProCmdCmdIdFind (CMD_UGPARTINFOMASS, &cmd_id);
/*--------------------------------------------------------------------*\
Extract the button label and helptext from a message file.
\*--------------------------------------------------------------------*/
status = ProMessageToBuffer (label, oa_msgfile,
"UGPartInfoMassLabel");
status = ProMessageToBuffer (help, oa_msgfile,
"UGPartInfoMassHelp");
/*--------------------------------------------------------------------*\
Add the button to the end of the popup menu.
\*--------------------------------------------------------------------*/
status = ProPopupmenuButtonAdd (menu_id, PRO_VALUE_UNUSED,
"UGPM.PartInfoMass",
label, help,
cmd_id,
UserPartInfoMass_TestPM,
NULL);
ERROR_CHECK ("UserPopupmenuNotification",
"ProPopupmenuButtonAdd()", status);
status = ProCmdCmdIdFind (CMD_UGAPPLYMATERIAL, &cmd_id);
/*--------------------------------------------------------------------*\
Extract the button label and helptext from a message file.
\*--------------------------------------------------------------------*/
status = ProMessageToBuffer (label, oa_msgfile,
"UGApplyMaterialLabel");
status = ProMessageToBuffer (help, oa_msgfile,
"UGApplyMaterialHelp");
/*--------------------------------------------------------------------*\
Add the button to the end of the popup menu.
\*--------------------------------------------------------------------*/
status = ProPopupmenuButtonAdd (menu_id, PRO_VALUE_UNUSED,
"UGPM.ApplyMaterial",
label, help,
cmd_id,
UserApplyMaterial_TestPM,
NULL);
ERROR_CHECK ("UserPopupmenuNotification",
"ProPopupmenuButtonAdd()", status);
status = ProCmdCmdIdFind (CMD_UGSMTFLGCREATE_ISEC, &cmd_id);
/*--------------------------------------------------------------------*\
Extract the button label and helptext from a message file.
\*--------------------------------------------------------------------*/
status = ProMessageToBuffer (label, oa_msgfile,
"UGSmtFlgWall_ISecLabel");
status = ProMessageToBuffer (help, oa_msgfile,
"UGSmtFlgWall_ISecHelp");
/*--------------------------------------------------------------------*\
Add the button to the end of the popup menu.
\*--------------------------------------------------------------------*/
status = ProPopupmenuButtonAdd (menu_id, PRO_VALUE_UNUSED,
"UGPM.ISecSmtFlgWall",
label, help,
cmd_id,
UserSmtFlgWallCreate_TestPM,
NULL);
ERROR_CHECK ("UserPopupmenuNotification",
"ProPopupmenuButtonAdd()", status);
status = ProCmdCmdIdFind (CMD_UGSMTFLGCREATE_USERDEFSEC, &cmd_id);
/*--------------------------------------------------------------------*\
Extract the button label and helptext from a message file.
\*--------------------------------------------------------------------*/
status = ProMessageToBuffer (label, oa_msgfile,
"UGSmtFlgWall_UserSecLabel");
status = ProMessageToBuffer (help, oa_msgfile,
"UGSmtFlgWall_UserSecHelp");
/*--------------------------------------------------------------------*\
Add the button to the end of the popup menu.
\*--------------------------------------------------------------------*/
status = ProPopupmenuButtonAdd (menu_id, PRO_VALUE_UNUSED,
"UGPM.UserSecSmtFlgWall",
label, help,
cmd_id,
UserSmtFlgWallCreate_TestPM,
NULL);
ERROR_CHECK ("UserPopupmenuNotification",
"ProPopupmenuButtonAdd()", status);
status = ProCmdCmdIdFind (CMD_UGSMTFLATCREATE_RECTSEC, &cmd_id);
/*--------------------------------------------------------------------*\
Extract the button label and helptext from a message file.
\*--------------------------------------------------------------------*/
status = ProMessageToBuffer (label, oa_msgfile,
"UGSmtFlatWall_RectSecLabel");
status = ProMessageToBuffer (help, oa_msgfile,
"UGSmtFlatWall_RectSecHelp");
/*--------------------------------------------------------------------*\
Add the button to the end of the popup menu.
\*--------------------------------------------------------------------*/
status = ProPopupmenuButtonAdd (menu_id, PRO_VALUE_UNUSED,
"UGPM.RectSecSmtFlatWall",
label, help,
cmd_id,
UserSmtFlatWallCreate_TestPM,
NULL);
ERROR_CHECK ("UserPopupmenuNotification",
"ProPopupmenuButtonAdd()", status);
status = ProCmdCmdIdFind (CMD_UGSMTFLATCREATE_USERDEFSEC, &cmd_id);
/*--------------------------------------------------------------------*\
Extract the button label and helptext from a message file.
\*--------------------------------------------------------------------*/
status = ProMessageToBuffer (label, oa_msgfile,
"UGSmtFlatWall_UserSecLabel");
status = ProMessageToBuffer (help, oa_msgfile,
"UGSmtFlatWall_UserSecHelp");
/*--------------------------------------------------------------------*\
Add the button to the end of the popup menu.
\*--------------------------------------------------------------------*/
status = ProPopupmenuButtonAdd (menu_id, PRO_VALUE_UNUSED,
"UGPM.UserSecSmtFlatWall",
label, help,
cmd_id,
UserSmtFlatWallCreate_TestPM,
NULL);
ERROR_CHECK ("UserPopupmenuNotification",
"ProPopupmenuButtonAdd()", status);
}
status = ProCmdCmdIdFind ( CMD_UGSMTEXTENDWALLCREATE, &cmd_id);
/*--------------------------------------------------------------------*\
Extract the button label and helptext from a message file.
\*--------------------------------------------------------------------*/
status = ProMessageToBuffer (label, oa_msgfile,
"UGSmtExtendWallLabel");
status = ProMessageToBuffer (help, oa_msgfile,
"UGSmtExtendWallHelp");
/*--------------------------------------------------------------------*\
Add the button to the end of the popup menu.
\*--------------------------------------------------------------------*/
status = ProPopupmenuIdGet (name, &menu_id);
status = ProPopupmenuButtonAdd (menu_id, PRO_VALUE_UNUSED,
"UGPM.UserSmtExtendWall",
label, help,
cmd_id,
UserSmtExtendWallCreate_TestPM,
NULL);
ERROR_CHECK ("UserPopupmenuNotification",
"ProPopupmenuButtonAdd()", status);
return PRO_TK_NO_ERROR;
}