1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License as
4 * published by the Free Software Foundation; either version 2 of the
5 * License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOUSE. See the GNU
10 * General Public License for more details.
11 *
12 * You should have recieved a copy of the GNU General Public License
13 * along with this program; if not write to the Free Software
14 * Foundation, inc., 59 Temple Place, Suite 330, Boston MA 02111-1307
15 * USA
16 */
17 package j3d;
18
19
20 import java.awt.*;
21 import java.awt.event.*;
22 import java.awt.image.*;
23 import java.io.*;
24 import java.nio.IntBuffer;
25 import java.util.*;
26
27 import javax.media.opengl.*;
28 import javax.media.opengl.glu.GLU;
29 import javax.media.opengl.glu.GLUquadric;
30 import javax.swing.*;
31 import javax.swing.tree.*;
32
33 import com.sun.opengl.util.j2d.*;
34 import com.sun.opengl.util.BufferUtil;
35
36 import gui.PreProcessor;
37 import util.PngEncoderB;
38
39 /**
40 * Insert the type's description here.
41 *
42 * @author: Yuriy Mikhaylovskiy, Jonas Forssell
43 */
44 public class Canvas3DGL extends GLCanvas implements GLEventListener, Canvas3D, Serializable {
45 private DefaultMutableTreeNode treeNode = new DefaultMutableTreeNode();
46 public DefaultTreeModel tree3d = new DefaultTreeModel(treeNode);
47 boolean painted = false;
48 private Vector obj3d = new Vector();
49 private Vector shp3d = new Vector();
50 private int id_obj3d=0;
51 public Matrix3D VMatrix3D = new Matrix3D();
52 public Vector3D center_of_rotation = new Vector3D();
53 public JLabel coodinates = new JLabel();
54 private int x,y,x0,y0;
55 private float screenwidth, screenheight, aspw, asph;
56 private PreProcessor pre;
57 private boolean show = true;
58 //
59 public boolean DRAFTMODE=false;
60 public Color BGCOLOR = Color.white;
61 public byte GRAPHICSMODE=2;
62 public Color GRIDCOLOR=Color.black;
63 public float GRIDLEVEL=0;
64 public byte GRIDPLANE=0;
65 public boolean GRIDMODE=true;
66 public float GRIDSIZE=10;
67 public float[] LIMITS={0,0,210,297};
68 public byte RENDERMODE=2;
69 public boolean SHOW_ID_NODE=false;
70 public boolean SHOW_ID_ELEMENT=false;
71 public boolean SHOW_ID_CONSTRAINTS=true;
72 public boolean SHOW_ID_LOADS=true;
73 public boolean SHOW_ID_TRACKERS=true;
74 public boolean SHOW_ID_MATERIALS=true;
75 public int POINTSIZE=8;
76 public int NODESIZE=6;
77 public Color STLCOLOR=new Color(0.7f,0.7f,0.7f);
78 private boolean DRAG = false;
79
80 // Codes for handling of geometry
81 public float GeometricTolerance = 0.01f; // Tolerance for calculation of geometry
82 public float NODE_MERGE_TOLERANCE = 1e-3F;
83
84 // OpenGL specific stuff
85 private static int NO_PICK = 0;
86 private static int POINT = 1;
87 private static int BOX = 2;
88
89 private GLU glu = new GLU();
90 private Overlay ovl;
91 private Graphics2D g2D;
92
93 private ArcBall arcBall = new ArcBall(640.0f, 480.0f);
94 private Matrix4f LastRot = new Matrix4f();
95 private Matrix4f ThisRot = new Matrix4f();
96 private final Object matrixLock = new Object();
97 private float[] matrix = new float[16];
98 private GLUquadric quadratic;
99 private float scale = 1.0f;
100 private float transX,transY,transZ;
101 private float left,right,bottom,top,Znear, Zfar;
102 private float aspect = 1.0f;
103 private boolean genlist;
104 private int picking = NO_PICK;
105 private IntBuffer selectBuffer;
106 private int hits = 0;
107 private shp axis = new shpXYZ();
108 //
109 private _Group nodes, elements, geometry;
110
main(String[] args)111 public static void main(String[] args) {
112 JFrame frame = new JFrame("Canvas3DGL Demo");
113
114 final GLCanvas canvas = new Canvas3DGL(null);
115
116 frame.getContentPane().add(canvas);
117 frame.setSize(300, 300);
118 //kill the process when the JFrame is closed
119 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
120
121 frame.show();
122
123 //show what we've done
124 SwingUtilities.invokeLater (
125 new Runnable() {
126 public void run() {
127 canvas.setVisible(true);
128 }
129 }
130 );
131 }
132
133
134
Canvas3DGL(PreProcessor pre)135 public Canvas3DGL(PreProcessor pre) {
136 this.pre = pre;
137 this.setFocusable(false);
138
139 createGroups();
140
141 addComponentListener(new ComponentAdapter() {
142 public void componentResized(ComponentEvent e) {
143 }
144 });
145
146 addGLEventListener(this);
147
148 addMouseListener(new MouseAdapter() {
149
150 public void mousePressed(MouseEvent e) {
151 int mod = e.getModifiers();
152 x=e.getX(); y=e.getY();
153 x0 = x; y0 = y;
154 this_mousePressed(e);
155 }
156
157 public void mouseReleased(MouseEvent e) {
158 int mod = e.getModifiers();
159 if (((mod & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) && DRAG == true) {
160 boxSelect(Math.min(x0,x),Math.min(y0,y),Math.max(x0,x),Math.max(y0,y));
161
162 view_reset();
163 }
164
165 DRAG = false;
166 DRAFTMODE = false;
167
168 view_repaint();
169 }
170
171 public void mouseClicked(MouseEvent e) {
172 int mod = e.getModifiers();
173 if((((mod & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) && ((mod & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK)) || ((mod & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK)){
174 if (!e.isControlDown()) {
175 clearSelectOnAllObjects3D();
176 clearTree();
177 }
178
179 setPickedObject();
180
181 view_reset();
182
183 if (e.getClickCount() == 2)
184 showEditPanel(e);
185
186 requestAction();
187 }
188
189 if(((mod & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK)){
190 view_all();
191 }
192 }
193 });
194
195 addMouseMotionListener(new MouseMotionAdapter() {
196
197 public void mouseMoved(MouseEvent e) {
198 coodinates.setText(e.getX()+","+e.getY());
199 }
200
201 public void mouseDragged(MouseEvent e) {
202 if(e.getModifiers() == MouseEvent.BUTTON1_MASK)
203 DRAG = true;
204 else
205 DRAFTMODE = true;
206 this_mouseDragged(e);
207 }
208 });
209
210
211 view_reset();
212 }
213
214
215
createGroups()216 private void createGroups() {
217 nodes = new _Group(false, true);
218 nodes.setName("Node");
219 this.add3D(nodes);
220
221 elements = new _Group(false, true);
222 elements.setName("Elem");
223 this.add3D(elements);
224
225 geometry = new _Group(false, true);
226 geometry.setName("Geo");
227 this.add3D(geometry);
228 }
229
230
231 // OpenGL initialization method.
init(GLAutoDrawable drawable)232 public void init(GLAutoDrawable drawable) {
233 float[] ambient = {1f, 1f, 1f, 0f};
234 float[] diffuse = {1f, 1f, 1f, 0f};
235
236 GL gl = drawable.getGL();
237 ovl = new Overlay(drawable);
238
239 // Start Of User Initialization
240 LastRot.setIdentity(); // Reset Rotation
241 ThisRot.setIdentity(); // Reset Rotation
242 ThisRot.get(matrix);
243
244 gl.glClearColor(1.0f, 1.0f, 1.0f, 0.5f);
245 gl.glClearDepth(1.0f);
246 gl.glDepthFunc(GL.GL_LEQUAL);
247 gl.glEnable(GL.GL_DEPTH_TEST);
248 gl.glShadeModel(GL.GL_FLAT);
249
250 gl.glEnable(GL.GL_LIGHTING);
251
252 gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, 1);
253 gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient, 0);
254 gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse, 0);
255 gl.glEnable(GL.GL_LIGHT0);
256
257 gl.glEnable(GL.GL_COLOR_MATERIAL);
258 gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);
259
260 quadratic = glu.gluNewQuadric();
261 glu.gluQuadricNormals(quadratic, GLU.GLU_SMOOTH);
262 glu.gluQuadricTexture(quadratic, true);
263
264 view_all();
265 }
266
267 // OpenGL method called when the canvas is reshaped
reshape(GLAutoDrawable drawable, int x, int y, int width, int height)268 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
269 GL gl = drawable.getGL();
270 float[] lightpos = {-1,1,1,0};
271 screenwidth = width;
272 screenheight = height;
273
274 gl.glViewport(0, 0, width, height); // Reset The Current Viewport
275 gl.glMatrixMode(GL.GL_PROJECTION); // Select The Projection Matrix
276 gl.glLoadIdentity(); // Reset The Projection Matrix
277
278 gl.glLightfv(GL.GL_LIGHT0,GL.GL_POSITION,lightpos,0); // Set light
279
280 aspect = width / height;
281
282 arcBall.setBounds((float) width, (float) height); //*NEW* Update mouse bounds for arcball
283
284 }
285
286 // OpenGL method called when the display is updated. Do all drawing here.
display(GLAutoDrawable drawable)287 public void display(GLAutoDrawable drawable) {
288 boolean shpimage = false;
289 shp tmp;
290 int[] viewport = new int[4];
291 float box_scale_x,box_scale_y, box_x0, box_y0;
292
293 // Set always rectangular aspect of the view
294 if (aspect < 1.0f) {
295 asph = aspect;
296 aspw = 1.0f;
297 }
298 else {
299 asph = 1.0f;
300 aspw = aspect;
301 }
302
303 synchronized(matrixLock) {
304 ThisRot.get(matrix);
305 }
306
307 GL gl = drawable.getGL();
308
309 gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
310
311 gl.glMatrixMode(GL.GL_PROJECTION);
312 gl.glLoadIdentity();
313
314 if (picking != NO_PICK) {
315 selectBuffer = BufferUtil.newIntBuffer(4*shp3d.size());
316 gl.glSelectBuffer(4*shp3d.size(), selectBuffer);
317 gl.glRenderMode(GL.GL_SELECT);
318 gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
319 gl.glInitNames();
320 gl.glPushName(-1);
321 if (picking == POINT)
322 glu.gluPickMatrix((double) x, (double)(viewport[3]-y),5.0,5.0,viewport,0);
323 else {
324 glu.gluPickMatrix((x0+x)*0.5, (double)(viewport[3]-(y0+y)*0.5),Math.abs(x0-x),Math.abs(y0-y),viewport,0);
325 }
326 }
327
328 gl.glOrtho(left*scale*aspw,right*scale*aspw,bottom*scale/asph,top*scale/asph,Znear,Zfar);
329
330 gl.glMatrixMode(GL.GL_MODELVIEW);
331 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
332 gl.glLoadIdentity();
333
334 gl.glPushMatrix();
335
336 // translate the model
337 gl.glTranslated(transX,transY,transZ);
338
339 // rotate the model
340 gl.glMultMatrixf(matrix, 0);
341
342 // Draw each element
343 // if (genlist == true) {
344
345 // gl.glNewList(1,GL.GL_COMPILE);
346
347 for(int i=0; i<shp3d.size(); i++){
348 tmp = (shp)shp3d.elementAt(i);
349 if (tmp instanceof shpBgImage && shpimage == false) { // For speed only
350 shpimage = true;
351 g2D = ovl.createGraphics();
352 }
353 if (tmp.isShow() == show) {
354 gl.glLoadName(i); // Set current position in shp3d stack as name for picking
355 tmp.paintGL(gl,g2D,this,center_of_rotation.x,center_of_rotation.y,center_of_rotation.z,scale);
356 }
357 }
358
359 // gl.glEndList();
360 genlist = false;
361 // }
362
363 // gl.glCallList(1);
364
365
366 if (picking != NO_PICK)
367 hits = gl.glRenderMode(GL.GL_RENDER); // Set render mode & collect if picking
368
369 gl.glPopMatrix();
370
371 // If box select, draw the box
372 if (DRAG == true) {
373
374 gl.glLoadIdentity();
375 gl.glPushMatrix();
376
377 box_scale_x = (right*scale*aspw-left*scale*aspw)/screenwidth;
378 box_scale_y = -(top*scale/asph-bottom*scale/asph)/screenheight;
379 box_x0 = left*scale*aspw;
380 box_y0 = top*scale/asph;
381
382 gl.glColor3f(1f, 0.1f, 0.1f);
383 gl.glBegin(GL.GL_LINE_STRIP);
384 gl.glVertex3f(box_x0+x0*box_scale_x,box_y0+y0*box_scale_y,Znear*0.99f);
385 gl.glVertex3f(box_x0+x*box_scale_x,box_y0+y0*box_scale_y,Znear*0.99f);
386 gl.glVertex3f(box_x0+x*box_scale_x,box_y0+y*box_scale_y,Znear*0.99f);
387 gl.glVertex3f(box_x0+x0*box_scale_x,box_y0+y*box_scale_y,Znear*0.99f);
388 gl.glVertex3f(box_x0+x0*box_scale_x,box_y0+y0*box_scale_y,Znear*0.99f);
389 gl.glEnd();
390
391 gl.glPopMatrix();
392
393 }
394
395 gl.glFlush(); // Flush the GL Rendering Pipeline
396
397 // generate the 2D overlay
398 if (shpimage == true)
399 ovl.drawAll();
400
401 }
402
403 // OpenGL method called when the display is changed.
displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)404 public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
405
406 }
407
setPainted()408 private synchronized void setPainted(){
409 painted = true;
410 notifyAll();
411 }
412
paint(Graphics g)413 public synchronized void paint(Graphics g){
414
415 display();
416
417 setPainted();
418 }
419
update(Graphics g)420 public void update(Graphics g){
421 paint(g);
422 }
423
add3D(Object obj)424 public int add3D(Object obj){
425
426 id_obj3d++;
427 ((_Object)obj).set_Id(id_obj3d+"");
428
429 try {
430 ((_Object)obj).reset(true);
431 } catch(Exception e1) {
432 error(e1);
433 return -1;
434 }
435
436 obj3d.addElement(obj);
437
438 _Object [] o = new _Object[1];
439 o[0] = (_Object)obj;
440
441 if (obj instanceof _Node)
442 nodes.addToGroup(o);
443 else
444 if (obj instanceof _Element)
445 elements.addToGroup(o);
446 else if (obj instanceof _Geometry)
447 geometry.addToGroup(o);
448 else {
449 treeNode.add(((_Object)obj).get_TreeNode());
450 }
451
452
453 Object[] arr = ((_Object)obj).get_Array(this);
454 for(int i=0; i<arr.length; i++){
455 ((shp)arr[i]).transform2D(VMatrix3D, center_of_rotation, this);
456 shp3d.addElement(arr[i]);
457 }
458 return id_obj3d;
459 }
460
clearTree()461 private void clearTree() {
462 if (pre != null) pre.clearTree();
463 }
464
showEditPanel(MouseEvent e)465 private void showEditPanel(MouseEvent e) {
466 if (pre != null) pre.showEditPanel(e);
467 }
468
setPickedObject()469 private void setPickedObject() {
470 int count = obj3d.size();
471 _Object o;
472
473 // Generate selection
474 picking = POINT;
475 display();
476 picking = NO_PICK;
477
478 // Set related shapes to picked
479 if (hits > 0)
480 for (int i=0; i<hits; i++)
481 ((shp)shp3d.elementAt(selectBuffer.get(4*i+3))).setPicked(true);
482
483 // Generate selected object tree
484 for (int i=0; i<count; i++) {
485 o = ((_Object)obj3d.elementAt(i));
486 if (o.isPickPoint(x,y,show,true))
487 o.setSelected(true);
488 }
489
490 // Update object selection in preprocessor tree
491 if (pre != null) pre.rescanTree();
492
493 }
494
495
boxSelect(int sx, int sy, int ex, int ey)496 private void boxSelect(int sx, int sy, int ex, int ey) {
497 int count = obj3d.size();
498 _Object o;
499
500 // Generate selection
501 picking = BOX;
502 display();
503 picking = NO_PICK;
504
505 // Set related shapes to picked
506 if (hits > 0)
507 for (int i=0; i<hits; i++)
508 ((shp)shp3d.elementAt(selectBuffer.get(4*i+3))).setPicked(true);
509
510 // Generate selected object tree
511 for (int i=0; i<count; i++) {
512 o = ((_Object)obj3d.elementAt(i));
513 if (o.isPickPoint(x,y,show,true))
514 o.setSelected(true);
515 }
516
517 // Update object selection in preprocessor tree
518 if (pre != null) pre.rescanTree();
519 }
520
521
getSelectedObject3D()522 public _Object getSelectedObject3D(){
523 _Object[] obj = getSelectedObjects3D();
524
525 if(obj.length > 0) return obj[0];
526
527 return null;
528 }
529
getSelectedObjects3D()530 public _Object[] getSelectedObjects3D() {
531 Vector v = new Vector();
532 _Object o;
533 _Object[] p;
534
535 for (int i=0; i<obj3d.size(); i++) {
536 o = ((_Object)obj3d.elementAt(i));
537 if (o.isSelected())
538 v.add(o);
539 }
540
541 p = new _Object[v.size()];
542 for (int i=0; i<v.size(); i++)
543 p[i] = (_Object)v.elementAt(i);
544
545 return p;
546 }
547
getAllObjects3D()548 public _Object[] getAllObjects3D() {
549 _Object[] arr = new _Object[obj3d.size()];
550 for(int i=0; i<obj3d.size(); i++) arr[i] = ((_Object)obj3d.elementAt(i));
551 return arr;
552 }
553
getAllNodes3D()554 public _Node[] getAllNodes3D() {
555 Vector arr = new Vector();
556 _Object o;
557
558 for(int i=0; i<obj3d.size(); i++) {
559 o = ((_Object)obj3d.elementAt(i));
560 if (o instanceof _Node)
561 arr.add(o);
562 }
563
564 // Generate array
565 _Node[] out = new _Node[arr.size()];
566 for (int i=0; i<out.length; i++)
567 out[i] = (_Node)arr.elementAt(i);
568
569 return out;
570 }
571
getAllElements3D()572 public _Object[] getAllElements3D() {
573 Vector arr = new Vector();
574 _Object o;
575
576 for(int i=0; i<obj3d.size(); i++) {
577 o = ((_Object)obj3d.elementAt(i));
578 if (o instanceof _Element)
579 arr.add(o);
580 }
581
582 // Generate array
583 _Object[] out = new _Object[arr.size()];
584 for (int i=0; i<out.length; i++)
585 out[i] = (_Object)arr.elementAt(i);
586
587 return out;
588 }
589
getAllGeometry3D()590 public _Geometry[] getAllGeometry3D() {
591 Vector arr = new Vector();
592 _Object o;
593
594 for(int i=0; i<obj3d.size(); i++) {
595 o = ((_Object)obj3d.elementAt(i));
596 if (o instanceof _Geometry)
597 arr.add(o);
598 }
599
600 // Generate array
601 _Geometry[] out = new _Geometry[arr.size()];
602 for (int i=0; i<out.length; i++)
603 out[i] = (_Geometry)arr.elementAt(i);
604
605 return out;
606 }
607
getAllGroups3D()608 public _Group[] getAllGroups3D() {
609 Vector arr = new Vector();
610 _Object o;
611
612 for(int i=0; i<obj3d.size(); i++) {
613 o = ((_Object)obj3d.elementAt(i));
614 if (o instanceof _Group)
615 arr.add(o);
616 }
617
618 _Group[] out = new _Group[arr.size()];
619 for (int i=0; i<out.length; i++)
620 out[i] = (_Group)arr.elementAt(i);
621
622 return out;
623 }
624
625
626
remove_all()627 public void remove_all(){
628 id_obj3d=0;
629 obj3d.removeAllElements();
630 shp3d.removeAllElements();
631 treeNode.removeAllChildren();
632 this.createGroups();
633 tree3d.reload();
634 view_grid();
635 repaint();
636 painted=true;
637 }
638
clearSelectOnAllObjects3D()639 public void clearSelectOnAllObjects3D(){
640 int count = obj3d.size();
641 for(int i=0; i<count; i++) ((_Object)obj3d.elementAt(i)).setSelected(false);
642 }
643
removeSelectedObjects3D()644 public void removeSelectedObjects3D(){
645 _Object o;
646 _Object[] s;
647 // Deselect required elements
648 for (int i=0; i<obj3d.size(); i++)
649 ((_Object)obj3d.elementAt(i)).deselectRequiredObjects();
650
651 // Remove selected objects from all groups
652 s = this.getSelectedObjects3D();
653
654 for (int i=0; i<obj3d.size(); i++) {
655 o = (_Object)obj3d.elementAt(i);
656 if (o instanceof _Group)
657 ((_Group)o).removeFromGroup(s);
658 }
659
660 // Remove selected objects from j3d
661 for (int i=0; i< obj3d.size(); i++) {
662 o = (_Object)obj3d.elementAt(i);
663 if (o.isSelected()) {
664 obj3d.remove(i);
665 i--;
666 }
667 }
668
669 this.tree_reset();
670 this.view_reset();
671 }
672
duplicate()673 public void duplicate(){
674 int count = obj3d.size();
675 _Object o;
676 Vector tmp = new Vector();
677
678 for(int i=0; i<count; i++) {
679 o = (_Object)obj3d.elementAt(i);
680 if(o.isSelected()){
681 tmp.add(o);
682 }
683 }
684
685 for (int i=0; i<tmp.size(); i++)
686 ((_Object)tmp.elementAt(i)).duplicate(this,true);
687
688 tree3d.reload();
689 view_reset();
690 }
691
transform3D(Matrix3D m)692 public void transform3D(Matrix3D m){
693 int count = obj3d.size();
694
695 _Object[] p = getSelectedObjects3D();
696
697 for (int i=0; i<p.length; i++)
698 if (!p[i].isProcessed()) {
699 p[i].transform3D(m);
700 p[i].setProcessed(true);
701 }
702
703 for(int i=0; i<count; i++)
704 ((_Object)obj3d.elementAt(i)).setProcessed(false);
705
706 view_reset();
707 view_repaint();
708 tree_reset();
709 }
710
tree_reset()711 public void tree_reset(){
712 _Object o;
713
714 treeNode.removeAllChildren();
715 int count = obj3d.size();
716 for(int i=0; i<count; i++) {
717 o = (_Object)obj3d.elementAt(i);
718 if (o instanceof _Group)
719 if (((_Group)o).isTopgroup())
720 treeNode.add(o.get_TreeNode());
721 }
722 tree3d.reload();
723 }
724
725 /** This method generates a new list of shapes to be used in the model rendering.
726 *
727 */
view_reset()728 public synchronized void view_reset(){
729 int count = obj3d.size();
730 shp3d.removeAllElements();
731
732 for(int i=0; i<count; i++){
733 Object[] arr = ((_Object)obj3d.elementAt(i)).get_Array(this);
734 for(int j=0; j<arr.length; j++){
735 ((shp)arr[j]).transform2D(VMatrix3D, center_of_rotation, this);
736 shp3d.addElement(arr[j]);
737 }
738 }
739
740 // Generate a new command list in the display method
741 genlist = true;
742
743 // Add the grid to the shp3d array
744 view_grid();
745 }
746
view_repaint()747 public synchronized void view_repaint(){
748 if(painted){
749 painted = false;
750 repaint();
751 }
752 }
753
view_translate(float dx, float dy, float dz)754 public synchronized void view_translate(float dx, float dy, float dz){
755 transX += dx*(right-left)*scale*aspw/screenwidth;
756 transY += dy*(top-bottom)*scale*asph/screenheight;
757 transZ += dz;
758
759 view_repaint();
760 }
761
762
view_top()763 public synchronized void view_top(){
764 synchronized(matrixLock) {
765 LastRot.setIdentity(); // Reset Rotation
766 ThisRot.setIdentity(); // Reset Rotation
767 }
768 view_repaint();
769 }
770
view_bottom()771 public synchronized void view_bottom(){
772 synchronized(matrixLock) {
773 LastRot.set(-1,0,0,0,0,1,0,0,0,0,-1,0,0,0,0,1);
774 ThisRot.set(-1,0,0,0,0,1,0,0,0,0,-1,0,0,0,0,1);
775 }
776 view_repaint();
777 }
778
view_ne()779 public synchronized void view_ne(){
780 synchronized(matrixLock) {
781 LastRot.set(-0.67843485f,-0.47181374f,0.5631324f,0.0f,0.7337033f,-0.4742565f,0.48658055f,0.0f,0.03749419f,0.7432855f,0.6679232f,0.0f,0.0f,0.0f,0.0f,1.0f);
782 ThisRot.set(-0.67843485f,-0.47181374f,0.5631324f,0.0f,0.7337033f,-0.4742565f,0.48658055f,0.0f,0.03749419f,0.7432855f,0.6679232f,0.0f,0.0f,0.0f,0.0f,1.0f);
783 }
784 view_repaint();
785 }
786
view_sw()787 public synchronized void view_sw(){
788 synchronized(matrixLock) {
789 LastRot.set(0.847451f,0.355411f,-0.394347f,0f,-0.5291711f,0.5060926f,-0.6810645f,0f,-0.04248167f,0.7858457f,0.6169619f,0f,0f,0f,0f,1f);
790 ThisRot.set(0.847451f,0.355411f,-0.394347f,0f,-0.5291711f,0.5060926f,-0.6810645f,0f,-0.04248167f,0.7858457f,0.6169619f,0f,0f,0f,0f,1f);
791 }
792 view_repaint();
793 }
794
view_se()795 public synchronized void view_se(){
796 synchronized(matrixLock) {
797 LastRot.set(0.7957134f,-0.36887878f,0.48038355f,0f,0.6056719f,0.48640004f,-0.6297437f,0f,-0.0013595134f,0.7920504f,0.6104544f,0f,0f,0f,0f,1f);
798 ThisRot.set(0.7957134f,-0.36887878f,0.48038355f,0f,0.6056719f,0.48640004f,-0.6297437f,0f,-0.0013595134f,0.7920504f,0.6104544f,0f,0f,0f,0f,1f);
799 }
800 view_repaint();
801 }
802
view_nw()803 public synchronized void view_nw(){
804 synchronized(matrixLock) {
805 LastRot.set(-0.7357225f,0.48088235f,-0.4769326f,0.0f,-0.6764666f,-0.48717147f,0.55231994f,0f,0.03325309f,0.72898287f,0.683724f,0f,0f,0f,0f,1f);
806 ThisRot.set(-0.7357225f,0.48088235f,-0.4769326f,0.0f,-0.6764666f,-0.48717147f,0.55231994f,0f,0.03325309f,0.72898287f,0.683724f,0f,0f,0f,0f,1f);
807 }
808 view_repaint();
809 }
810
view_left()811 public synchronized void view_left(){
812 synchronized(matrixLock) {
813 LastRot.set(0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,1);
814 ThisRot.set(0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,1);
815 }
816 view_repaint();
817 }
818
view_right()819 public synchronized void view_right(){
820 synchronized(matrixLock) {
821 LastRot.set(0,0,-1,0,-1,0,0,0,0,1,0,0,0,0,0,1);
822 ThisRot.set(0,0,-1,0,-1,0,0,0,0,1,0,0,0,0,0,1);
823 }
824 view_repaint();
825 }
826
view_front()827 public synchronized void view_front(){
828 synchronized(matrixLock) {
829 LastRot.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);
830 ThisRot.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);
831 }
832 view_repaint();
833 }
834
view_back()835 public synchronized void view_back(){
836 synchronized(matrixLock) {
837 LastRot.set(-1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1);
838 ThisRot.set(-1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1);
839 }
840 view_repaint();
841 }
842
view_all()843 public synchronized void view_all(){
844 float cx,cy,cz,maxx,minx,maxy,miny,maxz,minz,d;
845 float[] b;
846 Shape shp;
847
848 minx = java.lang.Float.MAX_VALUE;
849 miny = java.lang.Float.MAX_VALUE;
850 minz = java.lang.Float.MAX_VALUE;
851 maxx = java.lang.Float.MIN_VALUE;
852 maxy = java.lang.Float.MIN_VALUE;
853 maxz = java.lang.Float.MIN_VALUE;
854
855 for(int i=0; i<shp3d.size(); i++){
856 try{
857 b = ((shp)shp3d.elementAt(i)).getBoundaries();
858
859 if (b != null) {
860
861 maxx = Math.max(maxx,b[0]);
862 minx = Math.min(minx,b[1]);
863 maxy = Math.max(maxy,b[2]);
864 miny = Math.min(miny,b[3]);
865 maxz = Math.max(maxz,b[4]);
866 minz = Math.min(minz,b[5]);
867
868 }
869 }catch(Exception e){}
870 }
871
872 // Ball centre
873 cx = (maxx+minx)/2;
874 cy = (maxy+miny)/2;
875 cz = (maxz+minz)/2;
876
877 // Ball diameter
878 d = maxx - minx;
879 d = Math.max(d,maxy - miny);
880 d = Math.max(d,maxz - minz);
881
882 // Set viewing coordinates
883 Znear = -d;
884 Zfar = d;
885 left = cx - d;
886 right = cx + d;
887 bottom = cy - d;
888 top = cy + d;
889
890 // Reset zoom
891 scale = 1.0f;
892 transX = 0.0f;
893 transY = 0.0f;
894 transZ = 0.0f;
895
896 // Repaint
897 painted = true;
898 view_repaint();
899
900 }
901
showhide()902 public synchronized boolean showhide() {
903
904 _Object[] obj = this.getSelectedObjects3D();
905 if (obj.length != 0)
906 for (int i=0; i<obj.length; i++)
907 obj[i].setShow(!show);
908 else
909 show = !show;
910
911 clearSelectOnAllObjects3D();
912 if (pre != null) pre.clearTree();
913 view_reset();
914 view_repaint();
915
916 return show;
917 }
918
919 // Creates a grid and a coordinate system and adds them to the shp base
view_grid()920 public synchronized void view_grid(){
921 for(int i=0; i<shp3d.size(); i++){
922 if(shp3d.elementAt(i) instanceof shpPointGrid){
923 shp3d.removeElementAt(i);
924 i--;
925 }
926 }
927
928 if(GRIDMODE)
929 for(float i=LIMITS[0]; i<=LIMITS[2]; i+=GRIDSIZE){
930 for(float j=LIMITS[1]; j<=LIMITS[3]; j+=GRIDSIZE){
931 float x,y,z;
932 if(GRIDPLANE==GRIDPLANE_XY){
933 x=i;
934 y=j;
935 z=GRIDLEVEL;
936 }else if(GRIDPLANE==GRIDPLANE_YZ){
937 x=GRIDLEVEL;
938 y=j;
939 z=i;
940 }else{
941 x=i;
942 y=GRIDLEVEL;
943 z=j;
944 }
945 shpPointGrid gp = new shpPointGrid(x,y,z,GRIDCOLOR);
946 gp.setShow(show);
947 shp3d.addElement(gp);
948 }
949 }
950
951 shpXYZ xyz = new shpXYZ();
952 shp3d.addElement(xyz);
953 view_repaint();
954
955 }
956
view_scale(float s)957 public synchronized void view_scale(float s){
958 scale *= s;
959 view_repaint();
960 }
961
962
this_mousePressed(MouseEvent e)963 void this_mousePressed(MouseEvent e) {
964 int mod = e.getModifiers();
965
966 if (((mod & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) && ((mod & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK))
967 {
968 synchronized(matrixLock) {
969 LastRot.set( ThisRot ); // Set Last Static Rotation To Last Dynamic One
970 }
971 arcBall.click( e.getPoint() ); // Update Start Vector And Prepare For Dragging
972
973 }
974 }
975
976
this_mouseDragged(MouseEvent e)977 void this_mouseDragged(MouseEvent e) {
978 int mod = e.getModifiers();
979
980 if (((mod & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) && ((mod & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK)) {
981 Quat4f ThisQuat = new Quat4f();
982
983 arcBall.drag( e.getPoint(), ThisQuat); // Update End Vector And Get Rotation As Quaternion
984 synchronized(matrixLock) {
985 ThisRot.setRotation(ThisQuat); // Convert Quaternion Into Matrix3fT
986 ThisRot.mul( ThisRot, LastRot); // Accumulate Last Rotation Into This One
987 }
988 } else
989
990 if(((mod & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) && ((mod & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK)){
991 if(y-e.getY()>0) this.view_scale(1.1f);
992 if(y-e.getY()<0) this.view_scale(0.9f);
993 } else
994
995 if(((mod & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)) {
996 this.view_translate(e.getX()-x,y-e.getY(),0);
997 }
998
999 x=e.getX();
1000 y=e.getY();
1001
1002 view_repaint();
1003 }
1004
save(String file)1005 public void save(String file) {
1006 try {
1007 FileOutputStream ostream = new FileOutputStream(file);
1008 ObjectOutputStream p = new ObjectOutputStream(ostream);
1009 p.writeObject(VMatrix3D);
1010 for(int i=0; i<obj3d.size(); i++) p.writeObject(obj3d.elementAt(i));
1011 p.flush();
1012 ostream.close();
1013 }catch(FileNotFoundException fnfe) {
1014 System.err.println("File not found: " + file);
1015 }catch(IOException ioe){ System.err.println("Could not write file: " + file); ioe.printStackTrace();}
1016 }
1017
save(ObjectOutputStream oos)1018 public void save(ObjectOutputStream oos) {
1019 try {
1020 oos.writeObject(VMatrix3D);
1021 for(int i=0; i<obj3d.size(); i++) oos.writeObject(obj3d.elementAt(i));
1022 }catch(Exception e) { e.printStackTrace();}
1023 }
1024
open(String file)1025 public void open(String file) {
1026 try {
1027 FileInputStream istream = new FileInputStream(file);
1028 ObjectInputStream p = new ObjectInputStream(istream);
1029 remove_all();
1030 VMatrix3D=(Matrix3D)p.readObject();
1031 Object obj;
1032 try { while((obj = p.readObject())!=null) add3D(obj); }catch(EOFException eof){}
1033 view_repaint();
1034 p.close();
1035 istream.close();
1036 }catch(Exception ioe){ System.err.println("Could not open file: " + file+"\n"+ioe); }
1037 }
open(ObjectInputStream ois)1038 public void open(ObjectInputStream ois) {
1039 try {
1040 //remove_all();
1041 VMatrix3D=(Matrix3D)ois.readObject();
1042 Object obj;
1043 try { while((obj = ois.readObject())!=null) add3D(obj); }catch(EOFException eof){}
1044 view_repaint();
1045 }catch(Exception e) { e.printStackTrace();}
1046 }
1047
save_Image(String file)1048 public void save_Image(String file) {
1049 byte[] pngbytes;
1050 PngEncoderB png;
1051
1052 try {
1053 if(file.toLowerCase().indexOf(".png")==-1) file+=".png";
1054 FileOutputStream out = new FileOutputStream(file);
1055 BufferedImage image = (BufferedImage)createImage(getWidth(), getHeight());
1056 Graphics g = image.getGraphics();
1057 paint(g);
1058
1059 png = new PngEncoderB(image,false,0,5); // Encode at level 5 compression
1060 pngbytes = png.pngEncode();
1061 out.write(pngbytes);
1062
1063 g.dispose();
1064 out.flush();
1065 out.close();
1066 }catch(FileNotFoundException fnfe) {
1067 System.err.println("File not found: " + file);
1068 }catch(IOException ioe){ System.err.println("Could not write file: " + file); }
1069 }
1070
open_stl(String file)1071 public void open_stl(String file){
1072 this.add3D(new _Stl(file));
1073 view_repaint();
1074 }
1075
error(Object st)1076 public void error(Object st){
1077 JOptionPane.showMessageDialog(null,"Error: "+st,"Error!",JOptionPane.ERROR_MESSAGE);
1078 if(st instanceof Exception) ((Exception)st).printStackTrace(); else System.out.println("Error: "+st);
1079 }
1080
rebuild()1081 public void rebuild() {
1082 int count = obj3d.size();
1083 for (int i=0; i<4; i++)
1084 for(int j=0; j<count; j++){
1085 _Object obj = ((_Object)obj3d.elementAt(j));
1086 if (obj.getGeometryType() == i)
1087 obj.reset(true);
1088 }
1089 view_reset();
1090 view_repaint();
1091 tree_reset();
1092 }
1093
setCenterOfRotation()1094 public void setCenterOfRotation() {
1095 _Object obj = this.getSelectedObject3D();
1096 if (obj != null) {
1097
1098 center_of_rotation = obj.getCenter();
1099
1100 }
1101 view_reset();
1102 view_repaint();
1103 }
1104
addBorderObjects()1105 public void addBorderObjects() {
1106 _Object[] obj = this.getSelectedObjects3D();
1107 _Object[] add = null;
1108 if (obj != null)
1109 for (int i=0; i<obj.length; i++) {
1110 add = obj[i].getBorderObjects();
1111 if (add != null)
1112 for (int j=0; j<add.length; j++)
1113 this.add3D(add[j]);
1114 }
1115 view_reset();
1116 view_repaint();
1117 }
1118
intersectObjects()1119 public void intersectObjects() throws IllegalStateException {
1120 _Object[] obj = this.getSelectedObjects3D();
1121 _NurbCurve[] o = new _NurbCurve[obj.length];
1122 _NurbSurface[] s = new _NurbSurface[obj.length];
1123 _Point[] p = null;
1124 _NurbCurve[] c = null;
1125 int j = 0, k = 0;
1126
1127 if (obj != null)
1128 if (obj.length > 1)
1129 for (int i=0; i<obj.length; i++) {
1130 if (obj[i] instanceof _NurbCurve && !lib3D.contains(o,obj[i]))
1131 o[j++] = (_NurbCurve)obj[i];
1132 if (obj[i] instanceof _NurbSurface && !lib3D.contains(s,obj[i]))
1133 s[k++] = (_NurbSurface)obj[i];
1134 }
1135
1136 if (j == 2) {
1137 try {
1138 p = lib3D.intersectCurves(o[0], o[1], GeometricTolerance);
1139 } catch (IllegalStateException e) {
1140 throw new IllegalStateException("No intersection found");
1141 }
1142 }
1143 else
1144 if (j == 1 && k == 1) {
1145 try {
1146 p = lib3D.intersectCurveWithSurface(o[0], s[0], GeometricTolerance);
1147 } catch (IllegalStateException e) {
1148 throw new IllegalStateException("No intersection found");
1149 }
1150 }
1151 else
1152 if (k == 2) {
1153 try {
1154 c = lib3D.intersectSurfaces(s[0], s[1]);
1155 } catch (IllegalStateException e) {
1156 throw new IllegalStateException("No intersection found");
1157 }
1158 }
1159
1160 if (p != null)
1161 if (p.length > 0)
1162 for (int i=0; i<p.length; i++)
1163 this.add3D(p[i]);
1164
1165 if (c != null)
1166 if (c.length > 0)
1167 for (int i=0; i<c.length; i++)
1168 this.add3D(c[i]);
1169
1170 view_reset();
1171 view_repaint();
1172 }
1173
1174
1175
breakObjects()1176 public void breakObjects() throws IllegalStateException {
1177 _Object[] obj = this.getSelectedObjects3D();
1178 _Point[] ps = new _Point[obj.length];
1179 _NurbCurve[] o = new _NurbCurve[obj.length];
1180 _NurbSurface[] s = new _NurbSurface[obj.length];
1181 _Point[] p = null;
1182 _NurbCurve[] c = null;
1183 int j = 0, k = 0, l = 0;
1184
1185 if (obj != null)
1186 if (obj.length > 1)
1187 for (int i=0; i<obj.length; i++) {
1188 if (obj[i] instanceof _Point && !lib3D.contains(ps,obj[i]))
1189 ps[l++] = (_Point)obj[i];
1190 if (obj[i] instanceof _NurbCurve && !lib3D.contains(o,obj[i]))
1191 o[j++] = (_NurbCurve)obj[i];
1192 if (obj[i] instanceof _NurbSurface && !lib3D.contains(s,obj[i]))
1193 s[k++] = (_NurbSurface)obj[i];
1194 }
1195
1196 if (l == 1 && j == 1) {
1197 try {
1198 c = lib3D.breakCurve(o[0], ps[0], GeometricTolerance);
1199 } catch (IllegalStateException e) {
1200 throw new IllegalStateException("No break possible");
1201 }
1202 }
1203 else
1204 if (l == 1 && k == 1)
1205 throw new IllegalStateException("Surface break not supported yet");
1206
1207 else
1208 if (j == 1 && k == 1)
1209 throw new IllegalStateException("Surface break using a curve is not supported yet");
1210
1211
1212 if (p != null)
1213 if (p.length > 0)
1214 for (int i=0; i<p.length; i++)
1215 this.add3D(p[i]);
1216
1217 if (c != null)
1218 if (c.length > 0)
1219 for (int i=0; i<c.length; i++)
1220 this.add3D(c[i]);
1221
1222 view_reset();
1223 view_repaint();
1224 }
1225
1226
1227
projectObjects()1228 public void projectObjects() throws IllegalStateException {
1229 _Object[] obj = this.getSelectedObjects3D();
1230 _Point[] ps = new _Point[obj.length];
1231 _NurbCurve[] o = new _NurbCurve[obj.length];
1232 _NurbSurface[] s = new _NurbSurface[obj.length];
1233 _Point[] p = null;
1234 _NurbCurve[] c = null;
1235 int j = 0, k = 0, l = 0;
1236
1237 if (obj != null)
1238 if (obj.length > 1)
1239 for (int i=0; i<obj.length; i++) {
1240 if (obj[i] instanceof _Point && !lib3D.contains(ps,obj[i]))
1241 ps[l++] = (_Point)obj[i];
1242 if (obj[i] instanceof _NurbCurve && !lib3D.contains(o,obj[i]))
1243 o[j++] = (_NurbCurve)obj[i];
1244 if (obj[i] instanceof _NurbSurface && !lib3D.contains(s,obj[i]))
1245 s[k++] = (_NurbSurface)obj[i];
1246 }
1247
1248 if (l == 1 && j == 1) {
1249 try {
1250 p = lib3D.projectPointOntoCurve(ps[0], o[0], GeometricTolerance);
1251 } catch (IllegalStateException e) {
1252 throw new IllegalStateException("No projection found");
1253 }
1254 }
1255 else
1256 if (l == 1 && k == 1) {
1257 try {
1258 p = lib3D.projectPointOntoSurface(ps[0], s[0], GeometricTolerance);
1259 } catch (IllegalStateException e) {
1260 throw new IllegalStateException("No projection found");
1261 }
1262 }
1263 else
1264 if (j == 1 && k == 1) {
1265 try {
1266 // c = lib3D.projectCurveOntoSurface(o[0], s[0]);
1267 } catch (IllegalStateException e) {
1268 throw new IllegalStateException("No projection found");
1269 }
1270 }
1271
1272 if (p != null)
1273 if (p.length > 0)
1274 for (int i=0; i<p.length; i++)
1275 this.add3D(p[i]);
1276
1277 if (c != null)
1278 if (c.length > 0)
1279 for (int i=0; i<c.length; i++)
1280 this.add3D(c[i]);
1281
1282 view_reset();
1283 view_repaint();
1284 }
1285
requestAction()1286 private void requestAction() {
1287
1288 if (pre != null)
1289 pre.requestAction();
1290
1291 }
1292
1293
1294
getSHOW_ID_NODE()1295 public boolean getSHOW_ID_NODE() {
1296 return SHOW_ID_NODE;
1297 }
1298
setSHOW_ID_NODE(boolean show_id_node)1299 public void setSHOW_ID_NODE(boolean show_id_node) {
1300 SHOW_ID_NODE = show_id_node;
1301 }
1302
getBGCOLOR()1303 public Color getBGCOLOR() {
1304 return BGCOLOR;
1305 }
1306
setBGCOLOR(Color bgcolor)1307 public void setBGCOLOR(Color bgcolor) {
1308 BGCOLOR = bgcolor;
1309 }
1310
getDRAFTMODE()1311 public boolean getDRAFTMODE() {
1312 return DRAFTMODE;
1313 }
1314
setDRAFTMODE(boolean draftmode)1315 public void setDRAFTMODE(boolean draftmode) {
1316 DRAFTMODE = draftmode;
1317 }
1318
getGRAPHICSMODE()1319 public byte getGRAPHICSMODE() {
1320 return GRAPHICSMODE;
1321 }
1322
setGRAPHICSMODE(byte graphicsmode)1323 public void setGRAPHICSMODE(byte graphicsmode) {
1324 GRAPHICSMODE = graphicsmode;
1325 }
1326
getGRIDCOLOR()1327 public Color getGRIDCOLOR() {
1328 return GRIDCOLOR;
1329 }
1330
setGRIDCOLOR(Color gridcolor)1331 public void setGRIDCOLOR(Color gridcolor) {
1332 GRIDCOLOR = gridcolor;
1333 }
1334
getGRIDLEVEL()1335 public float getGRIDLEVEL() {
1336 return GRIDLEVEL;
1337 }
1338
setGRIDLEVEL(float gridlevel)1339 public void setGRIDLEVEL(float gridlevel) {
1340 GRIDLEVEL = gridlevel;
1341 }
1342
getGRIDMODE()1343 public boolean getGRIDMODE() {
1344 return GRIDMODE;
1345 }
1346
setGRIDMODE(boolean gridmode)1347 public void setGRIDMODE(boolean gridmode) {
1348 GRIDMODE = gridmode;
1349 }
1350
getGRIDPLANE()1351 public byte getGRIDPLANE() {
1352 return GRIDPLANE;
1353 }
1354
setGRIDPLANE(byte gridplane)1355 public void setGRIDPLANE(byte gridplane) {
1356 GRIDPLANE = gridplane;
1357 }
1358
getGRIDSIZE()1359 public float getGRIDSIZE() {
1360 return GRIDSIZE;
1361 }
1362
setGRIDSIZE(float gridsize)1363 public void setGRIDSIZE(float gridsize) {
1364 GRIDSIZE = gridsize;
1365 }
1366
getLIMITS()1367 public float[] getLIMITS() {
1368 return LIMITS;
1369 }
1370
setLIMITS(float[] limits)1371 public void setLIMITS(float[] limits) {
1372 LIMITS = limits;
1373 }
1374
getNODE_MERGE_TOLERANCE()1375 public float getNODE_MERGE_TOLERANCE() {
1376 return NODE_MERGE_TOLERANCE;
1377 }
1378
setNODE_MERGE_TOLERANCE(float node_merge_tolerance)1379 public void setNODE_MERGE_TOLERANCE(float node_merge_tolerance) {
1380 NODE_MERGE_TOLERANCE = node_merge_tolerance;
1381 }
1382
getNODESIZE()1383 public int getNODESIZE() {
1384 return NODESIZE;
1385 }
1386
setNODESIZE(int nodesize)1387 public void setNODESIZE(int nodesize) {
1388 NODESIZE = nodesize;
1389 }
1390
getPOINTSIZE()1391 public int getPOINTSIZE() {
1392 return POINTSIZE;
1393 }
1394
setPOINTSIZE(int pointsize)1395 public void setPOINTSIZE(int pointsize) {
1396 POINTSIZE = pointsize;
1397 }
1398
getRENDERMODE()1399 public byte getRENDERMODE() {
1400 return RENDERMODE;
1401 }
1402
setRENDERMODE(byte rendermode)1403 public void setRENDERMODE(byte rendermode) {
1404 RENDERMODE = rendermode;
1405 }
1406
getSHOW_ID_CONSTRAINTS()1407 public boolean getSHOW_ID_CONSTRAINTS() {
1408 return SHOW_ID_CONSTRAINTS;
1409 }
1410
setSHOW_ID_CONSTRAINTS(boolean show_id_constraints)1411 public void setSHOW_ID_CONSTRAINTS(boolean show_id_constraints) {
1412 SHOW_ID_CONSTRAINTS = show_id_constraints;
1413 }
1414
getSHOW_ID_ELEMENT()1415 public boolean getSHOW_ID_ELEMENT() {
1416 return SHOW_ID_ELEMENT;
1417 }
1418
setSHOW_ID_ELEMENT(boolean show_id_element)1419 public void setSHOW_ID_ELEMENT(boolean show_id_element) {
1420 SHOW_ID_ELEMENT = show_id_element;
1421 }
1422
getSHOW_ID_LOADS()1423 public boolean getSHOW_ID_LOADS() {
1424 return SHOW_ID_LOADS;
1425 }
1426
setSHOW_ID_LOADS(boolean show_id_loads)1427 public void setSHOW_ID_LOADS(boolean show_id_loads) {
1428 SHOW_ID_LOADS = show_id_loads;
1429 }
1430
getSHOW_ID_MATERIALS()1431 public boolean getSHOW_ID_MATERIALS() {
1432 return SHOW_ID_MATERIALS;
1433 }
1434
setSHOW_ID_MATERIALS(boolean show_id_materials)1435 public void setSHOW_ID_MATERIALS(boolean show_id_materials) {
1436 SHOW_ID_MATERIALS = show_id_materials;
1437 }
1438
getSHOW_ID_TRACKERS()1439 public boolean getSHOW_ID_TRACKERS() {
1440 return SHOW_ID_TRACKERS;
1441 }
1442
setSHOW_ID_TRACKERS(boolean show_id_trackers)1443 public void setSHOW_ID_TRACKERS(boolean show_id_trackers) {
1444 SHOW_ID_TRACKERS = show_id_trackers;
1445 }
1446
getSTLCOLOR()1447 public Color getSTLCOLOR() {
1448 return STLCOLOR;
1449 }
1450
setSTLCOLOR(Color stlcolor)1451 public void setSTLCOLOR(Color stlcolor) {
1452 STLCOLOR = stlcolor;
1453 }
1454
getVMatrix3D()1455 public Matrix3D getVMatrix3D() {
1456 return VMatrix3D;
1457 }
1458
setVMatrix3D(Matrix3D matrix3D)1459 public void setVMatrix3D(Matrix3D matrix3D) {
1460 VMatrix3D = matrix3D;
1461 }
1462
1463
getTree3d()1464 public DefaultTreeModel getTree3d() {
1465 return tree3d;
1466 }
1467
getGeometricTolerance()1468 public float getGeometricTolerance() {
1469 return GeometricTolerance;
1470 }
1471
setGeometricTolerance(float geometricTolerance)1472 public void setGeometricTolerance(float geometricTolerance) {
1473 GeometricTolerance = geometricTolerance;
1474 }
1475
1476
1477
replaceAllInstancesOf(_Object o, _Object replacement)1478 public void replaceAllInstancesOf(_Object o, _Object replacement) {
1479
1480 // Replace all instances of object o with replacement
1481 for (int i=0; i<obj3d.size(); i++)
1482 ((_Object)obj3d.elementAt(i)).replaceObjectWith(o,replacement);
1483
1484 // Remove object o from database
1485 obj3d.remove(o);
1486
1487 }
1488
1489
1490
1491 }