1 /*
2 * RenderApp.cpp
3 *
4 * Copyright (C) 1999 Stephen F. White
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program (see the file "COPYING" for details); if
18 * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19 * Cambridge, MA 02139, USA.
20 */
21
22 #include "stdafx.h"
23 #include "swt.h"
24 #include "RenderApp.h"
25 #include "DuneApp.h"
26
27 #define DEFAULT_NEAR_CLIPPING_PLANE_DIST 0.05f
28 #define DEFAULT_FAR_CLIPPING_PLANE_DIST 7000.0f
29 #define DEFAULT_MAX_INLINES_TO_LOAD 1024
30 #define DEFAULT_MAX_KEYS_IN_CHANNELVIEW 64
31
RenderApp()32 RenderApp::RenderApp()
33 {
34 RenderDefaults();
35 }
36
37 void
RenderLoadPreferences()38 RenderApp::RenderLoadPreferences()
39 {
40 m_showAllFields = TheApp->GetBoolPreference("ShowAllFields", false);
41 const char* pointSetSizeBuf = TheApp->GetPreference("PointSetSize", "0.0");
42 m_pointSetSize = atof(pointSetSizeBuf);
43 char buf[128];
44 const char *buf2;
45 mysnprintf(buf, 127, "%f", DEFAULT_NEAR_CLIPPING_PLANE_DIST);
46 buf2 = TheApp->GetPreference("NearClippingPlaneDistance", buf);
47 if (atof(buf2) > 0)
48 m_nearClippingPlaneDist = atof(buf2);
49 else {
50 m_nearClippingPlaneDist = DEFAULT_NEAR_CLIPPING_PLANE_DIST;
51 swDebugf("NearClippingPlaneDistance preference");
52 swDebugf(" must be greater zero\n");
53 swDebugf("NearClippingPlaneDistance preference set to %f\n",
54 m_nearClippingPlaneDist);
55 }
56 mysnprintf(buf, 127, "%f", DEFAULT_FAR_CLIPPING_PLANE_DIST);
57 buf2 = TheApp->GetPreference("FarClippingPlaneDistance", buf);
58 if (atof(buf2) > m_nearClippingPlaneDist)
59 m_farClippingPlaneDist = atof(buf2);
60 else {
61 m_nearClippingPlaneDist = DEFAULT_NEAR_CLIPPING_PLANE_DIST;
62 m_farClippingPlaneDist = DEFAULT_FAR_CLIPPING_PLANE_DIST;
63 swDebugf("FarClippingPlaneDistance preference");
64 swDebugf(" must be greater than NearClippingPlaneDistance preference\n");
65 swDebugf("FarClippingPlaneDistance preference set to %f\n",
66 m_farClippingPlaneDist);
67 swDebugf("NearClippingPlaneDistance preference set to %f\n",
68 m_nearClippingPlaneDist);
69 }
70 m_maxInlinesToLoad = TheApp->GetIntPreference("MaxInlinesToLoad",
71 DEFAULT_MAX_INLINES_TO_LOAD);
72 m_maxKeysInChannelView = TheApp->GetIntPreference("MaxKeysInChannelView",
73 DEFAULT_MAX_KEYS_IN_CHANNELVIEW);
74 }
75
76 void
RenderDefaults()77 RenderApp::RenderDefaults()
78 {
79 m_showAllFields = false;
80 m_pointSetSize = 0.0;
81 m_nearClippingPlaneDist = DEFAULT_NEAR_CLIPPING_PLANE_DIST;
82 m_farClippingPlaneDist = DEFAULT_FAR_CLIPPING_PLANE_DIST;
83 m_maxInlinesToLoad = DEFAULT_MAX_INLINES_TO_LOAD;
84 m_maxKeysInChannelView = DEFAULT_MAX_KEYS_IN_CHANNELVIEW;
85 }
86
87
RenderSavePreferences()88 void RenderApp::RenderSavePreferences()
89 {
90 char buf[128];
91 TheApp->SetBoolPreference("ShowAllFields", m_showAllFields);
92 mysnprintf(buf, 127, "%f", m_nearClippingPlaneDist);
93 TheApp->SetPreference("NearClippingPlaneDistance", buf);
94 mysnprintf(buf, 127, "%f", m_farClippingPlaneDist);
95 TheApp->SetPreference("FarClippingPlaneDistance", buf);
96 TheApp->SetIntPreference("MaxInlinesToLoad", m_maxInlinesToLoad);
97 TheApp->SetIntPreference("MaxKeysInChannelView", m_maxKeysInChannelView);
98 }
99
SetShowAllFields(bool showAllFields)100 void RenderApp::SetShowAllFields(bool showAllFields)
101 {
102 if (m_showAllFields != showAllFields) {
103 m_showAllFields = showAllFields;
104 TheApp->UpdateAllWindows();
105 }
106 }
107
SetPointSetSize(float size)108 void RenderApp::SetPointSetSize(float size)
109 {
110 m_pointSetSize = size;
111 TheApp->UpdateAllWindows();
112 }
113
114