-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathIGraphicMode.java
158 lines (117 loc) · 5.52 KB
/
IGraphicMode.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*---
iGeo - http://igeo.jp
Copyright (c) 2002-2013 Satoru Sugihara
This file is part of iGeo.
iGeo is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, version 3.
iGeo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with iGeo. If not, see <http://www.gnu.org/licenses/>.
---*/
package igeo.gui;
import igeo.IConfig;
/**
Class to specify graphic mode of either OpenGL mode / Java mode and
wireframe / fill / transparent fill / wireframe+fill / wireframe+transparent fill.
@author Satoru Sugihara
*/
public class IGraphicMode{
public enum GraphicType{ GL, P3D, J2D };
//public enum DisplayType{ WIREFRAME, FILL, TRANSPARENT }
//public static final IGraphicMode glWire = new IGraphicMode(GraphicType.GL,DisplayType.WIREFRAME);
//public static final IGraphicMode glFill = new IGraphicMode(GraphicType.GL,DisplayType.FILL);
//public static final IGraphicMode glTrans = new IGraphicMode(GraphicType.GL,DisplayType.TRANSPARENT);
//public static final IGraphicMode javaWire = new IGraphicMode(GraphicType.JAVA,DisplayType.WIREFRAME);
//public static final IGraphicMode javaFill = new IGraphicMode(GraphicType.JAVA,DisplayType.FILL);
//public static final IGraphicMode javaTrans = new IGraphicMode(GraphicType.JAVA,DisplayType.TRANSPARENT);
public GraphicType graphicType;
//public DisplayType displayType;
public boolean wireframe=true;
public boolean fill=true;
public boolean transparent=true;
/** if transparentWireframe is false, wireframe doesn't become transparent in transparent mode
*/
public boolean transparentWireframe = IConfig.transparentWireframe;
/** if lightWireframe is false, wireframe doesn't use material in GL light mode
*/
public boolean lightWireframe = IConfig.lightWireframe;
public boolean light = IConfig.useLight; // only in OpenGL
public IGraphicMode(){}
//public IGraphicMode(GraphicType g, DisplayType d){ graphicType=g; displayType=d; }
public IGraphicMode(GraphicType g){ graphicType=g; }
public IGraphicMode(GraphicType g, boolean enableFill, boolean enableWireframe,
boolean enableTransparent){
graphicType=g;
fill=enableFill;
wireframe=enableWireframe;
transparent=enableTransparent;
}
public IGraphicMode(IGraphicMode m){
graphicType = m.graphicType;
fill = m.fill;
wireframe = m.wireframe;
transparent = m.transparent;
transparentWireframe = m.transparentWireframe;
lightWireframe = m.lightWireframe;
light = m.light;
}
public void setGraphicType(GraphicType g){ graphicType=g; }
//public void setDisplayType(DisplayType d){ displayType=d; }
public GraphicType getGraphicType(){ return graphicType; }
//public DisplayType getDisplayType(){ return displayType; }
public boolean isGL(){ return graphicType==GraphicType.GL; }
//public boolean isJava(){ return graphicType==GraphicType.JAVA; }
public boolean isJ2D(){ return graphicType==GraphicType.J2D; }
public boolean isP3D(){ return graphicType==GraphicType.P3D; }
/** 3D graphic elements keeping 3D info; no need to be sorted due to depth buffer */
public boolean isGraphic3D(){
return graphicType==GraphicType.GL || graphicType==GraphicType.P3D;
}
/** 2D graphic elements already flattened in 2D; need to be sorted and vary depending on view */
public boolean isGraphic2D(){
return graphicType==GraphicType.P3D;
}
//public boolean isWireframe(){ return displayType==DisplayType.WIREFRAME; }
//public boolean isFill(){ return displayType==DisplayType.FILL; }
//public boolean isTransparent(){ return displayType==DisplayType.TRANSPARENT; }
public boolean isWireframe(){ return wireframe; }
public boolean isFill(){ return fill; }
public boolean isTransparent(){ return transparent; }
public boolean isNone(){ return !wireframe&&!fill&&!transparent; }
public boolean isLight(){ return light; }
public boolean isTransparentWireframe(){ return transparentWireframe; }
public boolean isLightWireframe(){ return lightWireframe; }
public void setDrawMode(boolean wireframe, boolean fill, boolean transparent){
this.wireframe=wireframe;
this.fill=fill;
this.transparent=transparent;
}
public void toggleWireframe(){
// either of wireframe or fill needs to stay true
if(!wireframe || fill) wireframe = !wireframe;
}
public void toggleFill(){
// either of wireframe or fill needs to stay true
if(!fill || wireframe) fill = !fill;
}
public void toggleTransparent(){ transparent = !transparent; }
public void enableLight(){ light=true; }
public void disableLight(){ light=false; }
public static IGraphicMode[] getAllModes(){
GraphicType[] g = GraphicType.values();
IGraphicMode[] ret = new IGraphicMode[g.length];
for(int i=0; i<g.length; i++) ret[i] = new IGraphicMode(g[i]);
/*
DisplayType[] d = DisplayType.values();
IGraphicMode[] ret = new IGraphicMode[g.length*d.length];
for(int i=0; i<g.length; i++)
for(int j=0; j<d.length; j++)
ret[i*d.length+j] = new IGraphicMode(g[i], d[j]);
*/
return ret;
}
}