/*
Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
/*--------------------------------------------------------------------*\
Pro/TOOLKIT includes
\*--------------------------------------------------------------------*/
#include <ProToolkit.h>
#include <ProArray.h>
#include <ProMdl.h>
#include <ProDrawing.h>
#include <ProMenu.h>
#include <ProUtil.h>
#include <ProDtlnote.h>
#include <ProNote.h>
/*--------------------------------------------------------------------*\
Application includes
\*--------------------------------------------------------------------*/
#include "UtilMessage.h"
#include "UtilMenu.h"
#include "UtilFiles.h"
#include <ProTKRunTime.h>
#include <ProMessage.h>
#define NOTE_ATTR_MIRROR 0
#define NOTE_ATTR_JUSTIF 1
#define NOTE_ATTR_READONLY 2
#define NOTE_FONT 0
#define NOTE_ULINE 1
#define NOTE_THICKNESS 2
#define NOTE_SLANT 3
#define NOTE_WIDTH 4
#define NOTE_HEIGHT 5
#define NOTE_STRING 6
#define NOTE_MOD_TEXT 0
#define NOTE_MOD_ATTR 1
#define NOTE_MOD_COLOR 2
#define NOTE_MOD_LOCATION 3
#define NOTE_MOD_ATTACH 4
#define NOTE_MOD_ANGLE 5
#define NOTE_MOD_ELB 6
#define NOTE_MOD_READONLY 7
#define NOTE_REMOVE 0
#define NOTE_ERASE 1
#define NOTE_DELETE 2
#define DTL_NOTE_FILE ".inf"
/*---------------------------------------------------------------------*\
Functions declaration
\*---------------------------------------------------------------------*/
int ProTestDtlNoteCreateMenu (void*, int);
int ProTestDtlNoteCreate (void*);
int ProTestDtlNoteModify (void*);
int ProTestDtlNoteInfo (void*);
int ProTestDtlNoteDisplay (void*);
int ProTestLocationGet (ProDrawing, ProView, ProDtlattachType, ProDtlattach*);
int ProTestNoteTextGet (ProDtlnoteline**);
int ProTestAssignAttr (ProAppData , int );
ProError ProTestLeadersGet (ProDtlattach** );
ProError ProTestAttachTypeGet (ProDtlattachType*);
/*---------------------------------------------------------------------*\
Function: ProTestDtlNoteMenu()
Purpose: On-button function. Set up the dtl note menu
Returns: 0 - success; -1 - error.
\*---------------------------------------------------------------------*/
int ProTestDtlNoteMenu (void** app_data)
{
ProError status;
int menu_id; /* The identifier of the created menu */
int action;
ProDrawing drawing = (ProDrawing)*app_data;
/*--------------------------------------------------------------------*\
Enables the Pro/ENGINEER user to select drawing
detail notes flagged as read-only.
\*--------------------------------------------------------------------*/
status = ProDrawingReadonlyselectionAllow (PRO_B_TRUE);
TEST_CALL_REPORT( "ProDrawingReadonlyselectionAllow()",
"ProTestDtlNoteMenu()", status, status != PRO_TK_NO_ERROR );
/*---------------------------------*\
Create new menu Note
\*---------------------------------*/
/* Load base menu from file */
status = ProMenuFileRegister( (char*)"Note", (char*)"tkdtlnote.mnu", &menu_id );
TEST_CALL_REPORT( "ProMenuFileRegister()", "ProTestDtlNoteMenu()",
status, status != PRO_TK_NO_ERROR );
/* Define menu buttons */
ProMenubuttonActionSet( (char*)"Note", (char*)"Create",
(ProMenubuttonAction)ProTestDtlNoteCreate, drawing, 0);
ProMenubuttonActionSet( (char*)"Note", (char*)"Modify",
(ProMenubuttonAction)ProTestDtlNoteModify, drawing, 0);
ProMenubuttonActionSet( (char*)"Note", (char*)"Info",
(ProMenubuttonAction)ProTestDtlNoteInfo, drawing, 0);
ProMenubuttonActionSet( (char*)"Note", (char*)"Display",
(ProMenubuttonAction)ProTestDtlNoteDisplay, drawing, 0);
ProMenubuttonActionSet( (char*)"Note", (char*)"Note",
(ProMenubuttonAction)ProMenuDelete, NULL, 0 );
/*--------------------------*\
Run menu Disp List
\*--------------------------*/
status = ProMenuCreate( PROMENUTYPE_MAIN, (char*)"Note", &menu_id );
TEST_CALL_REPORT( "ProMenuCreate()", "ProTestDtlNoteMenu()",
status, status != PRO_TK_NO_ERROR );
if( status == PRO_TK_NO_ERROR )
{
status = ProMenuProcess( (char*)"", &action );
TEST_CALL_REPORT( "ProMenuProcess()", "ProTestDtlNoteMenu()",
status, status != PRO_TK_NO_ERROR && status != PRO_TK_E_FOUND);
}
return 0;
}
/*---------------------------------------------------------------------*\
Function: ProTestAttachTypeGet()
Purpose: Get attachment type
\*---------------------------------------------------------------------*/
ProError ProTestAttachTypeGet (ProDtlattachType *at_type)
{
ProError err;
static ProUtilMenuButtons attach_type[] = {
{"NoteAttach", 0, TEST_CALL_PRO_MENU_DELETE},
{"Free", PRO_DTLATTACHTYPE_FREE, 0},
{"Parametric", PRO_DTLATTACHTYPE_PARAMETRIC, 0},
{"",0,0}
};
err = ProUtilMenuIntValueSelect(attach_type, (int*)at_type);
return (err);
}
/*---------------------------------------------------------------------*\
Function: ProTestDtlNoteCreate()
Purpose: On-button function. Create a note.
Returns: 0 - success; -1 - error.
\*---------------------------------------------------------------------*/
int ProTestDtlNoteCreate (void* app_data)
{
ProDrawing drawing = (ProDrawing)app_data;
ProDtlnote note;
ProDtlnoteline *note_lines;
ProDtlnotedata note_data;
ProError err;
ProDtlattach location, *leaders = NULL;
ProView view;
ProDtlattachType at_type;
int status = 0, i, sheet, n_leaders;
err = ProTestAttachTypeGet (&at_type);
/*--------------------------------------------------------------------------*\
Get view
\*--------------------------------------------------------------------------*/
err = ProDrawingCurrentSheetGet (drawing, &sheet);
TEST_CALL_REPORT ("ProDrawingCurrentSheetGet()",
"ProTestDtlNoteCreate()", err, err != PRO_TK_NO_ERROR);
err = ProDrawingBackgroundViewGet (drawing, sheet, &view);
TEST_CALL_REPORT ("ProDrawingBackgroundViewGet()",
"ProTestDtlNoteCreate()", err, err != PRO_TK_NO_ERROR);
/*--------------------------------------------------------------------------*\
Allocate memory for note data
\*--------------------------------------------------------------------------*/
err = ProDtlnotedataAlloc (drawing, ¬e_data);
TEST_CALL_REPORT ("ProDtlnotedataAlloc()", "ProTestDtlNoteCreate()",
err, err != PRO_TK_NO_ERROR);
/*--------------------------------------------------------------------------*\
Get LOCATION for note and set it to note data
\*--------------------------------------------------------------------------*/
status = ProTestLocationGet (drawing, view, at_type, &location);
if (status != 0)
return -1;
err = ProDtlnotedataAttachmentSet (note_data, location);
TEST_CALL_REPORT ("ProDtlnotedataAttachmentSet()",
"ProTestDtlNoteCreate()",
err, err != PRO_TK_NO_ERROR);
err = ProDtlattachFree (location);
TEST_CALL_REPORT ("ProDtlattachFree()", "ProTestDtlNoteCreate()",
err, err != PRO_TK_NO_ERROR);
/*--------------------------------------------------------------------------*\
Get NOTE TEXT and set it to note data
\*--------------------------------------------------------------------------*/
status = ProTestNoteTextGet (¬e_lines);
if (status != 0)
return -1;
err = ProDtlnoteldataLinesSet (note_data, note_lines);
TEST_CALL_REPORT ("ProDtlnoteldataLinesSet()", "ProTestDtlNoteCreate()",
err, err != PRO_TK_NO_ERROR);
err = ProArrayFree ((ProArray*)¬e_lines);
TEST_CALL_REPORT ("ProArrayFree()", "ProTestDtlNoteCreate()",
err, err != PRO_TK_NO_ERROR);
/*--------------------------------------------------------------------------*\
Get LEADERS if attachment type is PRO_DTLATTACHTYPE_FREE,
and set them to note data
\*--------------------------------------------------------------------------*/
if (at_type == PRO_DTLATTACHTYPE_FREE)
{
err = ProTestLeadersGet (&leaders);
if (leaders != NULL && err == PRO_TK_NO_ERROR)
{
err = ProDtlnotedataLeadersSet (note_data, leaders);
TEST_CALL_REPORT("ProDtlnotedataLeadersSet()",
"ProTestDtlNoteCreate()", err, err != PRO_TK_NO_ERROR);
err = ProArraySizeGet ((ProArray)leaders, &n_leaders);
for (i = 0; i < n_leaders; i++)
err = ProDtlattachFree (leaders[i]);
err = ProArrayFree ((ProArray*)&leaders);
}
}
/*--------------------------------------------------------------------------*\
Create NOTE
\*--------------------------------------------------------------------------*/
err = ProDtlnoteCreate (drawing, NULL, note_data, ¬e);
TEST_CALL_REPORT ("ProDtlnoteCreate()", "ProTestDtlNoteCreate()",
err, err != PRO_TK_NO_ERROR);
err = ProDtlnoteShow (¬e);
TEST_CALL_REPORT ("ProDtlnoteShow()", "ProTestDtlNoteCreate()",
err, err != PRO_TK_NO_ERROR);
/*--------------------------------------------------------------------------*\
Release memory (function ProDtlnotedataFree free all leaders, lines and
texts in note data)
\*--------------------------------------------------------------------------*/
err = ProDtlnotedataFree (note_data);
TEST_CALL_REPORT ("ProDtlnotedataFree()", "ProTestDtlNoteCreate()",
err, err != PRO_TK_NO_ERROR);
return 0;
}
/*---------------------------------------------------------------------*\
Function: ProTestNoteTextGet ()
Purpose: Creates text lines for note
Returns: 0 - success; -1 - error.
\*---------------------------------------------------------------------*/
int ProTestNoteTextGet (ProDtlnoteline **p_lines)
{
ProDtlnoteline *lines, note_line;
int status, line_count = 0, n_texts, i;
ProDtlnotetext *texts, note_text;
ProError err;
ProLine text;
/*--------------------------------------------------------------------------*\
Allocat ememory for lines
\*--------------------------------------------------------------------------*/
err = ProArrayAlloc (0, sizeof (ProDtlnoteline), 1, (ProArray*)&lines);
TEST_CALL_REPORT ("ProArrayAlloc()", "ProTestNoteTextGet()",
err, err != PRO_TK_NO_ERROR);
/*--------------------------------------------------------------------------*\
Do while user doesn't cancel input
\*--------------------------------------------------------------------------*/
do
{
ProUtilMsgPrint ("gen", "TEST %0s", "Enter NOTE:" );
status = ProUtilStringGet (text, NULL, PRO_LINE_SIZE);
if (status)
{
/* allocate memory for note_line*/
err = ProDtlnotelineAlloc (¬e_line);
TEST_CALL_REPORT ("ProDtlnotelineAlloc()", "ProTestNoteTextGet()",
err, err != PRO_TK_NO_ERROR);
/* allocate memory for note_text */
err = ProDtlnotetextAlloc (¬e_text);
TEST_CALL_REPORT ("ProDtlnotetextAlloc()", "ProTestNoteTextGet()",
err, err != PRO_TK_NO_ERROR);
/* set string to note_text */
err = ProDtlnotetextStringSet (note_text, text);
TEST_CALL_REPORT ("ProDtlnotetextStringSet()",
"ProTestNoteTextGet()",
err, err != PRO_TK_NO_ERROR);
/* set note_text to note line */
err = ProDtlnotelineTextAdd (note_line, note_text);
TEST_CALL_REPORT ("ProDtlnotelineTextAdd()",
"ProTestNoteTextGet()",
err, err != PRO_TK_NO_ERROR);
/* free note_text memory */
err = ProDtlnotetextFree (note_text);
TEST_CALL_REPORT ("ProDtlnotetextFree()", "ProTestNoteTextGet()",
err, err != PRO_TK_NO_ERROR);
/*--------------------------------------------------------------------------*\
Copy note_line info to the array of lines
\*--------------------------------------------------------------------------*/
err = ProArrayObjectAdd ((ProArray*)&lines, PRO_VALUE_UNUSED,
1, ¬e_line);
/* Also must set copy of texts (because ProDtlnotelineFree */
/* will free texts) */
err = ProDtlnotelineTextsCollect (note_line, &texts);
TEST_CALL_REPORT ("ProDtlnotelineTextsCollect()",
"ProTestNoteTextGet()",
err, err != PRO_TK_NO_ERROR && err != PRO_TK_E_NOT_FOUND);
err = ProDtlnotelineTextsSet (lines[line_count], texts);
TEST_CALL_REPORT ("ProDtlnotelineTextsSet()",
"ProTestNoteTextGet()",
err, err != PRO_TK_NO_ERROR);
err = ProArraySizeGet ((ProArray)texts, &n_texts);
for (i = 0; i < n_texts; i++)
err = ProDtlnotetextFree (texts[i]);
err = ProArrayFree ((ProArray*)&texts);
line_count++;
}
}
while (status); /*while get input*/
*p_lines = lines;
return 0;
}
/*---------------------------------------------------------------------*\
Function: ProTestLocationGet ()
Purpose: Get Note location
Returns: 0 - success; -1 - error.
\*---------------------------------------------------------------------*/
int ProTestLocationGet (
ProDrawing drawing,
ProView view,
ProDtlattachType type,
ProDtlattach* p_attachment)
{
ProVector location;
ProError err;
ProMouseButton mouse_button;
ProSelection *p_sel;
int n_sel;
if (type == PRO_DTLATTACHTYPE_FREE)
{
ProUtilMsgPrint("gen", "TEST %0s", "Select location");
err = ProMousePickGet (PRO_LEFT_BUTTON, &mouse_button,location /*free_point*/);
TEST_CALL_REPORT("ProMousePickGet()", "ProTestLocationGet()",
err, err != PRO_TK_NO_ERROR);
if (err != PRO_TK_NO_ERROR)
return -1;
err = ProDtlattachAlloc (type, view, location, NULL, p_attachment);
TEST_CALL_REPORT ("ProDtlattachAlloc()", "ProTestLocationGet()",
err, err != PRO_TK_NO_ERROR);
}
else if (type == PRO_DTLATTACHTYPE_PARAMETRIC)
{
ProUtilMsgPrint("gen", "TEST %0s", "Select item");
err = ProSelect ((char*)"edge,curve,point", 1, NULL, NULL, NULL, NULL, &p_sel,
&n_sel);
if (err != PRO_TK_NO_ERROR || n_sel < 1)
return -1;
err = ProDtlattachAlloc (type, NULL, NULL, p_sel[0], p_attachment);
TEST_CALL_REPORT ("ProDtlattachAlloc()", "ProTestLocationGet()",
err, err != PRO_TK_NO_ERROR);
}
else
return (PRO_TK_GENERAL_ERROR);
return 0;
}
/*===========================================================================*\
Function : ProTestDtlNoteModify
Purpose :
\*===========================================================================*/
int ProTestDtlNoteModify (void* app_data)
{
ProDrawing drawing = (ProDrawing)app_data;
int opt, sheet, n_leaders, i;
ProDtlnotedata note_data;
ProDtlnote note;
ProError err;
ProCharLine line;
static ProUtilMenuButtons mod_note[] = {
{"Edit", 0, TEST_CALL_PRO_MENU_DELETE},
{"Text", NOTE_MOD_TEXT, 0},
{"Attrbutes", NOTE_MOD_ATTR, 0},
{"Color", NOTE_MOD_COLOR, 0},
{"Location", NOTE_MOD_LOCATION, 0},
{"leaders", NOTE_MOD_ATTACH, 0},
{"Angle", NOTE_MOD_ANGLE, 0},
{"Elbowlength", NOTE_MOD_ELB, 0},
{"",0,0}
};
ProColor color;
ProDtlattach location, *p_leaders = NULL;
ProDtlattachType at_type;
ProView view;
ProBoolean flag;
double param = 0.0;
ProTextStyle note_data_text_style;
int ProTestDtlAttribModify (ProDtlnotedata note_data);
int ProTestSelectNote (ProDrawing drw, ProDtlnote *note);
ProError ProTestDtlNoteTextModify (ProDtlnotedata note_data);
err = ProUtilMenuIntValueSelect(mod_note, &opt);
if (!ProTestSelectNote (drawing, ¬e))
return (PRO_TK_NO_ERROR);
err = ProDtlnoteDataGet (¬e, NULL, PRODISPMODE_NUMERIC, ¬e_data);
TEST_CALL_REPORT("ProDtlnoteDataGet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
err = ProDtlnotedataTextStyleGet(note_data, ¬e_data_text_style);
TEST_CALL_REPORT("ProDtlnotedataTextStyleGet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
switch (opt)
{
case NOTE_MOD_TEXT :
err = ProTestDtlNoteTextModify (note_data);
if (err != PRO_TK_NO_ERROR)
return (PRO_TK_GENERAL_ERROR);
break;
case NOTE_MOD_ATTR :
ProTestDtlAttribModify (note_data);
break;
case NOTE_MOD_COLOR :
ProTestColorGet (&color);
err = ProTextStyleColorSetWithDef(note_data_text_style, &color);
break;
case NOTE_MOD_LOCATION :
err = ProTestAttachTypeGet (&at_type);
err = ProDrawingCurrentSheetGet (drawing, &sheet);
TEST_CALL_REPORT ("ProDrawingCurrentSheetGet()",
"ProTestDtlNoteCreate()",err, err != PRO_TK_NO_ERROR);
err = ProDrawingBackgroundViewGet (drawing, sheet, &view);
TEST_CALL_REPORT ("ProDrawingBackgroundViewGet()",
"ProTestDtlNoteCreate()", err, err != PRO_TK_NO_ERROR);
if (ProTestLocationGet (drawing, view, at_type, &location) != 0)
return (PRO_TK_GENERAL_ERROR);
err = ProDtlnotedataAttachmentSet (note_data, location);
TEST_CALL_REPORT ("ProDtlnotedataAttachmentSet()",
"ProTestDtlNoteCreate()", err, err != PRO_TK_NO_ERROR);
err = ProDtlattachFree (location);
TEST_CALL_REPORT ("ProDtlattachFree()",
"ProTestDtlNoteCreate()", err, err != PRO_TK_NO_ERROR);
break;
case NOTE_MOD_ATTACH :
if (ProDtlnotedataLeadersCollect (note_data, &p_leaders)
!= PRO_TK_NO_ERROR)
{
ProUtilMsgPrint("gen", "TEST %0s", "Unable to modity leaders: ");
return (PRO_TK_NO_ERROR);
}
err = ProTestLeadersGet (&p_leaders);
if (p_leaders != NULL && err == PRO_TK_NO_ERROR)
{
err = ProDtlnotedataLeadersSet (note_data, p_leaders);
TEST_CALL_REPORT("ProDtlsyminstdataLeadersSet()",
"ProTestSymInstModify()", err, err != PRO_TK_NO_ERROR);
err = ProArraySizeGet ((ProArray)p_leaders, &n_leaders);
for (i = 0; i < n_leaders; i++)
err = ProDtlattachFree (p_leaders[i]);
err = ProArrayFree ((ProArray*)&p_leaders);
}
break;
case NOTE_MOD_ANGLE:
ProUtilMsgPrint("gen", "TEST %0s", "Enter angle: ");
err = ProTextStyleAngleGet(note_data_text_style, ¶m);
TEST_CALL_REPORT("ProTextStyleAngleGet()",
"ProTestSymInstModify()", err, err != PRO_TK_NO_ERROR);
ProTKSprintf (line, "Enter angle [%6.2f]: ", param);
ProUtilMsgPrint("gen", "TEST %0s", line);
if (ProMessageDoubleRead (NULL, ¶m) != PRO_TK_NO_ERROR)
return (PRO_TK_NO_ERROR);
err = ProTextStyleAngleSet (note_data_text_style, param);
TEST_CALL_REPORT("ProTextStyleAngleSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
break;
case NOTE_MOD_ELB :
if (ProDtlnotedataLeadersCollect (note_data, &p_leaders)
!= PRO_TK_NO_ERROR)
{
ProUtilMsgPrint("gen", "TEST %0s", "Unable to modity leaders: ");
return (PRO_TK_NO_ERROR);
}
err = ProDtlnotedataElbowlengthGet (note_data, &flag, ¶m);
TEST_CALL_REPORT("ProDtlnotedataElbowlengthGet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
if (flag == PRO_B_FALSE)
{
ProTKSprintf (line, "Enter elbow length [%6.2f]: ", param);
ProUtilMsgPrint("gen", "TEST %0s", line);
}
else
ProUtilMsgPrint("gen", "TEST %0s", "Enter elbow length: ");
if (ProMessageDoubleRead (NULL, ¶m) != PRO_TK_NO_ERROR)
return (PRO_TK_NO_ERROR);
err = ProDtlnotedataElbowlengthSet (note_data, PRO_B_FALSE,
param);
TEST_CALL_REPORT("ProDtlnotedataElbowlengthSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
break;
}
err = ProDtlnotedataTextStyleSet(note_data, note_data_text_style);
TEST_CALL_REPORT("ProDtlnotedataTextStyleSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
err = ProDtlnoteErase (¬e);
TEST_CALL_REPORT("ProDtlnoteErase()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
err = ProDtlnoteModify (¬e, NULL, note_data);
TEST_CALL_REPORT("ProDtlnoteModify()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
err = ProDtlnoteShow (¬e);
TEST_CALL_REPORT("ProDtlnoteShow()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
err = ProDtlnotedataFree (note_data);
TEST_CALL_REPORT ("ProDtlnotedataFree()", "ProTestDtlNoteCreate()",
err, err != PRO_TK_NO_ERROR);
return (PRO_TK_NO_ERROR);
}
/*===========================================================================*\
Function : ProTestDtlNoteTextModify
Purpose :
\*===========================================================================*/
ProError ProTestDtlNoteTextModify (ProDtlnotedata note_data)
{
ProError err;
int opt;
ProName font;
ProLine string;
static ProUtilMenuButtons text_note_opt[] = {
{"NoteText", 0, TEST_CALL_PRO_MENU_DELETE},
{"Font", NOTE_FONT, 0},
{"Uline", NOTE_ULINE, 0},
{"Thickness", NOTE_THICKNESS,0},
{"Slant", NOTE_SLANT,0},
{"Width", NOTE_WIDTH,0},
{"Height", NOTE_HEIGHT,0},
{"String", NOTE_STRING,0},
{"",0,0}
};
ProDtlnoteline *p_lines;
ProDtlnotetext *p_texts;
int n_lines = 0, i, j, n_texts = 0;
double param = 0.0;
ProBoolean underline = PRO_B_FALSE;
ProCharLine line, temp_str;
ProTextStyle note_text_style;
err = ProDtlnotedataLinesCollect (note_data, &p_lines);
TEST_CALL_REPORT("ProDtlnotedataLinesCollect()",
"ProTestDtlNoteTextModify()", err, err != PRO_TK_NO_ERROR
&& err != PRO_TK_E_NOT_FOUND);
if (err != PRO_TK_NO_ERROR)
return (err);
err = ProUtilMenuIntValueSelect(text_note_opt, &opt);
ProTKSprintf (line, "Enter %s: ", text_note_opt[opt+1].button);
ProUtilMsgPrint("gen", "TEST %0s", line);
if (opt == NOTE_FONT)
{
if (ProMessageStringRead (PRO_NAME_SIZE, font) != PRO_TK_NO_ERROR)
return (PRO_TK_GENERAL_ERROR);
}
else if (opt == NOTE_ULINE)
{
if (ProUtilYesnoGet((char*)"n"))
underline = PRO_B_TRUE;
}
else if (opt != NOTE_STRING)
{
if (ProMessageDoubleRead (NULL, ¶m) != PRO_TK_NO_ERROR)
return (PRO_TK_GENERAL_ERROR);
}
err = ProArraySizeGet ((ProArray)p_lines, &n_lines);
for (i = 0; i < n_lines; i++)
{
err = ProDtlnotelineTextsCollect (p_lines[i], &p_texts);
TEST_CALL_REPORT("ProDtlnotelineTextsCollect()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR
&& err != PRO_TK_E_NOT_FOUND);
if (err != PRO_TK_NO_ERROR)
continue;
err = ProArraySizeGet ((ProArray)p_texts, &n_texts);
for (j = 0; j < n_texts; j++)
{
err = ProDtlnotetextStyleGet(p_texts[j], ¬e_text_style);
TEST_CALL_REPORT("ProDtlnotetextStyleGet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
switch (opt)
{
case NOTE_FONT :
err = ProTextStyleFontSet(note_text_style, font);
TEST_CALL_REPORT("ProTextStyleFontSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
break;
case NOTE_ULINE :
err = ProDtlnotetextUlineSet (p_texts[j], underline);
TEST_CALL_REPORT("ProDtlnotetextUlineSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
break;
case NOTE_THICKNESS :
err = ProTextStyleThicknessSet(note_text_style, param);
TEST_CALL_REPORT("ProTextStyleThicknessSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
break;
case NOTE_SLANT :
err = ProTextStyleSlantAngleSet(note_text_style, param);
TEST_CALL_REPORT("ProTextStyleSlantAngleSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
break;
case NOTE_WIDTH :
err = ProTextStyleWidthSet(note_text_style, param);
TEST_CALL_REPORT("ProTextStyleWidthSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
break;
case NOTE_HEIGHT :
err = ProTextStyleHeightSet(note_text_style, param);
TEST_CALL_REPORT("ProTextStyleHeightSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
break;
case NOTE_STRING :
ProDtlnotetextStringGet (p_texts[j], string);
TEST_CALL_REPORT("ProDtlnotetextStringGet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
ProWstringToString (temp_str, string);
ProTKSprintf (line, "Enter text {%s}: ", temp_str);
ProUtilMsgPrint("gen", "TEST %0s", line);
ProUtilStringGet (string, NULL, PRO_LINE_SIZE);
err = ProDtlnotetextStringSet (p_texts[j], string);
TEST_CALL_REPORT("ProDtlnotetextStringSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
break;
default : break;
}
}
err = ProDtlnotelineTextsSet (p_lines[i], p_texts);
TEST_CALL_REPORT("ProDtlnotelineTextsSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
}
err = ProDtlnoteldataLinesSet (note_data, p_lines);
TEST_CALL_REPORT("ProDtlnoteldataLinesSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
return (PRO_TK_NO_ERROR);
}
/*===========================================================================*\
Function : ProTestDtlAttribModify
Purpose :
\*===========================================================================*/
int ProTestDtlAttribModify (ProDtlnotedata note_data)
{
ProError err;
int menu_id;
ProTextHrzJustification hjust = PRO_TEXT_HRZJUST_CENTER;
ProBoolean mirror, read;
ProVerticalJustification vjust = PRO_VERTJUST_TOP;
static char *menu[]={"Attributes","VerJust","HorJust","AttrSet",""};
int ProTestDtlAttribSet (ProBoolean *mirror, ProBoolean *read,
ProTextHrzJustification *hjust,
ProVerticalJustification *vjust,
ProDtlnotedata note_data);
mirror = read = PRO_B_FALSE;
err = ProMenuFileRegister((char*)"Attributes", (char*)"tkattribnote.mnu", &menu_id);
err = ProMenubuttonActionSet((char*)"Attributes", (char*)"Attributes",
(ProMenubuttonAction)ProMenuDelete, NULL, 0);
err = ProMenubuttonActionSet((char*)"Attributes", (char*)"Mirror",
(ProMenubuttonAction)ProTestAssignAttr, &mirror, PRO_B_TRUE);
err = ProMenubuttonActionSet((char*)"Attributes", (char*)"Readonly",
(ProMenubuttonAction)ProTestAssignAttr, &read, PRO_B_TRUE);
err = ProMenuFileRegister((char*)"HorJust", (char*)"tkattribnoteh.mnu", &menu_id);
err = ProMenubuttonActionSet((char*)"HorJust", (char*)"HorJust",
(ProMenubuttonAction)ProMenuDelete, NULL, 0);
err = ProMenubuttonActionSet((char*)"HorJust", (char*)"Left",
(ProMenubuttonAction)ProTestAssignAttr, &hjust, PRO_TEXT_HRZJUST_LEFT);
err = ProMenubuttonActionSet((char*)"HorJust", (char*)"Center",
(ProMenubuttonAction)ProTestAssignAttr, &hjust, PRO_TEXT_HRZJUST_CENTER);
err = ProMenubuttonActionSet((char*)"HorJust", (char*)"Right",
(ProMenubuttonAction)ProTestAssignAttr, &hjust, PRO_TEXT_HRZJUST_RIGHT);
err = ProMenuFileRegister((char*)"VerJust", (char*)"tkattribnotev.mnu", &menu_id);
err = ProMenubuttonActionSet((char*)"VerJust", (char*)"VerJust",
(ProMenubuttonAction)ProMenuDelete, NULL, 0);
err = ProMenubuttonActionSet((char*)"VerJust", (char*)"Top",
(ProMenubuttonAction)ProTestAssignAttr, &vjust, PRO_VERTJUST_TOP);
err = ProMenubuttonActionSet((char*)"VerJust", (char*)"Middle",
(ProMenubuttonAction)ProTestAssignAttr, &vjust, PRO_VERTJUST_MIDDLE);
err = ProMenubuttonActionSet((char*)"VerJust", (char*)"Bottom",
(ProMenubuttonAction)ProTestAssignAttr, &vjust, PRO_VERTJUST_BOTTOM);
err = ProMenuFileRegister((char*)"AttrSet", (char*)"tkattribnoteset.mnu", &menu_id);
err = ProMenubuttonActionSet((char*)"AttrSet", (char*)"AttrSet",
(ProMenubuttonAction)ProMenuDelete, NULL, 0);
err = ProMenubuttonGenactionSet((char*)"AttrSet", (char*)"Done",
(ProMenubuttonGenaction)ProTestDtlAttribSet, &mirror, &read, &vjust,
&hjust, note_data, NULL);
err = ProCompoundmenuCreate(menu, &menu_id);
err = ProMenuProcess(menu[0], &menu_id);
return (PRO_TK_NO_ERROR);
}
/*===========================================================================*\
Function : ProTestDtlAttribSet
Purpose :
\*===========================================================================*/
int ProTestDtlAttribSet (
ProBoolean *mirror,
ProBoolean *read,
ProTextHrzJustification *hjust,
ProVerticalJustification *vjust,
ProDtlnotedata note_data)
{
ProError err;
ProTextStyle note_data_text_style;
ProMenuDelete();
ProMenuDelete();
ProMenuDelete();
ProMenuDelete();
err = ProDtlnotedataTextStyleGet(note_data, ¬e_data_text_style);
TEST_CALL_REPORT("ProDtlnotedataTextStyleGet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
err = ProTextStyleMirrorSet(note_data_text_style, *mirror);
TEST_CALL_REPORT("ProTextStyleMirrorSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
err = ProTextStyleJustificationSet(note_data_text_style, *hjust);
TEST_CALL_REPORT("ProTextStyleJustificationSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
err = ProTextStyleVertJustificationSet(note_data_text_style, *vjust);
TEST_CALL_REPORT("ProTextStyleVertJustificationSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
err = ProDtlnotedataTextStyleSet(note_data, note_data_text_style);
TEST_CALL_REPORT("ProDtlnotedataTextStyleSet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
err = ProDtlnotedataReadonlySet (note_data, *read);
TEST_CALL_REPORT("ProDtlnotedataReadonlySet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
return (PRO_TK_NO_ERROR);
}
/*===========================================================================*\
Function : ProTestSelectNote
Purpose :
\*===========================================================================*/
int ProTestSelectNote (ProDrawing drw, ProDtlnote *note)
{
ProSelection *p_sel;
int n_sel;
ProError err;
ProUtilMsgPrint("gen", "TEST %0s", "Select a note");
err = ProSelect ((char*)"any_note", 1 , NULL, NULL, NULL, NULL, &p_sel, &n_sel);
if (err != PRO_TK_NO_ERROR || n_sel < 1)
return (PRO_TK_NO_ERROR);
err = ProSelectionModelitemGet (p_sel[0], note);
TEST_CALL_REPORT("ProSelectionModelitemGet()",
"ProTestEntEdit()", err, err != PRO_TK_NO_ERROR);
return (1);
}
/*===========================================================================*\
Function : ProTestDtlNoteInfo
Purpose :
\*===========================================================================*/
int ProTestDtlNoteInfo (void* app_data)
{
ProDrawing drawing = (ProDrawing)app_data;
ProError err;
ProDtlnote *p_notes;
int n_notes = 0, i, n_leaders = 0, j, n_lines = 0, n_texts = 0, k, id;
ProDtlnotedata note_data;
ProBoolean flag;
ProTextHrzJustification hjust;
ProVerticalJustification vjust;
ProColor color;
double param = 0.0;
ProDtlattach attach, *p_leaders;
ProDtlattachType type;
ProView view;
ProVector location;
ProSelection attach_point;
ProDtlnoteline *p_lines;
ProDtlnotetext *p_texts;
ProTextStyle note_text_style;
ProLine string;
FILE *fp;
ProCharLine line, fname;
ProPath path;
wchar_t *font;
ProMdlName mdl_ref_name;
ProMdl mdl_ref;
ProTextStyle note_data_text_style;
void ProTestColorPrint (FILE *, ProColor);
fp = ProUtilGenFilePtr((ProMdl)drawing, (char*)DTL_NOTE_FILE, fname, (char*)"w");
err = ProDrawingDtlnotesCollect (drawing, NULL, PRO_VALUE_UNUSED, &p_notes);
TEST_CALL_REPORT("ProDrawingDtlnotesCollect()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR
&& err != PRO_TK_E_NOT_FOUND);
err = ProArraySizeGet ((ProArray)p_notes, &n_notes);
for (i = 0; i < n_notes; i++)
{
err = ProDtlnoteDataGet (&p_notes[i], NULL, PRODISPMODE_NUMERIC,
¬e_data);
TEST_CALL_REPORT("ProDtlnoteDataGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
err = ProDtlnotedataIdGet (note_data, &id);
TEST_CALL_REPORT("ProDtlnotedataIdGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp, "\nID: %d. ", id);
/* get attributes */
err = ProDtlnotedataTextStyleGet(note_data, ¬e_data_text_style);
TEST_CALL_REPORT("ProDtlnotedataTextStyleGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
err = ProTextStyleMirrorGet(note_data_text_style, &flag);
TEST_CALL_REPORT("ProTextStyleMirrorGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp, "Mirrored: %s. ", (flag == PRO_B_TRUE) ? "Yes" : "No");
err = ProDtlnotedataReadonlyGet (note_data, &flag);
TEST_CALL_REPORT("ProDtlnotedataReadonlyGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp, "Readonly: %s. \n", (flag == PRO_B_TRUE) ? "Yes" : "No");
err = ProTextStyleJustificationGet(note_data_text_style, &hjust);
TEST_CALL_REPORT("ProTextStyleJustificationGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
err = ProTextStyleVertJustificationGet(note_data_text_style, &vjust);
TEST_CALL_REPORT("ProTextStyleVertJustificationGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp, "Justification : norisontal = %d, vertical = %d. \n",
hjust, vjust);
/* get color */
err = ProTextStyleColorGetWithDef(note_data_text_style, &color);
TEST_CALL_REPORT("ProTextStyleColorGetWithDef()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp, "Color: ");
ProTestColorPrint (fp, color);
/* get parameters */
err = ProDtlnotedataElbowlengthGet (note_data, &flag, ¶m);
TEST_CALL_REPORT("ProDtlnotedataElbowlengthGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
if (flag == PRO_B_FALSE)
ProTKFprintf (fp, "Elbow leng = %6.3f.", param);
else
ProTKFprintf (fp, "Elbow leng: No.");
err = ProTextStyleAngleGet(note_data_text_style, ¶m);
TEST_CALL_REPORT("ProTextStyleAngleGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp, " Angle = %6.3f. ", param);
/* get attachment */
err = ProDtlnotedataAttachmentGet (note_data, &attach);
TEST_CALL_REPORT("ProDtlnotedataAttachmentGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
err = ProDtlattachGet (attach, &type, &view, location, &attach_point);
TEST_CALL_REPORT("ProDtlattachGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp, "Attachment type: %d. ", type);
/* free dtl attachment */
err = ProDtlattachFree (attach);
TEST_CALL_REPORT("ProDtlattachFree()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
/* get leaders */
err = ProDtlnotedataLeadersCollect (note_data, &p_leaders);
TEST_CALL_REPORT("ProDtlnotedataLeadersCollect()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR
&& err != PRO_TK_E_NOT_FOUND);
if (err == PRO_TK_NO_ERROR)
{
err = ProArraySizeGet ((ProArray)p_leaders, &n_leaders);
ProTKFprintf (fp, "Number of leaders: %d.\n", n_leaders);
}
/* get texts */
err = ProDtlnotedataLinesCollect (note_data, &p_lines);
TEST_CALL_REPORT("ProDtlnotedataLinesCollect()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR
&& err != PRO_TK_E_NOT_FOUND);
if (err != PRO_TK_NO_ERROR)
continue;
err = ProArraySizeGet ((ProArray)p_lines, &n_lines);
for (j = 0; j < n_lines; j++)
{
err = ProDtlnotelineTextsCollect (p_lines[j], &p_texts);
TEST_CALL_REPORT("ProDtlnotelineTextsCollect()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR
&& err != PRO_TK_E_NOT_FOUND);
if (err != PRO_TK_NO_ERROR)
continue;
err = ProArraySizeGet ((ProArray)p_texts, &n_texts);
for (k = 0; k < n_texts; k++)
{
err = ProDtlnotetextStyleGet(p_texts[k], ¬e_text_style);
TEST_CALL_REPORT("ProDtlnotetextStyleGet",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp, "Note text param:\n");
err = ProTextStyleHeightGet(note_text_style, ¶m);
TEST_CALL_REPORT("ProTextStyleHeightGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp,"Height = %6.3f. ", param);
err = ProTextStyleWidthGet(note_text_style, ¶m);
TEST_CALL_REPORT("ProTextStyleWidthGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp,"Width = %6.3f. ", param);
err = ProTextStyleSlantAngleGet(note_text_style, ¶m);
TEST_CALL_REPORT("ProTextStyleSlantAngleGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp,"Slant = %6.3f. ", param);
err = ProTextStyleThicknessGet(note_text_style, ¶m);
TEST_CALL_REPORT("ProTextStyleThicknessGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp,"Thickness = %6.3f.\n", param);
err = ProTextStyleFontGet(note_text_style, font);
TEST_CALL_REPORT("ProTextStyleFontGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProWstringToString (line, font);
ProTKFprintf (fp,"Font: %s. ", line);
err = ProDtlnotetextUlineGet (p_texts[k], &flag);
TEST_CALL_REPORT("ProDtlnotetextUlineGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp,"Uline: %s.\n", (flag == PRO_B_TRUE) ? "Yes" : "No");
ProTKFprintf (fp, "Note text:\n");
err = ProDtlnotetextStringGet (p_texts[k], string);
TEST_CALL_REPORT("ProDtlnotetextStringGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProWstringToString (line, string);
ProTKFprintf (fp, "%s", line);
err = ProDtlnoteModelrefGet (&p_notes[i], NULL, j, k, &mdl_ref);
TEST_CALL_REPORT("ProDtlnoteModelrefGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
if (err == PRO_TK_NO_ERROR)
{
err = ProMdlMdlnameGet (mdl_ref, mdl_ref_name);
TEST_CALL_REPORT("ProMdlMdlnameGet()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
ProTKFprintf (fp, " (Ref model: %s)\n",
ProWstringToString (line, mdl_ref_name));
}
}
for (k = 0; k < n_texts; k++)
{
err = ProDtlnotetextFree (p_texts[k]);
TEST_CALL_REPORT("ProDtlnotetextFree()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
}
err = ProArrayFree ((ProArray*)&p_texts);
}
for (j = 0; j < n_lines; j++)
{
err = ProDtlnotelineFree (p_lines[j]);
TEST_CALL_REPORT("ProDtlnotelineFree()",
"ProTestDtlNoteInfo()", err, err != PRO_TK_NO_ERROR);
}
err = ProArrayFree ((ProArray*)&p_lines);
}
err = ProArrayFree ((ProArray*)&p_notes);
err = ProDtlnotedataFree (note_data);
TEST_CALL_REPORT ("ProDtlnotedataFree()", "ProTestDtlNoteCreate()",
err, err != PRO_TK_NO_ERROR);
fclose (fp);
ProStringToWstring(path, fname);
err = ProInfoWindowDisplay(path, NULL, NULL);
return (PRO_TK_NO_ERROR);
}
/*===========================================================================*\
Function : ProTestDtlNoteDisplay
Purpose :
\*===========================================================================*/
int ProTestDtlNoteDisplay (void* app_data)
{
ProError err;
ProDrawing drw = (ProDrawing)app_data;
int opt;
ProDtlnote note;
static ProUtilMenuButtons disp_note[] = {
{"Display", 0, TEST_CALL_PRO_MENU_DELETE},
{"Remove", NOTE_REMOVE, 0},
{"Erase", NOTE_ERASE, 0},
{"Delete", NOTE_DELETE, 0},
{"",0,0}
};
err = ProUtilMenuIntValueSelect(disp_note, &opt);
if (!ProTestSelectNote (drw, ¬e))
return (PRO_TK_NO_ERROR);
switch (opt)
{
case NOTE_REMOVE :
err = ProDtlnoteRemove (¬e);
TEST_CALL_REPORT("ProDtlnoteRemove()",
"ProTestDtlNoteDisplay()", err, err != PRO_TK_NO_ERROR);
break;
case NOTE_ERASE :
err = ProDtlnoteErase (¬e);
TEST_CALL_REPORT("ProDtlnoteErase()",
"ProTestDtlNoteDisplay()", err, err != PRO_TK_NO_ERROR);
break;
case NOTE_DELETE :
err = ProDtlnoteErase (¬e);
TEST_CALL_REPORT("ProDtlnoteErase()",
"ProTestDtlNoteDisplay()", err, err != PRO_TK_NO_ERROR);
err = ProDtlnoteDelete (¬e, NULL);
TEST_CALL_REPORT("ProDtlnoteDelete()",
"ProTestDtlNoteDisplay()", err, err != PRO_TK_NO_ERROR);
break;
}
return (PRO_TK_NO_ERROR);
}
/*===========================================================================*\
Function : ProTestAssignAttr
Purpose :
\*===========================================================================*/
int ProTestAssignAttr(ProAppData p_member, int option)
{
*((int *)p_member) = option;
return (PRO_TK_NO_ERROR);
}
/*===========================================================================*\
Function : ProTestLeadersGet
Purpose :
\*===========================================================================*/
ProError ProTestLeadersGet (ProDtlattach** leaders_arr)
{
ProError err;
int menu_id;
int n_leaders = 0;
ProDtlattach *leaders;
int ProTestLeadesAdd (ProDtlattach** leaders,
ProDtlattachType type);
if (leaders_arr != NULL)
*leaders_arr = (ProDtlattach *)NULL;
else
return (PRO_TK_BAD_INPUTS);
err = ProArrayAlloc (0, sizeof (ProDtlattach), 1, (ProArray*)&leaders);
TEST_CALL_REPORT("ProArrayAlloc()",
"ProTestLeadersGet()", err, err != PRO_TK_NO_ERROR);
err = ProMenuFileRegister((char*)"LeaderType",(char*)"tkleadertype.mnu", &menu_id);
err = ProMenubuttonActionSet((char*)"LeaderType",(char*)"LeaderType",
(ProMenubuttonAction)ProMenuDelete, NULL, 0);
err = ProMenubuttonActionSet((char*)"LeaderType",(char*)"Free",
(ProMenubuttonAction)ProTestLeadesAdd, &leaders,
PRO_DTLATTACHTYPE_FREE);
err = ProMenubuttonActionSet((char*)"LeaderType",(char*)"Parametric",
(ProMenubuttonAction)ProTestLeadesAdd, &leaders,
PRO_DTLATTACHTYPE_PARAMETRIC);
err = ProMenubuttonActionSet((char*)"LeaderType",(char*)"Done",
(ProMenubuttonAction)ProMenuDelete, NULL, 0);
err = ProMenuCreate(PROMENUTYPE_MAIN, (char*)"LeaderType",&menu_id);
err = ProMenuProcess((char*)"", &menu_id);
err = ProArraySizeGet ((ProArray)leaders, &n_leaders);
if (err == PRO_TK_NO_ERROR && n_leaders > 0)
*leaders_arr = leaders;
else
err = ProArrayFree ((ProArray*)&leaders);
return (PRO_TK_NO_ERROR);
}
/*===========================================================================*\
Function : ProTestLeadesAdd
Purpose :
\*===========================================================================*/
int ProTestLeadesAdd(ProDtlattach** leaders,
ProDtlattachType type)
{
ProError err;
ProView view;
ProDrawing drawing;
ProDtlattach leader;
ProPoint3d point;
ProSelection *sel;
int n_sel, sheet;
ProMouseButton btn;
err = ProMdlCurrentGet ((ProMdl*)&drawing);
err = ProDrawingCurrentSheetGet (drawing, &sheet);
TEST_CALL_REPORT ("ProDrawingCurrentSheetGet()",
"ProTestLeadesAdd()",err, err != PRO_TK_NO_ERROR);
err = ProDrawingBackgroundViewGet (drawing, sheet, &view);
TEST_CALL_REPORT ("ProDrawingBackgroundViewGet()", "ProTestLeadesAdd()",
err, err != PRO_TK_NO_ERROR);
switch (type)
{
case PRO_DTLATTACHTYPE_FREE :
ProUtilMsgPrint("gen", "TEST %0s",
"Pick end points of leaders (middle button to quit)");
while (1)
{
err = ProMousePickGet(PRO_ANY_BUTTON, &btn, point);
if (btn != PRO_LEFT_BUTTON || err != PRO_TK_NO_ERROR)
break;
ProGraphicsCircleDraw (point, 0.5);
err = ProDtlattachAlloc (type, view, point, NULL, &leader);
TEST_CALL_REPORT("ProDtlattachAlloc()",
"ProTestAttachGet()", err, err != PRO_TK_NO_ERROR);
err = ProArrayObjectAdd ((ProArray*)leaders, PRO_VALUE_UNUSED,
1, &leader);
}
break;
case PRO_DTLATTACHTYPE_PARAMETRIC :
ProUtilMsgPrint("gen", "TEST %0s",
"Select attachment points for leaders");
while (1)
{
err = ProSelect ((char*)"edge,curve,point,axis", 1, NULL, NULL, NULL,
NULL, &sel, &n_sel);
if (err != PRO_TK_NO_ERROR || n_sel != 1)
break;
err = ProDtlattachAlloc (type, NULL, NULL, sel[0], &leader);
TEST_CALL_REPORT("ProDtlattachAlloc()",
"ProTestLeadersGet()", err, err != PRO_TK_NO_ERROR);
err = ProArrayObjectAdd ((ProArray*)leaders, PRO_VALUE_UNUSED,
1, &leader);
}
break;
default : break;
}
return (PRO_TK_NO_ERROR);
}