⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nameset.c

📁 Intro/: Directory containing introductory examples. HelloWorld.c A simple program that draws a bo
💻 C
字号:
#include <phigs.h>			/* get HP-PHIGS definitions for C */#include <stdio.h>			/* get standard I/O definitions */#include <math.h>			/* link with library "-lm" */main()					/* file "NameSet.c" */{    Pint	WorkstnID = 1;		/* workstation identifier */    Pint	ConnID;			/* connection identifier */    Pint	WorkstnType = POIDDX;	/* out/in, direct, dbl bfr, Xwindow */    Pint	Names[255];		/* names for name set */    Pint_list	NameSet;		/* the name set itself */    Pint	Root = 1, Text = 2;	/* structure names (chosen by user) */    Pfilter	Filter;    Pint	Include[10], Exclude[10];	/* name set variables */    Pint	Floor1 = 1, Floor2 = 2,		Floor3 = 3, Electrical = 4, Plumbing = 5;    Pint	ChoiceStatus, ChoiceNum;/* choice status and value */    char	Message1[80], Message2[80], Message3[80], Message4[80];    static Pcolr_rep Gray   = {0.4, 0.4, 0.4};    static Pcolr_rep Green  = {0.0, 1.0, 0.0};    static Pcolr_rep Yellow = {1.0, 1.0, 0.0};    Phighl_rep	HighlightRep;    static Pvec	ZeroVec = {0.0, 0.0};	/* annotation text offset */    Ppoint	Loc;			/* for text location */    Pint	Error;			/* error-return variable */    /*--- open phigs and workstation  --------------------------------------*/    popen_phigs((char *) stderr, 0);	/* errors go to "stderr" */    pescape_u4("/dev/screen/phigs_window", &ConnID);    popen_ws(WorkstnID, (void *) ConnID, WorkstnType);    pset_colr_rep(WorkstnID, 0, &Gray);    pset_colr_rep(WorkstnID, 2, &Green);    pset_colr_rep(WorkstnID, 3, &Yellow);    pset_choice_mode(WorkstnID, 2, POP_REQ, PSWITCH_NO_ECHO);    /*--- set up highlight colour ------------------------------------------*/    HighlightRep.method_4.highl_colr_ind = 2;    pescape_u200(WorkstnID, 1, 4, &HighlightRep); /* set highlight rep. */    /*--- text structure for messages --------------------------------------*/    strcpy(Message1, "Initial Values");    strcpy(Message2, "  Inclusion set: Empty");    strcpy(Message3, "  Exclusion set: Empty");    strcpy(Message4, "(press any key to continue)");    popen_struct(Text);    pset_text_colr_ind(2);    pset_anno_char_ht(0.02);    Loc.x = 0.05, Loc.y = 0.9;	panno_text_rel(&Loc, &ZeroVec, Message1);    Loc.x = 0.05, Loc.y = 0.85;	panno_text_rel(&Loc, &ZeroVec, Message2);    Loc.x = 0.05, Loc.y = 0.80;	panno_text_rel(&Loc, &ZeroVec, Message3);    Loc.x = 0.05, Loc.y = 0.75;	panno_text_rel(&Loc, &ZeroVec, Message4);    pclose_struct();    /*--- open the root structure ------------------------------------------*/    popen_struct(Root);    pset_text_font(2);    /*--- create headings without nameset attributes -----------------------*/    pexec_struct(Text);    pset_char_ht(0.05);    pset_text_colr_ind(2);    Loc.x = 0.05, Loc.y = 0.6;	ptext(&Loc, "Electrical");    Loc.x = 0.6, Loc.y = 0.6;	ptext(&Loc, "Plumbing");    pset_text_colr_ind(3);    /*--- create nameset elements for each electrical component ------------*/    Names[0] = Electrical;    Names[1] = Floor1;    NameSet.num_ints = 2;    NameSet.ints = Names;    padd_names_set(&NameSet);    /*--- current name set: Electrical, Floor1 -----------------------------*/    Loc.x = 0.05, Loc.y = 0.5;	ptext(&Loc, "Floor 1");    Names[0] = Floor1;    NameSet.num_ints = 1;    premove_names_set(&NameSet);    Names[0] = Floor2;    padd_names_set(&NameSet);    /*--- current name set: Electrical, Floor2 -----------------------------*/    Loc.x = 0.05, Loc.y = 0.4;	ptext(&Loc, "Floor 2");    Names[0] = Floor2;    premove_names_set(&NameSet);    Names[0] = Floor3;    padd_names_set(&NameSet);    /*--- current name set: Electrical, Floor3 -----------------------------*/    Loc.x = 0.05, Loc.y = 0.3;	ptext(&Loc, "Floor 3");    Names[0] = Electrical;    premove_names_set(&NameSet);    /*--- current name set: Floor3 -----------------------------------------*/    /*--- create nameset attribute elements for each plumbing component ----*/    Names[0] = Plumbing;    padd_names_set(&NameSet);    /*--- current name set: Plumbing, Floor3 -------------------------------*/    Loc.x = 0.6, Loc.y = 0.3;	ptext(&Loc, "Floor 3");    Names[0] = Floor3;    premove_names_set(&NameSet);    Names[0] = Floor2;    padd_names_set(&NameSet);    /*--- current name set: Plumbing, Floor2 -------------------------------*/    Loc.x = 0.6, Loc.y = 0.4;	ptext(&Loc, "Floor 2");    Names[0] = Floor2;    premove_names_set(&NameSet);    Names[0] = Floor1;    padd_names_set(&NameSet);    /*--- current name set: Plumbing, Floor1 -------------------------------*/    Loc.x = 0.6, Loc.y = 0.5;	ptext(&Loc, "Floor 1");    /*--- close the structure and post it to the workstation  --------------*/    pclose_struct();    ppost_struct(WorkstnID, Root, 1.0);    predraw_all_structs(WorkstnID, 1);    preq_choice(WorkstnID, 2, &ChoiceStatus, &ChoiceNum);    /*--- highlight electrical on floors 1 and 3  --------------------------*/    Include[0] = Electrical;    Filter.incl_set.num_ints = 1;    Filter.incl_set.ints = Include;    Filter.excl_set.num_ints = 2;    Filter.excl_set.ints = Exclude;    Exclude[0] = Plumbing;    Exclude[1] = Floor2;    pset_highl_filter(WorkstnID, &Filter);    /*--- replace text primitives in the text structure --------------------*/    strcpy(Message1, "Highlight filter");    strcpy(Message2, "  Inclusion set: Electrical");    strcpy(Message3, "  Exclusion set: Plumbing, Floor2");    pset_edit_mode(PEDIT_REPLACE);    popen_struct(Text);    pset_elem_ptr(3);    Loc.x = 0.05, Loc.y = 0.9;	panno_text_rel(&Loc, &ZeroVec, Message1);    pset_elem_ptr(4);    Loc.x = 0.05, Loc.y = 0.85;	panno_text_rel(&Loc, &ZeroVec, Message2);    pset_elem_ptr(5);    Loc.x = 0.05, Loc.y = 0.80;	panno_text_rel(&Loc, &ZeroVec, Message3);    pclose_struct();    /*--- redraw all structures and request choice -------------------------*/    predraw_all_structs(WorkstnID, 1);    preq_choice(WorkstnID, 2, &ChoiceStatus, &ChoiceNum);    /*--- clear the highlighting filter  -----------------------------------*/    Filter.incl_set.num_ints = Filter.excl_set.num_ints = 0;    pset_highl_filter(WorkstnID, &Filter);    /*--- make electrical and plumbing on floors 2 and 3 invisible ---------*/    Filter.incl_set.num_ints = 2;    Filter.excl_set.num_ints = 1;    Include[0] = Electrical;    Include[1] = Plumbing;    Exclude[0] = Floor1;    pset_invis_filter(WorkstnID, &Filter);    /*--- replace text primitives in the text structure --------------------*/    strcpy(Message1, "Invisibility filter");    strcpy(Message2, "  Inclusion set: Floor2, Floor3, Electrical, Plumbing");    strcpy(Message3, "  Exclusion set: Floor1");    popen_struct(Text);    pset_elem_ptr(3);    Loc.x = 0.05, Loc.y = 0.9;	panno_text_rel(&Loc, &ZeroVec, Message1);    pset_elem_ptr(4);    Loc.x = 0.05, Loc.y = 0.85;	panno_text_rel(&Loc, &ZeroVec, Message2);    pset_elem_ptr(5);    Loc.x = 0.05, Loc.y = 0.80;	panno_text_rel(&Loc, &ZeroVec, Message3);    pclose_struct();    /*--- redraw all structures and request choice ------------------------*/    predraw_all_structs(WorkstnID, 1);    preq_choice(WorkstnID, 2, &ChoiceStatus, &ChoiceNum);    punpost_all_structs(WorkstnID);    pupd_ws(WorkstnID, PFLAG_PERFORM);    pclose_ws(WorkstnID);    pclose_phigs();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -