ruby-iup 0.0.1-i386-mswin32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. data/doc/README +10 -0
  2. data/doc/build_install.txt +77 -0
  3. data/examples/README +16 -0
  4. data/examples/ctrl/cbox.rb +221 -0
  5. data/examples/ctrl/checkboard.rb +33 -0
  6. data/examples/ctrl/degrade.rb +73 -0
  7. data/examples/ctrl/example1.rb +53 -0
  8. data/examples/ctrl/example2.rb +39 -0
  9. data/examples/ctrl/iupcolorbar.rb +95 -0
  10. data/examples/ctrl/iupcolorbrowser.rb +45 -0
  11. data/examples/ctrl/iupdial.rb +117 -0
  12. data/examples/ctrl/iupgauge.rb +242 -0
  13. data/examples/ctrl/iupgetcolor.rb +8 -0
  14. data/examples/ctrl/iupgetparam.rb +62 -0
  15. data/examples/ctrl/iupglcanvas.rb +172 -0
  16. data/examples/ctrl/iupmask.rb +15 -0
  17. data/examples/ctrl/iupmatrix.rb +39 -0
  18. data/examples/ctrl/iupplot2.rb +603 -0
  19. data/examples/ctrl/iuptabs.rb +22 -0
  20. data/examples/ctrl/iuptree.rb +190 -0
  21. data/examples/ctrl/iupval.rb +71 -0
  22. data/examples/ctrl/numbering.rb +46 -0
  23. data/examples/ctrl/sample.rb +166 -0
  24. data/examples/dlg/iupalarm.rb +14 -0
  25. data/examples/dlg/iupfiledlg.rb +19 -0
  26. data/examples/dlg/iupgetfile.rb +19 -0
  27. data/examples/dlg/iuplistdialog.rb +26 -0
  28. data/examples/dlg/iupmessage.rb +5 -0
  29. data/examples/dlg/iupscanf.rb +17 -0
  30. data/examples/elem/iupbutton.rb +197 -0
  31. data/examples/elem/iupcanvas.rb +27 -0
  32. data/examples/elem/iupcanvas2.rb +113 -0
  33. data/examples/elem/iupcanvas3.rb +62 -0
  34. data/examples/elem/iupdialog.rb +71 -0
  35. data/examples/elem/iupdialog2.rb +25 -0
  36. data/examples/elem/iupfill.rb +51 -0
  37. data/examples/elem/iupframe.rb +25 -0
  38. data/examples/elem/iuphbox.rb +68 -0
  39. data/examples/elem/iupimage.rb +113 -0
  40. data/examples/elem/iupitem.rb +60 -0
  41. data/examples/elem/iuplabel.rb +57 -0
  42. data/examples/elem/iuplist.rb +41 -0
  43. data/examples/elem/iuplist2.rb +125 -0
  44. data/examples/elem/iupmenu.rb +32 -0
  45. data/examples/elem/iupmultiline.rb +24 -0
  46. data/examples/elem/iupmultiline2.rb +156 -0
  47. data/examples/elem/iupradio.rb +32 -0
  48. data/examples/elem/iupseparator.rb +81 -0
  49. data/examples/elem/iupsubmenu.rb +85 -0
  50. data/examples/elem/iuptext.rb +61 -0
  51. data/examples/elem/iuptimer.rb +36 -0
  52. data/examples/elem/iuptoggle.rb +110 -0
  53. data/examples/elem/iupvbox.rb +87 -0
  54. data/examples/elem/iupzbox.rb +60 -0
  55. data/examples/elem/mdisample.rb +376 -0
  56. data/examples/elem/progressbar.rb +294 -0
  57. data/examples/elem/scrollbar.rb +66 -0
  58. data/examples/elem/tray.rb +90 -0
  59. data/examples/func/iupgetattribute.rb +32 -0
  60. data/examples/func/iupidle.rb +48 -0
  61. data/ext/extconf.rb +27 -0
  62. data/ext/iup-win32/cd.dll +0 -0
  63. data/ext/iup-win32/cd.lib +0 -0
  64. data/ext/iup-win32/cdcontextplus.dll +0 -0
  65. data/ext/iup-win32/cdcontextplus.lib +0 -0
  66. data/ext/iup-win32/cdlua51.lib +0 -0
  67. data/ext/iup-win32/cdluacontextplus51.lib +0 -0
  68. data/ext/iup-win32/cdluaim51.lib +0 -0
  69. data/ext/iup-win32/cdluapdf51.lib +0 -0
  70. data/ext/iup-win32/cdpdf.dll +0 -0
  71. data/ext/iup-win32/cdpdf.lib +0 -0
  72. data/ext/iup-win32/freetype6.dll +0 -0
  73. data/ext/iup-win32/freetype6.lib +0 -0
  74. data/ext/iup-win32/im.dll +0 -0
  75. data/ext/iup-win32/im_avi.dll +0 -0
  76. data/ext/iup-win32/im_capture.dll +0 -0
  77. data/ext/iup-win32/im_ecw.dll +0 -0
  78. data/ext/iup-win32/im_fftw.dll +0 -0
  79. data/ext/iup-win32/im_jp2.dll +0 -0
  80. data/ext/iup-win32/im_process.dll +0 -0
  81. data/ext/iup-win32/im_wmv.dll +0 -0
  82. data/ext/iup-win32/iup.dll +0 -0
  83. data/ext/iup-win32/iup.lib +0 -0
  84. data/ext/iup-win32/iup_pplot.dll +0 -0
  85. data/ext/iup-win32/iup_pplot.lib +0 -0
  86. data/ext/iup-win32/iupcd.dll +0 -0
  87. data/ext/iup-win32/iupcd.lib +0 -0
  88. data/ext/iup-win32/iupcontrols.dll +0 -0
  89. data/ext/iup-win32/iupcontrols.lib +0 -0
  90. data/ext/iup-win32/iupgl.dll +0 -0
  91. data/ext/iup-win32/iupgl.lib +0 -0
  92. data/ext/iup-win32/iupim.dll +0 -0
  93. data/ext/iup-win32/iupim.lib +0 -0
  94. data/ext/iup-win32/iupimglib.dll +0 -0
  95. data/ext/iup-win32/iupimglib.lib +0 -0
  96. data/ext/iup-win32/iuplua51.lib +0 -0
  97. data/ext/iup-win32/iuplua_pplot51.lib +0 -0
  98. data/ext/iup-win32/iupluacd51.lib +0 -0
  99. data/ext/iup-win32/iupluacontrols51.lib +0 -0
  100. data/ext/iup-win32/iupluagl51.lib +0 -0
  101. data/ext/iup-win32/iupluaim51.lib +0 -0
  102. data/ext/iup-win32/iupluaimglib51.lib +0 -0
  103. data/ext/iup-win32/iupluaole51.lib +0 -0
  104. data/ext/iup-win32/iupole.dll +0 -0
  105. data/ext/iup-win32/iupole.lib +0 -0
  106. data/ext/iup-win32/iupstub.lib +0 -0
  107. data/ext/iup-win32/pdflib.dll +0 -0
  108. data/ext/iup-win32/pdflib.lib +0 -0
  109. data/ext/iup.c +1261 -0
  110. data/ext/mkrf_conf.rb +72 -0
  111. data/ext/rb_cd.h +1525 -0
  112. data/ext/rb_iup.h +2446 -0
  113. data/ext/rb_iup_pplot.h +129 -0
  114. data/ext/rb_iupcb.h +13 -0
  115. data/ext/rb_iupcbox.h +40 -0
  116. data/ext/rb_iupcells.h +15 -0
  117. data/ext/rb_iupcolorbar.h +17 -0
  118. data/ext/rb_iupcompat.h +237 -0
  119. data/ext/rb_iupcontrols.h +28 -0
  120. data/ext/rb_iupdef.h +3 -0
  121. data/ext/rb_iupdial.h +24 -0
  122. data/ext/rb_iupgauge.h +15 -0
  123. data/ext/rb_iupgc.h +18 -0
  124. data/ext/rb_iupgetparam.h +72 -0
  125. data/ext/rb_iupgl.h +58 -0
  126. data/ext/rb_iupim.h +25 -0
  127. data/ext/rb_iupmask.h +189 -0
  128. data/ext/rb_iupmatrix.h +80 -0
  129. data/ext/rb_iupole.h +24 -0
  130. data/ext/rb_iupsbox.h +23 -0
  131. data/ext/rb_iupspeech.h +25 -0
  132. data/ext/rb_iupspin.h +29 -0
  133. data/ext/rb_iuptabs.h +29 -0
  134. data/ext/rb_iuptree.h +94 -0
  135. data/ext/rb_iupval.h +24 -0
  136. data/lib/README +1 -0
  137. data/lib/iup.so +0 -0
  138. metadata +187 -0
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'iup'
3
+
4
+ r,g,b=Iup.GetColor(100,100)
5
+ if r
6
+ puts "RGB = %.2X%.2X%.2X" % [r,g,b]
7
+ end
8
+
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ require 'iup'
3
+
4
+ def param_action(dialog,param_index,user_data)
5
+ case(param_index)
6
+ when -1
7
+ puts("OK")
8
+ when -2
9
+ puts("Map")
10
+ when -3
11
+ puts("Cancel")
12
+ else
13
+ param_str = "PARAM#{param_index}"
14
+ param = dialog.GetNode(param_str)
15
+ puts "#{param_str} = #{param.value}"
16
+ end
17
+ return 1
18
+ end
19
+
20
+ pboolean = 1
21
+ pinteger = 3456
22
+ preal = 3.543
23
+ pinteger2 = 192
24
+ preal2 = 0.5
25
+ pangle = 90.0
26
+ pstring = "string text"
27
+ plist = 2
28
+ pstring2 = "second text\nsecond line"
29
+ file_name = "test.jpg"
30
+
31
+
32
+ pboolean, pinteger, preal, pinteger2, preal2, pangle, pstring, plist, file_name, pstring2 =
33
+ Iup.GetParam("Title", 'param_action', 0,
34
+ "Boolean: %b[No,Yes]\n"+
35
+ "Integer: %i\n"+
36
+ "Real 1: %r\n"+
37
+ "Sep1 %t\n"+
38
+ "Integer: %i[0,255]\n"+
39
+ "Real 2: %r[-1.5,1.5]\n"+
40
+ "Sep2 %t\n"+
41
+ "Angle: %a[0,360]\n"+
42
+ "String: %s\n"+
43
+ "List: %l|item1|item2|item3|\n" +
44
+ "File: %f[OPEN|*.bmp;*.jpg|CURRENT|NO|NO]\n"+
45
+ "Sep3 %t\n"+
46
+ "Multiline: %m\n",
47
+ pboolean, pinteger, preal, pinteger2, preal2, pangle, pstring, plist, file_name, pstring2)
48
+
49
+ Iup.Messagef("IupGetParam",
50
+ "Boolean Value: %d\n"+
51
+ "Integer: %d\n"+
52
+ "Real 1: %g\n"+
53
+ "Integer: %d\n"+
54
+ "Real 2: %g\n"+
55
+ "Angle: %g\n"+
56
+ "String: %s\n"+
57
+ "List Index: %d\n"+
58
+ "FileName: %s\n"+
59
+ "Multiline: %s",
60
+ pboolean, pinteger, preal, pinteger2, preal2, pangle, pstring, plist, file_name, pstring2);
61
+
62
+
@@ -0,0 +1,172 @@
1
+ require 'rubygems'
2
+ require 'iup'
3
+ require 'opengl'
4
+
5
+ include Gl
6
+
7
+ redraw = lambda do |ih,x,y|
8
+ size = ih.rastersize
9
+ w,h = size.scan(/\d+/).map{|x|x.to_i}
10
+
11
+ Iup.GLMakeCurrent(ih)
12
+ glViewport(0, 0, w, h)
13
+
14
+ glMatrixMode(GL_PROJECTION)
15
+ glLoadIdentity()
16
+ glOrtho(0, 1, 1, 0, -1.0, 1.0)
17
+ glMatrixMode(GL_MODELVIEW)
18
+ glLoadIdentity()
19
+ glPushMatrix()
20
+ glTranslate(0.25,0.5, 0)
21
+ glScale(0.2, 0.2, 1)
22
+
23
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
24
+
25
+ glClearColor(0,0,0,1)
26
+ glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
27
+ glEnable(GL_BLEND)
28
+
29
+ # draw rectangle
30
+ glColor(1, 1, 0, 0.8)
31
+ glRect(-1,-1,1,1)
32
+
33
+ # Create List That Draws the Circle
34
+ planet = glGenLists(1)
35
+ orbit = glGenLists(2)
36
+
37
+ glNewList(planet, GL_COMPILE)
38
+ glBegin(GL_POLYGON)
39
+ for i in 0..100
40
+ cosine = Math.cos(i * 2 * Math::PI/100.0)
41
+ sine = Math.sin(i * 2 * Math::PI/100.0)
42
+ glVertex(cosine,sine)
43
+ end
44
+ glEnd()
45
+ glEndList()
46
+
47
+ glNewList(orbit, GL_COMPILE)
48
+ glBegin(GL_LINE_LOOP)
49
+ for i in 0..100
50
+ cosine = Math.cos(i * 2 * Math::PI/100.0)
51
+ sine = Math.sin(i * 2 * Math::PI/100.0)
52
+ glVertex(cosine, sine)
53
+ end
54
+ glEnd()
55
+ glEndList()
56
+
57
+ glColor( 0, 0.5, 0, 0.8)
58
+ glCallList(planet)
59
+
60
+ glColor( 0, 0, 0, 1 )
61
+ glCallList(orbit)
62
+
63
+ glEnableClientState(GL_VERTEX_ARRAY)
64
+
65
+ vertices = [[-3**(0.5)/2, 1.0/2], [3**(0.5)/2, 0.5], [0.0, -1.0], [-3**(0.5)/2, -1.0/2], [3**(0.5)/2, -1.0/2], [0.0, 1.0] ]
66
+
67
+ glVertexPointer(2,GL_FLOAT,0,vertices.flatten.pack("f*"))
68
+
69
+ # draw first triangle
70
+ glColor( 0, 0, 1, 0.5 )
71
+
72
+ glBegin(GL_TRIANGLES)
73
+ glArrayElement(0)
74
+ glArrayElement(1)
75
+ glArrayElement(2)
76
+ glEnd()
77
+
78
+ # draw second triangle
79
+ glColor( 1, 0, 0, 0.5 )
80
+ glVertexPointer(2,GL_FLOAT,0,vertices.flatten.pack("f*"))
81
+ glDrawArrays(GL_TRIANGLES, 3, 3)
82
+
83
+ # draw triangles outline
84
+ glColor(1,1,1,1)
85
+ elements = [ 0, 1, 2].pack("I*")
86
+ glDrawElements(GL_LINE_LOOP,3,GL_UNSIGNED_INT,elements)
87
+ elements = [ 3, 4, 5].pack("I*")
88
+ glDrawElements(GL_LINE_LOOP,3,GL_UNSIGNED_INT,elements)
89
+
90
+ glDisableClientState(GL_VERTEX_ARRAY)
91
+
92
+ glPopMatrix()
93
+ glTranslate(0.75,0.5, 0)
94
+ glScale(0.2, 0.2, 1)
95
+
96
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
97
+
98
+ # draw rectangle
99
+ glColor( 1, 1, 0, 0.8 )
100
+
101
+ glBegin(GL_QUADS)
102
+ glVertex(-1,-1)
103
+ glVertex( 1,-1)
104
+ glVertex( 1, 1)
105
+ glVertex(-1, 1)
106
+ glEnd()
107
+
108
+ glColor( 0, 0.5, 0, 0.8 )
109
+ glBegin(GL_POLYGON)
110
+ for i in 0..100
111
+ cosine = Math.cos(i * 2.0 * Math::PI/100.0)
112
+ sine = Math.sin(i * 2.0 * Math::PI/100.0)
113
+ glVertex(cosine,sine)
114
+ end
115
+ glEnd()
116
+
117
+ glColor( 0, 0, 0, 1 )
118
+ glBegin(GL_LINE_LOOP)
119
+ for i in 0..100
120
+ cosine = Math.cos(i * 2.0 * Math::PI/100.0)
121
+ sine = Math.sin(i * 2.0 * Math::PI/100.0)
122
+ glVertex(cosine, sine)
123
+ end
124
+ glEnd()
125
+
126
+ # draw first triangle
127
+ glColor( 0, 0, 1, 0.5 )
128
+ glBegin(GL_TRIANGLES)
129
+ glVertex(*vertices[0])
130
+ glVertex(*vertices[1])
131
+ glVertex(*vertices[2])
132
+ glEnd()
133
+ # draw second triangle
134
+ glColor( 1, 0, 0, 0.5 )
135
+ glBegin(GL_TRIANGLES)
136
+ glVertex(*vertices[3])
137
+ glVertex(*vertices[4])
138
+ glVertex(*vertices[5])
139
+ glEnd()
140
+ # draw triangles outline
141
+ glColor(1,1,1,1)
142
+ glBegin(GL_LINE_LOOP)
143
+ glVertex(*vertices[0])
144
+ glVertex(*vertices[1])
145
+ glVertex(*vertices[2])
146
+ glEnd()
147
+ glBegin(GL_LINE_LOOP)
148
+ glVertex(*vertices[3])
149
+ glVertex(*vertices[4])
150
+ glVertex(*vertices[5])
151
+ glEnd()
152
+
153
+ Iup.GLSwapBuffers(ih)
154
+
155
+ Iup::DEFAULT
156
+ end
157
+
158
+
159
+ canvas = Iup.GLCanvas()
160
+ canvas.action = redraw
161
+ canvas.buffer = "DOUBLE"
162
+ canvas.rastersize = "123x200"
163
+
164
+ finale = Iup.Hbox([Iup.Fill(),
165
+ canvas,
166
+ Iup.Fill()])
167
+
168
+ dg = Iup.Dialog(finale,:title=>"IupGLCanvas")
169
+
170
+ dg.Show()
171
+ Iup.MainLoop
172
+ dg.Destroy()
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'iup'
3
+
4
+ text = Iup.Text()
5
+ test = text.maskSet("/d*", 0, 1)
6
+
7
+ text.size = "100x"
8
+ text.expand = "HORIZONTAL"
9
+
10
+ dg = Iup.Dialog(text,:title=> "IupMask")
11
+
12
+ dg.Show()
13
+ Iup.MainLoop()
14
+ text.maskRemove
15
+ dg.Destroy()
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require 'iup'
3
+
4
+
5
+ def create_mat()
6
+
7
+ mat = Iup.Matrix(nil)
8
+
9
+ mat.numcol_visible = 2
10
+ mat.numlin_visible = 3
11
+ mat.resizematrix = "YES"
12
+
13
+ mat.numlin = 3
14
+ mat.numcol = 2
15
+
16
+ mat["0:0"] = "Inflation"
17
+ mat["1:0"] = "Medicine "
18
+ mat["2:0"] = "Food"
19
+ mat["3:0"] = "Energy"
20
+ mat["0:1"] = "January 2000"
21
+ mat["0:2"] = "February 2000"
22
+ mat["1:1"] = 5.6
23
+ mat["2:1"] = 2.2
24
+ mat["3:1"] = 7.2
25
+ mat["1:2"] = 4.5
26
+ mat["2:2"] = 8.1
27
+ mat["3:2"] = 3.4
28
+ mat.widthdef = 34
29
+
30
+ mat
31
+ end
32
+
33
+
34
+
35
+ dlg = Iup.Dialog(create_mat)
36
+ dlg.ShowXY(Iup::CENTER,Iup::CENTER)
37
+ Iup.MainLoop
38
+ dlg.Destroy
39
+
@@ -0,0 +1,603 @@
1
+ require 'rubygems'
2
+ require 'iup'
3
+
4
+ MAXPLOT = 6 # room for examples
5
+
6
+ class IupPlotTest
7
+
8
+ def InitPlots()
9
+
10
+ delete_cb = lambda do |ih, index, sample_index, x, y|
11
+ puts("DELETE_CB(#{index}, #{sample_index}, #{x}, #{y})")
12
+ Iup::DEFAULT
13
+ end
14
+
15
+ select_cb = lambda do |ih, index, sample_index, x, y, select|
16
+ puts("SELECT_CB(#{index}, #{sample_index}, #{x}, #{y}, #{select})")
17
+ Iup::DEFAULT
18
+ end
19
+
20
+ edit_cb = lambda do |ih, index, sample_index, x, y,new_x,new_y|
21
+ puts("EDIT_CB(#{index}, #{sample_index}, #{x}, #{y}, #{new_x}, #{new_y})")
22
+ Iup::DEFAULT
23
+ end
24
+
25
+ postdraw_cb = lambda do |ih,cnv|
26
+ ix,iy = ih.PPlotTransform(0.003, 0.02)
27
+ cnv.CanvasFont(nil, Cd::BOLD, 10)
28
+ cnv.CanvasTextAlignment(Cd::SOUTH)
29
+ cnv.CanvasText(ix, iy, "My Inline Legend")
30
+ puts("POSTDRAW_CB()")
31
+ Iup::DEFAULT
32
+ end
33
+
34
+ predraw_cb = lambda do |ih, cnv|
35
+ puts("PREDRAW_CB()")
36
+ Iup::DEFAULT
37
+ end
38
+
39
+ # PLOT 0 - MakeExamplePlot1
40
+ @plot[0].title = "AutoScale"
41
+ @plot[0].margintop = 40
42
+ @plot[0].marginleft = 40
43
+ @plot[0].marginbottom = 50
44
+ @plot[0].titlefontsize = 16
45
+ @plot[0].axs_xlabel = "gnu (Foo)"
46
+ @plot[0].axs_ylabel = "Space (m^3)"
47
+ @plot[0].axs_yfontsize = 7
48
+ @plot[0].axs_ytickfontsize = 7
49
+ @plot[0].legendshow = "YES"
50
+ @plot[0].axs_xfontsize = 10
51
+ @plot[0].axs_yfontsize = 10
52
+ @plot[0].axs_xlabelcentered = "NO"
53
+ @plot[0].axs_ylabelcentered = "NO"
54
+
55
+ # @plot[0].use_imagergb = "YES"
56
+ # @plot[0].use_gdi = "YES"
57
+
58
+ theFac = 1.0/(100*100*100)
59
+ @plot[0].PPlotBegin(0)
60
+ for theI in -100..100
61
+ x = theI+50.0
62
+ y = theFac*theI*theI*theI
63
+ @plot[0].PPlotAdd(x, y)
64
+ end
65
+ @plot[0].PPlotEnd()
66
+ @plot[0].ds_linewidth = 3
67
+ @plot[0].ds_legend = "Line"
68
+
69
+ theFac = 2.0/100
70
+ @plot[0].PPlotBegin(0)
71
+ for theI in -100..100
72
+ x = 1.0*theI
73
+ y = -theFac*theI
74
+ @plot[0].PPlotAdd(x, y)
75
+ end
76
+ @plot[0].PPlotEnd()
77
+ @plot[0].ds_legend = "Curve 1"
78
+
79
+ @plot[0].PPlotBegin(0)
80
+ for theI in -100..100
81
+ x = 0.01*theI*theI-30
82
+ y = 0.01*theI;
83
+ @plot[0].PPlotAdd(x, y)
84
+ end
85
+ @plot[0].PPlotEnd()
86
+ @plot[0].ds_legend = "Curve 2"
87
+
88
+ # PLOT 1 - MakeExamplePlot2
89
+ @plot[1].title = "No Autoscale+No CrossOrigin"
90
+ @plot[1].titlefontsize = 16
91
+ @plot[1].margintop = 40
92
+ @plot[1].marginleft = 55
93
+ @plot[1].marginbottom = 50
94
+ @plot[1].bgcolor = "0 192 192"
95
+ @plot[1].axs_xlabel = "Tg (X)"
96
+ @plot[1].axs_ylabel = "Tg (Y)"
97
+ @plot[1].axs_xautomin = "NO"
98
+ @plot[1].axs_xautomax = "NO"
99
+ @plot[1].axs_yautomin = "NO"
100
+ @plot[1].axs_yautomax = "NO"
101
+ @plot[1].axs_xmin = 10
102
+ @plot[1].axs_xmax = 60
103
+ @plot[1].axs_ymin = -0.5
104
+ @plot[1].axs_ymax = 0.5
105
+ @plot[1].axs_xcrossorigin = "NO"
106
+ @plot[1].axs_ycrossorigin = "NO"
107
+ @plot[1].axs_xfontstyle = "BOLD"
108
+ @plot[1].axs_yfontstyle = "BOLD"
109
+ @plot[1].axs_xreverse = "YES"
110
+ @plot[1].gridcolor = "128 255 128"
111
+ @plot[1].gridlinestyle = "DOTTED"
112
+ @plot[1].grid = "YES"
113
+ @plot[1].legendshow = "YES"
114
+
115
+ theFac = 1.0/(100*100*100)
116
+ @plot[1].PPlotBegin(0)
117
+ for theI in 0..100
118
+ x = 1.0*(theI)
119
+ y = theFac*theI*theI*theI;
120
+ @plot[1].PPlotAdd(x, y)
121
+ end
122
+ @plot[1].PPlotEnd()
123
+
124
+ theFac = 2.0/100
125
+ @plot[1].PPlotBegin(0)
126
+ for theI in 0..100
127
+ x = 1.0*(theI)
128
+ y = -theFac*theI
129
+ @plot[1].PPlotAdd(x, y)
130
+ end
131
+ @plot[1].PPlotEnd()
132
+
133
+ # PLOT 2 - MakeExamplePlot4
134
+ @plot[2].title = "Log Scale"
135
+ @plot[2].titlefontsize = 16
136
+ @plot[2].margintop = 40
137
+ @plot[2].marginleft = 70
138
+ @plot[2].marginbottom = 50
139
+ @plot[2].grid = "YES"
140
+ @plot[2].axs_xscale = "LOG10"
141
+ @plot[2].axs_yscale = "LOG2"
142
+ @plot[2].axs_xlabel = "Tg (X)"
143
+ @plot[2].axs_ylabel = "Tg (Y)"
144
+ @plot[2].axs_xfontstyle = "BOLD"
145
+ @plot[2].axs_yfontstyle = "BOLD"
146
+
147
+ theFac = 100.0/(100*100*100)
148
+ @plot[2].PPlotBegin(0)
149
+ for theI in 0..100
150
+ x = (0.0001+theI*0.001)
151
+ y = (0.01+theFac*theI*theI*theI)
152
+ @plot[2].PPlotAdd(x, y)
153
+ end
154
+ @plot[2].PPlotEnd()
155
+ @plot[2].ds_color = "100 100 200"
156
+
157
+ #PLOT 3 - MakeExamplePlot5
158
+ @plot[3].title = "Bar Mode"
159
+ @plot[3].titlefontsize = 16
160
+ @plot[3].margintop = 40
161
+ @plot[3].marginleft = 30
162
+ @plot[3].marginbottom = 30
163
+ kLables = ["jan","feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
164
+ kData = [1,2,3,4,5,6,7,8,9,0,1,2]
165
+
166
+ @plot[3].PPlotBegin(1)
167
+ for theI in 0...12
168
+ @plot[3].PPlotAddStr(kLables[theI], kData[theI])
169
+ end
170
+ @plot[3].PPlotEnd()
171
+ @plot[3].ds_color = "100 100 200"
172
+ @plot[3].ds_mode = "BAR"
173
+
174
+ #PLOT 4 - MakeExamplePlot6
175
+ @plot[4].title = "Marks Mode"
176
+ @plot[4].titlefontsize = 16
177
+ @plot[4].margintop = 40
178
+ @plot[4].marginleft = 45
179
+ @plot[4].marginbottom = 40
180
+ @plot[4].axs_xautomin = "NO"
181
+ @plot[4].axs_xautomax = "NO"
182
+ @plot[4].axs_yautomin = "NO"
183
+ @plot[4].axs_yautomax = "NO"
184
+ @plot[4].axs_xmin = 0
185
+ @plot[4].axs_xmax = 0.011
186
+ @plot[4].axs_ymin = 0
187
+ @plot[4].axs_ymax = 0.22
188
+ @plot[4].axs_xcrossorigin = "NO"
189
+ @plot[4].axs_ycrossorigin = "NO"
190
+ @plot[4].axs_xtickformat = "%1.3f"
191
+ @plot[4].legendshow = "YES"
192
+ @plot[4].legendpos = "BOTTOMRIGHT"
193
+
194
+ theFac = 100.0/(100*100*100)
195
+ @plot[4].PPlotBegin(0)
196
+ for theI in 0..10
197
+ x = (0.0001+theI*0.001)
198
+ y = (0.01+theFac*theI*theI)
199
+ @plot[4].PPlotAdd(x, y)
200
+ end
201
+ @plot[4].PPlotEnd()
202
+ @plot[4].ds_mode = "MARKLINE"
203
+ @plot[4].ds_showvalues = "YES"
204
+
205
+ @plot[4].PPlotBegin(0)
206
+ for theI in 0..10
207
+ x = (0.0001+theI*0.001)
208
+ y = (0.2-theFac*theI*theI)
209
+ @plot[4].PPlotAdd(x, y)
210
+ end
211
+ @plot[4].PPlotEnd()
212
+ @plot[4].ds_mode = "MARK"
213
+ @plot[4].ds_markstyle = "HOLLOW_CIRCLE"
214
+
215
+ #PLOT 5 - MakeExamplePlot8
216
+ @plot[5].title = "Data Selection and Editing"
217
+ @plot[5].titlefontsize = 16
218
+ @plot[5].margintop = 40
219
+
220
+ theFac = 100.0/(100*100*100)
221
+ @plot[5].PPlotBegin(0)
222
+ for theI in -10..10
223
+ x = (0.001*theI)
224
+ y = (0.01+theFac*theI*theI*theI)
225
+ @plot[5].PPlotAdd(x, y)
226
+ end
227
+ @plot[5].PPlotEnd()
228
+ @plot[5].ds_color = "100 100 200"
229
+ @plot[5].ds_edit = "YES"
230
+ @plot[5].delete_cb = delete_cb
231
+ @plot[5].select_cb = select_cb
232
+ @plot[5].postdraw_cb = postdraw_cb
233
+ @plot[5].predraw_cb = predraw_cb
234
+ @plot[5].edit_cb = edit_cb
235
+ end
236
+
237
+ def tabs_get_index()
238
+ curr_tab = @tabs.value
239
+ ss = curr_tab.tabtitle
240
+ ss = ss[5..-1] # Skip "Plot "
241
+ ss.to_i
242
+ end
243
+
244
+ def initialize
245
+ # Some processing required by current tab change: the controls at left
246
+ # will be updated according to current @plot props
247
+ tabs_tabchange_cb = lambda do |ih, new_tab, old_tab|
248
+ ii=0
249
+
250
+ ss = new_tab.tabtitle
251
+ ss = ss[5..-1] # Skip "Plot "
252
+ ii = ss.to_i
253
+
254
+ # autoscaling
255
+ # X axis
256
+ if (@plot[ii].axs_xautomin=="YES" && @plot[ii].axs_xautomax=="YES")
257
+ @tgg2.value = "ON"
258
+ @dial2.active = "NO"
259
+ else
260
+ @tgg2.value = "OFF"
261
+ @dial2.active = "YES"
262
+ end
263
+ # Y axis
264
+ if (@plot[ii].axs_yautomin=="YES" && @plot[ii].axs_yautomax=="YES")
265
+ @tgg1.value = "ON"
266
+ @dial1.active = "NO"
267
+ else
268
+ @tgg1.value = "OFF"
269
+ @dial1.active = "YES"
270
+ end
271
+
272
+ # grid
273
+ if (@plot[ii].grid=="YES")
274
+ @tgg3.value = "ON"
275
+ @tgg4.value = "ON"
276
+ else
277
+ # X axis
278
+ if (@plot[ii].grid == 'VERTICAL')
279
+ @tgg3.value = "ON"
280
+ else
281
+ @tgg3.value = "OFF"
282
+ end
283
+ # Y axis
284
+ if (@plot[ii].grid == 'HORIZONTAL')
285
+ @tgg4.value = "ON"
286
+ else
287
+ @tgg4.value = "OFF"
288
+ end
289
+ end
290
+
291
+ # legend
292
+ if (@plot[ii].legendshow == "YES")
293
+ @tgg5.value = "ON"
294
+ else
295
+ @tgg5.value = "OFF"
296
+ end
297
+
298
+ Iup::DEFAULT
299
+ end
300
+
301
+
302
+ # show/hide V grid
303
+ tgg3_cb = lambda do |ih,v|
304
+ ii = tabs_get_index()
305
+
306
+ if (v!=0)
307
+ if (@tgg4.value == "ON")
308
+ @plot[ii].grid = "YES"
309
+ else
310
+ @plot[ii].grid = "VERTICAL"
311
+ end
312
+ else
313
+ if (@tgg4.value == "OFF")
314
+ @plot[ii].grid = "NO"
315
+ else
316
+ @plot[ii].grid = "HORIZONTAL"
317
+ end
318
+ end
319
+ @plot[ii].redraw = nil
320
+
321
+ Iup::DEFAULT
322
+ end
323
+
324
+
325
+ # show/hide H grid
326
+ tgg4_cb = lambda do |ih, v|
327
+ ii = tabs_get_index()
328
+
329
+ if (v!=0)
330
+ if (@tgg3.value == "ON")
331
+ @plot[ii].grid = "YES"
332
+ else
333
+ @plot[ii].grid = "HORIZONTAL"
334
+ end
335
+ else
336
+ if (@tgg3.value == "OFF")
337
+ @plot[ii].grid = "NO"
338
+ else
339
+ @plot[ii].grid = "VERTICAL"
340
+ end
341
+ end
342
+ @plot[ii].redraw = nil
343
+
344
+ Iup::DEFAULT
345
+ end
346
+
347
+
348
+ # show/hide legend
349
+ tgg5_cb = lambda do |ih, v|
350
+ ii = tabs_get_index()
351
+
352
+ if (v!=0)
353
+ @plot[ii].legendshow = "YES"
354
+ else
355
+ @plot[ii].legendshow = "NO"
356
+ end
357
+ @plot[ii].redraw = nil
358
+
359
+ Iup::DEFAULT
360
+ end
361
+
362
+
363
+ # autoscale Y
364
+ tgg1_cb = lambda do |ih, v|
365
+ ii = tabs_get_index()
366
+
367
+ if (v!=0)
368
+ @dial1.active = "NO"
369
+ @plot[ii].axs_yautomin = "YES"
370
+ @plot[ii].axs_yautomax = "YES"
371
+ else
372
+ @dial1.active = "YES"
373
+ @plot[ii].axs_yautomin = "NO"
374
+ @plot[ii].axs_yautomax = "NO"
375
+ end
376
+ @plot[ii].redraw = nil
377
+
378
+ Iup::DEFAULT
379
+ end
380
+
381
+
382
+ # autoscale X
383
+ tgg2_cb = lambda do |ih, v|
384
+ ii = tabs_get_index()
385
+
386
+ if (v!=0)
387
+ @dial2.active = "NO"
388
+ @plot[ii].axs_xautomin = "YES"
389
+ @plot[ii].axs_xautomax = "YES"
390
+ else
391
+ @dial2.active = "YES"
392
+ @plot[ii].axs_xautomin = "NO"
393
+ @plot[ii].axs_xautomax = "NO"
394
+ end
395
+ @plot[ii].redraw = nil
396
+
397
+ Iup::DEFAULT
398
+ end
399
+
400
+
401
+ # Y zoom
402
+ dial1_btndown_cb = lambda do |ih, angle|
403
+ ii = tabs_get_index()
404
+
405
+ @plot[ii].old_ymin = @plot[ii].axs_ymin
406
+ @plot[ii].old_ymax = @plot[ii].axs_ymax
407
+
408
+ Iup::DEFAULT
409
+ end
410
+
411
+ dial1_btnup_cb = lambda do |ih, angle|
412
+ ii = tabs_get_index()
413
+
414
+ x1 = @plot[ii].old_ymin.to_f
415
+ x2 = @plot[ii].old_ymax.to_f
416
+
417
+ ss = @plot[ii].axs_ymode
418
+ if ( ss && ss[3,1]=='2' )
419
+ # LOG2: one circle will zoom 2 times
420
+ xm = 4.0 * fabs(angle) / 3.141592
421
+ if (angle>0.0)
422
+ x2 /= xm
423
+ x1 *= xm
424
+ else
425
+ x2 *= xm
426
+ x1 /= xm
427
+ end
428
+ end
429
+ if ( ss && ss[3,1]=='1' )
430
+ # LOG10: one circle will zoom 10 times
431
+ xm = 10.0 * fabs(angle) / 3.141592
432
+ if (angle>0.0)
433
+ x2 /= xm
434
+ x1 *= xm
435
+ else
436
+ x2 *= xm
437
+ x1 /= xm
438
+ end
439
+ else
440
+ # LIN: one circle will zoom 2 times
441
+ xm = (x1 + x2) / 2.0
442
+ x1 = xm - (xm - x1)*(1.0-angle*1.0/3.141592)
443
+ x2 = xm + (x2 - xm)*(1.0-angle*1.0/3.141592)
444
+ end
445
+
446
+ if (x1<x2)
447
+ @plot[ii].axs_ymin = x1
448
+ @plot[ii].axs_ymax = x2
449
+ end
450
+ @plot[ii].redraw = nil
451
+
452
+ return Iup::DEFAULT
453
+ end
454
+
455
+
456
+ # X zoom
457
+ dial2_btndown_cb = lambda do |ih, angle|
458
+ ii = tabs_get_index()
459
+
460
+ @plot[ii].old_xmin = @plot[ii].axs_xmin
461
+ @plot[ii].old_xmax = @plot[ii].axs_xmax
462
+
463
+ Iup::DEFAULT
464
+ end
465
+
466
+ dial2_btnup_cb = lambda do |ih, angle|
467
+ ii = tabs_get_index()
468
+
469
+ x1 = @plot[ii].old_xmin.to_f
470
+ x2 = @plot[ii].old_xmax.to_f
471
+
472
+ xm = (x1 + x2) / 2.0
473
+
474
+ x1 = xm - (xm - x1)*(1.0-angle*1.0/3.141592) # one circle will zoom 2 times
475
+ x2 = xm + (x2 - xm)*(1.0-angle*1.0/3.141592)
476
+
477
+ @plot[ii].axs_xmin = x1
478
+ @plot[ii].axs_xmax = x2
479
+
480
+ @plot[ii].redraw = nil
481
+
482
+ Iup::DEFAULT
483
+ end
484
+
485
+ bt1_cb = lambda do |ih|
486
+ p "bt1_cb"
487
+ ii = tabs_get_index()
488
+ # cnv = Cd.CreateCanvas(Cd.ContextPDF(), "pplot.pdf -o")
489
+ # Iup.PPlotPaintTo(@plot[ii], cnv)
490
+ # Cd.KillCanvas(cnv)
491
+ Iup::DEFAULT
492
+ end
493
+
494
+
495
+ @plot = Array.new(MAXPLOT)
496
+ # create plots
497
+ for ii in 0...MAXPLOT
498
+ @plot[ii] = Iup.PPlot()
499
+ end
500
+
501
+ # left panel: @plot control
502
+ # Y zooming
503
+ @dial1 = Iup.Dial("VERTICAL")
504
+ lbl1 = Iup.Label("+")
505
+ lbl2 = Iup.Label("-")
506
+ boxinfo = Iup.Vbox([lbl1, Iup.Fill(),lbl2])
507
+ boxdial1 = Iup.Hbox([boxinfo, @dial1])
508
+
509
+ boxdial1.align = "ACENTER"
510
+ boxinfo.align = "ACENTER"
511
+ boxinfo.size = "20x52"
512
+ boxinfo.gap = 2
513
+ boxinfo.margin = 4
514
+ boxinfo.expand = "YES"
515
+ lbl1.expand = "NO"
516
+ lbl2.expand = "NO"
517
+
518
+ @dial1.active = "NO"
519
+ @dial1.size = "20x52"
520
+ @dial1.button_press_cb = dial1_btndown_cb
521
+ @dial1.mousemove_cb = dial1_btnup_cb
522
+ @dial1.button_release_cb = dial1_btnup_cb
523
+
524
+ @tgg1 = Iup.Toggle("Y Autoscale")
525
+ @tgg1.action = tgg1_cb
526
+ @tgg1.value = "ON"
527
+
528
+ f1 = Iup.Frame( Iup.Vbox([boxdial1, @tgg1]),:title=> "Y Zoom" )
529
+
530
+ # X zooming
531
+ @dial2 = Iup.Dial("HORIZONTAL")
532
+ lbl1 = Iup.Label("-")
533
+ lbl2 = Iup.Label("+")
534
+ boxinfo = Iup.Hbox([lbl1, Iup.Fill(), lbl2])
535
+ boxdial2 = Iup.Vbox([@dial2, boxinfo])
536
+
537
+ boxdial2.align = "ACENTER"
538
+ boxinfo.align = "ACENTER"
539
+ boxinfo.size = "64x16"
540
+ boxinfo.gap = 2
541
+ boxinfo.margin = 4
542
+ boxinfo.expand = "HORIZONTAL"
543
+
544
+ lbl1.expand = "NO"
545
+ lbl2.expand = "NO"
546
+
547
+ @dial2.active = "NO"
548
+ @dial2.size = "64x16"
549
+ @dial2.button_press_cb = dial2_btndown_cb
550
+ @dial2.mousemove_cb = dial2_btnup_cb
551
+ @dial2.button_release_cb = dial2_btnup_cb
552
+
553
+ @tgg2 = Iup.Toggle("X Autoscale")
554
+ @tgg2.action = tgg2_cb
555
+
556
+ f2 = Iup.Frame( Iup.Vbox([boxdial2, @tgg2]),:title=> "X Zoom")
557
+
558
+ lbl1 = Iup.Label(:title=>"",:separator=>"HORIZONTAL")
559
+
560
+ @tgg3 = Iup.Toggle("Vertical Grid")
561
+ @tgg3.action = tgg3_cb
562
+
563
+ @tgg4 = Iup.Toggle("Hirozontal Grid")
564
+ @tgg4.action = tgg4_cb
565
+
566
+ lbl2 = Iup.Label(:title=>"",:separator=>"HORIZONTAL")
567
+
568
+ @tgg5 = Iup.Toggle("Legend", nil)
569
+ @tgg5.action = tgg5_cb
570
+
571
+ lbl3 = Iup.Label(:title=>"",:separator=>"HORIZONTAL")
572
+
573
+ bt1 = Iup.Button("Export PDF")
574
+ bt1.action = bt1_cb
575
+
576
+ vboxl = Iup.Vbox([f1, f2, lbl1, @tgg3, @tgg4, lbl2, @tgg5, lbl3, bt1],:gap=>4,:expand=>"NO")
577
+
578
+ vboxr = Array.new(MAXPLOT) # tabs containing the plots
579
+ # right panel: tabs with plots
580
+ for ii in 0...MAXPLOT
581
+ vboxr[ii] = Iup.Vbox([@plot[ii]]) # each @plot a tab
582
+ vboxr[ii].tabtitle = "Plot #{ii}"
583
+ end
584
+
585
+ @tabs = Iup.Tabs(vboxr) # create tabs
586
+ @tabs.tabchange_cb = tabs_tabchange_cb
587
+
588
+ # dialog
589
+ hbox = Iup.Hbox([vboxl, @tabs],:margin =>"4x4",:gap=>10)
590
+
591
+ dlg = Iup.Dialog(hbox,:size=>"600x240",:title=>"IupPPlot Example")
592
+
593
+ InitPlots() # It must be able to be done independent of dialog Mapping
594
+
595
+ #tabs_tabchange_cb.call(@tabs, vboxr[0], 0)
596
+
597
+ dlg.ShowXY(Iup::CENTER, Iup::CENTER)
598
+ Iup.MainLoop
599
+ dlg.Destroy
600
+ end
601
+ end
602
+
603
+ plot = IupPlotTest.new