2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2006 - ENPC - Jean-Philipe Chancelier
4 * Copyright (C) 2006 - INRIA - Fabrice Leray
5 * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
6 * Copyright (C) 2011 - DIGITEO - Bruno JOFRET
8 * This file must be used under the terms of the CeCILL.
9 * This source file is licensed as described in the file COPYING, which
10 * you should have received as part of this distribution. The terms
11 * are also available at
12 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
16 /*------------------------------------------------------------------------*/
17 /* file: sci_xrects.c */
18 /* desc : interface for xrects routine */
19 /*------------------------------------------------------------------------*/
21 #include "gw_graphics.h"
23 #include "BuildObjects.h"
25 #include "DrawObjects.h"
26 #include "GetProperty.h"
27 #include "localization.h"
29 #include "HandleManagement.h"
31 #include "createGraphicObject.h"
32 #include "setGraphicObjectProperty.h"
33 #include "getGraphicObjectProperty.h"
34 #include "graphicObjectProperties.h"
35 #include "CurrentObject.h"
36 /*--------------------------------------------------------------------------*/
37 int sci_xrects( char *fname, unsigned long fname_len )
39 int m1 = 0, n1 = 0, l1 = 0, m2 = 0, n2 = 0, l2 = 0;
42 char* psubwinUID = NULL;
45 int *piForeground = &foreground;
46 char *pstCompoundUID = NULL;
50 GetRhsVar(1, MATRIX_OF_DOUBLE_DATATYPE, &m1, &n1, &l1);
54 Scierror(999, _("%s: Wrong size for input argument #%d: %s expected.\n"), fname, 1, "(4,n)");
61 GetRhsVar(2, MATRIX_OF_INTEGER_DATATYPE, &m2, &n2, &l2);
62 CheckVector(2, m2, n2);
65 Scierror(999, _("%s: Incompatible length for input arguments #%d and #%d.\n"), fname, 1, 2);
72 CreateVar(2, MATRIX_OF_INTEGER_DATATYPE, &m2, &n2, &l2);
73 for (i = 0; i < n2; ++i)
79 psubwinUID = (char*)getOrCreateDefaultSubwin();
82 pstCompoundUID = createGraphicObject(__GO_COMPOUND__);
83 /* Sets the parent-child relationship for the Compound */
84 setGraphicObjectRelationship(psubwinUID, pstCompoundUID);
86 /** Get Subwin line color */
87 getGraphicObjectProperty(psubwinUID, __GO_LINE_COLOR__, jni_int, (void**)&piForeground);
89 for (i = 0; i < n1; ++i)
91 /* j = (i==0) ? 0 : 1; */
92 if (*istk(l2 + i) == 0)
94 /** fil(i) = 0 rectangle i is drawn using the current line style (or color).**/
95 /* color setting is done now */
97 Objrect(stk(l1 + (4 * i)), stk(l1 + (4 * i) + 1), stk(l1 + (4 * i) + 2), stk(l1 + (4 * i) + 3),
98 &foreground, NULL, FALSE, TRUE, &hdl);
102 if (*istk(l2 + i) < 0)
104 /** fil(i) < 0 rectangle i is drawn using the line style (or color) **/
105 int tmp = - (*istk(l2 + i));
106 Objrect(stk(l1 + (4 * i)), stk(l1 + (4 * i) + 1), stk(l1 + (4 * i) + 2), stk(l1 + (4 * i) + 3),
107 &tmp, NULL, FALSE, TRUE, &hdl);
111 /** fil(i) > 0 rectangle i is filled using the pattern (or color) **/
112 Objrect(stk(l1 + (4 * i)), stk(l1 + (4 * i) + 1), stk(l1 + (4 * i) + 2), stk(l1 + (4 * i) + 3),
113 NULL, istk(l2 + i), TRUE, FALSE, &hdl);
116 // Add newly created object to Compound
117 setGraphicObjectRelationship(pstCompoundUID, getObjectFromHandle(hdl));
120 /** make Compound current object **/
121 setCurrentObject(pstCompoundUID);
127 /*--------------------------------------------------------------------------*/