1 /*
2   Teem: Tools to process and visualize scientific data and images             .
3   Copyright (C) 2012, 2011, 2010, 2009  University of Chicago
4   Copyright (C) 2008, 2007, 2006, 2005  Gordon Kindlmann
5   Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998  University of Utah
6 
7   This library is free software; you can redistribute it and/or
8   modify it under the terms of the GNU Lesser General Public License
9   (LGPL) as published by the Free Software Foundation; either
10   version 2.1 of the License, or (at your option) any later version.
11   The terms of redistributing and/or modifying this software also
12   include exceptions to the LGPL that facilitate static linking.
13 
14   This library is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17   Lesser General Public License for more details.
18 
19   You should have received a copy of the GNU Lesser General Public License
20   along with this library; if not, write to Free Software Foundation, Inc.,
21   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 */
23 
24 
25 #include "limn.h"
26 
27 limnLight *
limnLightNew(void)28 limnLightNew(void) {
29   limnLight *lit;
30 
31   lit = (limnLight *)calloc(1, sizeof(limnLight));
32   return lit;
33 }
34 
35 limnLight *
limnLightNix(limnLight * lit)36 limnLightNix(limnLight *lit) {
37 
38   if (lit) {
39     free(lit);
40   }
41   return NULL;
42 }
43 
44 void
limnCameraInit(limnCamera * cam)45 limnCameraInit(limnCamera *cam) {
46 
47   if (cam) {
48     cam->atRelative = limnDefCameraAtRelative;
49     cam->orthographic = limnDefCameraOrthographic;
50     cam->rightHanded = limnDefCameraRightHanded;
51     cam->uRange[0] = cam->uRange[1] = AIR_NAN;
52     cam->vRange[0] = cam->vRange[1] = AIR_NAN;
53     cam->fov = AIR_NAN;
54     cam->aspect = AIR_NAN;
55   }
56   return;
57 }
58 
59 limnCamera *
limnCameraNew(void)60 limnCameraNew(void) {
61   limnCamera *cam;
62 
63   cam = (limnCamera *)calloc(1, sizeof(limnCamera));
64   if (cam) {
65     limnCameraInit(cam);
66   }
67   return cam;
68 }
69 
70 limnCamera *
limnCameraNix(limnCamera * cam)71 limnCameraNix(limnCamera *cam) {
72 
73   if (cam) {
74     free(cam);
75   }
76   return NULL;
77 }
78 
79 void
_limnOptsPSDefaults(limnOptsPS * ps)80 _limnOptsPSDefaults(limnOptsPS *ps) {
81 
82   ps->lineWidth[limnEdgeTypeUnknown] = AIR_NAN;
83   ps->lineWidth[limnEdgeTypeBackFacet] = 0.0;
84   ps->lineWidth[limnEdgeTypeBackCrease] = 0.0;
85   ps->lineWidth[limnEdgeTypeContour] = 2.0;
86   ps->lineWidth[limnEdgeTypeFrontCrease] = 1.0;
87   ps->lineWidth[limnEdgeTypeFrontFacet] = 0.0;
88   ps->lineWidth[limnEdgeTypeBorder] = 1.0;
89   ps->lineWidth[limnEdgeTypeLone] = 1.0;
90   ps->creaseAngle = 46;
91   ps->showpage = AIR_FALSE;
92   ps->wireFrame = AIR_FALSE;
93   ps->noBackground = AIR_FALSE;
94   ELL_3V_SET(ps->bg, 1, 1, 1);
95   ELL_3V_SET(ps->edgeColor, 0, 0, 0);
96 }
97 
98 limnWindow *
limnWindowNew(int device)99 limnWindowNew(int device) {
100   limnWindow *win;
101 
102   win = (limnWindow *)calloc(1, sizeof(limnWindow));
103   if (win) {
104     win->device = device;
105     switch(device) {
106     case limnDevicePS:
107       win->yFlip = 1;
108       _limnOptsPSDefaults(&(win->ps));
109       break;
110     }
111     win->scale = 72;
112     win->file = NULL;
113   }
114   return win;
115 }
116 
117 limnWindow *
limnWindowNix(limnWindow * win)118 limnWindowNix(limnWindow *win) {
119 
120   if (win) {
121     free(win);
122   }
123   return NULL;
124 }
125