2 * Grace - GRaphing, Advanced Computation and Exploration of data
4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/
6 * Copyright (c) 1991-1995 Paul J Turner, Portland, OR
7 * Copyright (c) 1996-2003 Grace Development Team
9 * Maintained by Evgeny Stambulchik
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 * arrange graphs popup
32 * overlay graphs popup
44 #include "core_utils.h"
50 static int define_arrange_proc(void *data
);
51 static int define_autos_proc(void *data
);
53 typedef struct _Arrange_ui
{
55 StorageStructure
*frames
;
58 OptionStructure
*order
;
74 * Arrange frames popup routines
76 static int define_arrange_proc(void *data
)
78 Arrange_ui
*ui
= (Arrange_ui
*) data
;
81 int nrows
, ncols
, order
, snake
;
82 int hpack
, vpack
, add
, kill
;
83 double toff
, loff
, roff
, boff
, vgap
, hgap
;
85 nrows
= (int) GetSpinChoice(ui
->nrows
);
86 ncols
= (int) GetSpinChoice(ui
->ncols
);
87 if (nrows
< 1 || ncols
< 1) {
88 errmsg("# of rows and columns must be > 0");
89 return RETURN_FAILURE
;
92 nframes
= GetStorageChoices(ui
->frames
, &frames
);
97 order
= GetOptionChoice(ui
->order
);
98 snake
= GetToggleButtonState(ui
->snake
);
100 toff
= GetSpinChoice(ui
->toff
);
101 loff
= GetSpinChoice(ui
->loff
);
102 roff
= GetSpinChoice(ui
->roff
);
103 boff
= GetSpinChoice(ui
->boff
);
105 hgap
= GetSpinChoice(ui
->hgap
);
106 vgap
= GetSpinChoice(ui
->vgap
);
108 add
= GetToggleButtonState(ui
->add
);
109 kill
= GetToggleButtonState(ui
->kill
);
111 hpack
= GetToggleButtonState(ui
->hpack
);
112 vpack
= GetToggleButtonState(ui
->vpack
);
114 if (add
&& nframes
< nrows
*ncols
) {
116 frames
= xrealloc(frames
, nrows
*ncols
*sizeof(Quark
*));
117 for (i
= number_of_frames(grace
->project
); nframes
< nrows
*ncols
; nframes
++, i
++) {
118 frames
[nframes
] = frame_new(grace
->project
);
122 if (kill
&& nframes
> nrows
*ncols
) {
123 for (; nframes
> nrows
*ncols
; nframes
--) {
124 quark_free(frames
[nframes
- 1]);
128 arrange_frames(frames
, nframes
,
129 nrows
, ncols
, order
, snake
,
130 loff
, roff
, toff
, boff
, vgap
, hgap
,
135 SelectStorageChoices(ui
->frames
, nframes
, frames
);
138 xdrawgraph(grace
->project
, FALSE
);
140 return RETURN_SUCCESS
;
143 void hpack_cb(Widget but
, int onoff
, void *data
)
145 Arrange_ui
*ui
= (Arrange_ui
*) data
;
146 SetSensitive(ui
->hgap
->rc
, !onoff
);
148 void vpack_cb(Widget but
, int onoff
, void *data
)
150 Arrange_ui
*ui
= (Arrange_ui
*) data
;
151 SetSensitive(ui
->vgap
->rc
, !onoff
);
154 void create_arrange_frame(Widget but
, void *data
)
156 static Arrange_ui
*ui
= NULL
;
160 Widget arrange_panel
, fr
, gr
, rc
;
161 BitmapOptionItem opitems
[8] = {
162 {0 | 0 | 0 , m_hv_lr_tb_bits
},
163 {0 | 0 | GA_ORDER_V_INV
, m_hv_lr_bt_bits
},
164 {0 | GA_ORDER_H_INV
| 0 , m_hv_rl_tb_bits
},
165 {0 | GA_ORDER_H_INV
| GA_ORDER_V_INV
, m_hv_rl_bt_bits
},
166 {GA_ORDER_HV_INV
| 0 | 0 , m_vh_lr_tb_bits
},
167 {GA_ORDER_HV_INV
| 0 | GA_ORDER_V_INV
, m_vh_lr_bt_bits
},
168 {GA_ORDER_HV_INV
| GA_ORDER_H_INV
| 0 , m_vh_rl_tb_bits
},
169 {GA_ORDER_HV_INV
| GA_ORDER_H_INV
| GA_ORDER_V_INV
, m_vh_rl_bt_bits
}
172 ui
= xmalloc(sizeof(Arrange_ui
));
174 ui
->top
= CreateDialogForm(app_shell
, "Arrange frames");
175 AddHelpCB(ui
->top
, "doc/UsersGuide.html#arrange-frames");
177 arrange_panel
= CreateVContainer(ui
->top
);
179 fr
= CreateFrame(arrange_panel
, NULL
);
180 rc
= CreateVContainer(fr
);
181 ui
->frames
= CreateFrameChoice(rc
,
182 "Arrange frames:", LIST_TYPE_MULTIPLE
);
183 ui
->add
= CreateToggleButton(rc
,
184 "Add frames as needed to fill the matrix");
185 ui
->kill
= CreateToggleButton(rc
, "Kill extra frames");
187 fr
= CreateFrame(arrange_panel
, "Matrix");
188 gr
= CreateGrid(fr
, 4, 1);
189 ui
->ncols
= CreateSpinChoice(gr
,
190 "Cols:", 2, SPIN_TYPE_INT
, (double) 1, (double) 99, (double) 1);
191 PlaceGridChild(gr
, ui
->ncols
->rc
, 0, 0);
192 ui
->nrows
= CreateSpinChoice(gr
,
193 "Rows:", 2, SPIN_TYPE_INT
, (double) 1, (double) 99, (double) 1);
194 PlaceGridChild(gr
, ui
->nrows
->rc
, 1, 0);
195 ui
->order
= CreateBitmapOptionChoice(gr
,
196 "Order:", 2, 8, MBITMAP_WIDTH
, MBITMAP_HEIGHT
, opitems
);
197 PlaceGridChild(gr
, ui
->order
->menu
, 2, 0);
198 rc
= CreateHContainer(gr
);
199 ui
->snake
= CreateToggleButton(rc
, "Snake fill");
200 PlaceGridChild(gr
, rc
, 3, 0);
202 fr
= CreateFrame(arrange_panel
, "Page offsets");
203 gr
= CreateGrid(fr
, 3, 3);
204 ui
->toff
= CreateSpinChoice(gr
, "", 4, SPIN_TYPE_FLOAT
, 0.0, 1.0, 0.05);
205 PlaceGridChild(gr
, ui
->toff
->rc
, 1, 0);
206 ui
->loff
= CreateSpinChoice(gr
, "", 4, SPIN_TYPE_FLOAT
, 0.0, 1.0, 0.05);
207 PlaceGridChild(gr
, ui
->loff
->rc
, 0, 1);
208 ui
->roff
= CreateSpinChoice(gr
, "", 4, SPIN_TYPE_FLOAT
, 0.0, 1.0, 0.05);
209 PlaceGridChild(gr
, ui
->roff
->rc
, 2, 1);
210 ui
->boff
= CreateSpinChoice(gr
, "", 4, SPIN_TYPE_FLOAT
, 0.0, 1.0, 0.05);
211 PlaceGridChild(gr
, ui
->boff
->rc
, 1, 2);
213 fr
= CreateFrame(arrange_panel
, "Spacing");
214 gr
= CreateGrid(fr
, 2, 1);
215 rc
= CreateHContainer(gr
);
216 ui
->hgap
= CreateSpinChoice(rc
,
217 "Hgap/width", 3, SPIN_TYPE_FLOAT
, 0.0, 9.0, 0.1);
218 ui
->hpack
= CreateToggleButton(rc
, "Pack");
219 AddToggleButtonCB(ui
->hpack
, hpack_cb
, ui
);
220 PlaceGridChild(gr
, rc
, 0, 0);
221 rc
= CreateHContainer(gr
);
222 ui
->vgap
= CreateSpinChoice(rc
,
223 "Vgap/height", 3, SPIN_TYPE_FLOAT
, 0.0, 9.0, 0.1);
224 ui
->vpack
= CreateToggleButton(rc
, "Pack");
225 AddToggleButtonCB(ui
->vpack
, vpack_cb
, ui
);
226 PlaceGridChild(gr
, rc
, 1, 0);
228 CreateAACDialog(ui
->top
, arrange_panel
, define_arrange_proc
, ui
);
230 SetSpinChoice(ui
->nrows
, (double) 1);
231 SetSpinChoice(ui
->ncols
, (double) 1);
233 SetSpinChoice(ui
->toff
, GA_OFFSET_DEFAULT
);
234 SetSpinChoice(ui
->loff
, GA_OFFSET_DEFAULT
);
235 SetSpinChoice(ui
->roff
, GA_OFFSET_DEFAULT
);
236 SetSpinChoice(ui
->boff
, GA_OFFSET_DEFAULT
);
238 SetSpinChoice(ui
->hgap
, GA_GAP_DEFAULT
);
239 SetSpinChoice(ui
->vgap
, GA_GAP_DEFAULT
);
241 SetToggleButtonState(ui
->add
, TRUE
);
244 RaiseWindow(GetParent(ui
->top
));
252 typedef struct _Auto_ui
{
254 GraphSetStructure
*sel
;
255 OptionStructure
*astype
;
258 static int define_autos_proc(void *data
)
261 Auto_ui
*ui
= (Auto_ui
*) data
;
264 nsets
= GetStorageChoices(ui
->sel
->set_sel
, &sets
);
266 errmsg("No sets selected");
267 return RETURN_FAILURE
;
270 astype
= GetOptionChoice(ui
->astype
);
272 autoscale_bysets(sets
, nsets
, astype
);
277 xdrawgraph(grace
->project
, FALSE
);
279 return RETURN_SUCCESS
;
282 void create_autos_frame(Widget but
, void *data
)
284 static Auto_ui
*aui
= NULL
;
291 aui
= xmalloc(sizeof(Auto_ui
));
293 aui
->top
= CreateDialogForm(app_shell
, "Autoscale graphs");
295 rc
= CreateVContainer(aui
->top
);
296 aui
->sel
= CreateGraphSetSelector(rc
, NULL
, LIST_TYPE_MULTIPLE
);
297 aui
->astype
= CreateASChoice(rc
, "Autoscale type:");
299 CreateAACDialog(aui
->top
, rc
, define_autos_proc
, aui
);
302 RaiseWindow(GetParent(aui
->top
));