/*
Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
/*-------------------------- Pro/Toolkit includes ---------------------------*/
#include <ProToolkit.h>
#include <ProMdl.h>
#include <ProCsys.h>
#include <ProDtlnote.h>
/*-------------------------- Application includes ---------------------------*/
#include <TestError.h>
/*================================================================*\
FUNCTION : UserNotesColor
PURPOSE : Creates both general and projection type drawing views.
\*================================================================*/
ProError UserNotesColor ()
{
ProError status;
ProColor color;
int color_index;
ProDrawing p_draw;
int sheet, n_notes, n;
int i_range[2] = {0 , PRO_COLOR_MAX};
ProFileName WMSGFIL = {'m','s','g','_','u','g','d','w','g','.','t','x','t','\0'};
ProDtlnote *notes;
/*------------------------------------------------------------*\
Ask the user the color of the notes
\*------------------------------------------------------------*/
status = ProMessageDisplay(WMSGFIL, "USER %0s",
"Enter the color index : ");
ERROR_CHECK("UserNotesColor","ProMessageDisplay",status);
status = ProMessageIntegerRead(i_range, &color_index);
ERROR_CHECK("UserNotesColor","ProMessageIntegerRead",status);
if (status != PRO_TK_NO_ERROR) return(status);
/*------------------------------------------------------------*\
Get the current model
\*------------------------------------------------------------*/
status = ProMdlCurrentGet((ProMdl*)&p_draw);
ERROR_CHECK("UserNotesColor","ProMdlCurrentGet",status);
if (status != PRO_TK_NO_ERROR) return(status);
/*------------------------------------------------------------*\
Get the list of notes on the current sheet.
\*------------------------------------------------------------*/
status = ProDrawingCurrentSheetGet(p_draw, &sheet);
ERROR_CHECK("UserNotesColor","ProDrawingCurrentSheetGet",status);
if (sheet <=0) return (PRO_TK_NOT_VALID);
status = ProDrawingDtlnotesCollect(p_draw, NULL, sheet, ¬es);
ERROR_CHECK("UserNotesColor","prodtl_get_ids", status);
status = ProArraySizeGet ((ProArray)notes, &n_notes);
ERROR_CHECK("UserNotesColor","prodtl_get_ids", (n_notes <0));
if (n_notes < 0) return (PRO_TK_E_NOT_FOUND);
color.method = PRO_COLOR_METHOD_TYPE;
color.value.type = (ProColortype)color_index;
for (n = 0; n < n_notes; n++)
{
ProDtlnote *p_note;
ProDtlnotedata notedata;
ProTextStyle dtlNote_text_style;
p_note = ¬es[n];
/*--------------------------------------------------------*\
Get the note description and modify the note color.
\*--------------------------------------------------------*/
status = ProDtlnoteDataGet (p_note, NULL, PRODISPMODE_NUMERIC, ¬edata);
status = ProDtlnotedataTextStyleGet(notedata, &dtlNote_text_style);
status = ProTextStyleColorSetWithDef(dtlNote_text_style, &color);
/*--------------------------------------------------------*\
Erase, modify, and redraw the note.
\*--------------------------------------------------------*/
status = ProDtlnoteErase(p_note);
ERROR_CHECK("UserNotesColor","ProDtlnoteErase", status);
if (status != PRO_TK_NO_ERROR) return (PRO_TK_GENERAL_ERROR);
status = ProDtlnoteModify(p_note, NULL, notedata);
ERROR_CHECK("UserNotesColor","ProDtlnoteModify", status);
if (status != PRO_TK_NO_ERROR) return (PRO_TK_GENERAL_ERROR);
status = ProDtlnoteDraw(p_note);
ERROR_CHECK("UserNotesColor","ProDtlnoteDraw", status);
if (status != PRO_TK_NO_ERROR) return (PRO_TK_GENERAL_ERROR);
}
return (PRO_TK_NO_ERROR);
}