Salome HOME
Initial version
[modules/gui.git] / doc / salome / tui / KERNEL / exemple / Example13.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>\r
2 <HEAD>\r
3 <!-- hennerik CVSweb $Revision$ -->\r
4 <TITLE>Example</TITLE></HEAD>\r
5 <BODY BGCOLOR="#eeeeee">\r
6 <HR noshade><PRE>#%Test AttributeTextHighlightColor interface(creations/saving/restoring)%\r
7 #%SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open%\r
8 #%Attribute methods : &nbsp;SetTextHighlightColor TextHighlightColor%\r
9 \r
10 #--------------------------------------------------------------------------\r
11 # &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;create &nbsp; &nbsp;AttributeTextHighlightColor\r
12 #===========================================================\r
13 \r
14 import SALOMEDS_Attributes_idl\r
15 highlightcolor=SALOMEDS_Attributes_idl._0_SALOMEDS.Color(256,256,256)\r
16 \r
17 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, &quot;AttributeTextHighlightColor&quot;)\r
18 \r
19 if A == None :\r
20  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTextHighlightColor attribute&quot;\r
21 A = A._narrow(SALOMEDS.AttributeTextHighlightColor)\r
22 \r
23 if A == None :\r
24  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTextHighlightColor attribute&quot;\r
25 \r
26 A.SetTextHighlightColor(highlightcolor)\r
27 \r
28 c = A.TextHighlightColor();\r
29 if c.R != 256 or c.G != 256 or c.B != 256:\r
30  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Error: wrong value of AttributeTextHighlightColor&quot;\r
31 \r
32 \r
33 # &nbsp; &nbsp; &nbsp;save / restore study &nbsp; &nbsp; &nbsp;\r
34 #============================================================\r
35 str= os.getenv(&quot;TmpDir&quot;)\r
36 if str == None:\r
37  &nbsp; &nbsp; &nbsp; &nbsp;str = &quot;/tmp&quot;\r
38 file = str+&quot;/test.hdf&quot;\r
39 \r
40 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)\r
41 openedStudy=batchmode_geompy.myStudyManager.Open(file);\r
42 \r
43 if openedStudy == None:\r
44  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
45 \r
46 father = openedStudy.FindComponent(&quot;GEOM&quot;)\r
47 if father is None:\r
48  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;Geom component is not found! &nbsp;Wrong study is opened.&quot; \r
49 \r
50 \r
51 # &nbsp; &nbsp; &nbsp; find &nbsp; AttributeTextHighlightColor\r
52 #============================================================\r
53 \r
54 res, A = father.FindAttribute(&quot;AttributeTextHighlightColor&quot;)\r
55 print res, A\r
56 if res == 0 or A == None:\r
57  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: &nbsp;not found AttributeTextHighlightColor&quot;\r
58 \r
59 A = A._narrow(SALOMEDS.AttributeTextHighlightColor)\r
60 \r
61 if A == None :\r
62  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTextHighlightColor attribute&quot;\r
63 \r
64 c = A.TextHighlightColor();\r
65 \r
66 if c.R != 256 or c.G != 256 or c.B != 256:\r
67  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Error: wrong value of AttributeTextTextHighlightColor&quot;\r
68 </PRE>