改背景黑白交替

 1 NXOpen::Display::Background *background;
 2     background = workPart->Views()->CreateBackground(workPart->ModelingViews()->WorkView(), false);
 3     background->SetBackgroundShadedViewsType(NXOpen::Display::Background::ShadedTypePlain);
 4     background->Commit();
 5     background->Destroy();
 6     
 7     UF_initialize();
 8 
 9     char * clr_name;
10     double clr_values[3];
11     UF_DISP_ask_color(0, UF_DISP_rgb_model, &clr_name, clr_values);
12     if (clr_values[0] == 0.0&& clr_values[1] == 0.0&& clr_values[2] == 0.0)
13     {
14         //白色背景
15         double clr_values[3] = { 1.0,1.0,1.0 };
16         UF_DISP_set_color(UF_DISP_BACKGROUND_COLOR, UF_DISP_rgb_model, NULL, clr_values);
17         UF_DISP_load_color_table();
18         uc1601("庆哥提示更改为:白色背景", 0);
19     }
20     else if (clr_values[0] == 1.0&& clr_values[1] == 1.0&& clr_values[2] == 1.0)
21     {
22         //黑色背景
23         double clr_values[3] = { 0.0,0.0,0.0 };
24         UF_DISP_set_color(UF_DISP_BACKGROUND_COLOR, UF_DISP_rgb_model, NULL, clr_values);
25         UF_DISP_load_color_table();
26         uc1601("庆哥提示更改为:黑色背景", 0);
27     }
28     else
29     {
30         NXOpen::Display::Background *background;
31         background = workPart->Views()->CreateBackground(workPart->ModelingViews()->WorkView(), false);
32         background->SetBackgroundShadedViewsType(NXOpen::Display::Background::TypePlain);
33         background->Commit();
34         background->Destroy();
35     }
36     UF_terminate();

 下面是经典背景

 1     NXOpen::Session *theSession = NXOpen::Session::GetSession();
 2     NXOpen::Part *workPart(theSession->Parts()->Work());
 3     NXOpen::Part *displayPart(theSession->Parts()->Display());
 4 
 5     NXOpen::Display::Scene *scene;
 6     scene = workPart->Views()->CreateScene(workPart->ModelingViews()->WorkView(), false);
 7     NXOpen::Display::Background *background;
 8     background = workPart->Views()->CreateBackground(workPart->ModelingViews()->WorkView(), false);
 9     background->SetBackgroundShadedViewsType(2);
10     std::vector<double> topcolor;
11     const double topcolor1_initial_values[] = {0.13725490196078433, 0.13725490196078433, 0.29411764705882354};
12     topcolor.assign(topcolor1_initial_values, topcolor1_initial_values + 3);
13     background->SetBackgroundShadedViewsGraduatedTop(topcolor);
14     std::vector<double> bottomcolor;
15     const double bottomcolor1_initial_values[] = {0.054901960784313725, 0.41176470588235292, 0.58823529411764708};
16     bottomcolor.assign(bottomcolor1_initial_values, bottomcolor1_initial_values + 3);
17     background->SetBackgroundShadedViewsGraduatedBottom(bottomcolor);
18     background->Commit();
19     scene->Commit();
20     scene->Destroy();
21     background->Destroy();

 

posted @ 2020-06-08 21:42  老婆饼里有老婆  阅读(427)  评论(1编辑  收藏  举报