-
Notifications
You must be signed in to change notification settings - Fork 34
/
IG.java
4912 lines (4244 loc) · 189 KB
/
IG.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*---
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;
import java.awt.*;
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import igeo.gui.*;
import igeo.io.*;
/**
A main interface to background process of iGeo.
A single IG instance can be accessed through static methods although
multiple IG instance also can be contained in the static variable iglist in case
multiple object servers are needed or simultaneous execution of multiple applets.
One IG instance contains one IServer as object database and one IPanel as
display window. The member variable of IPanel can be null when no display
window is needed.
@see IServer
@see IPanel
@author Satoru Sugihara
*/
public class IG implements IServerI{
public static int majorVersion(){ return 0; }
public static int minorVersion(){ return 9; }
public static int buildVersion(){ return 3; }
public static int revisionVersion(){ return 0; }
public static Calendar versionDate(){ return new GregorianCalendar(2019, 8, 14); }
public static String version(){
return String.valueOf(majorVersion())+"."+String.valueOf(minorVersion())+"."+
String.valueOf(buildVersion())+"."+String.valueOf(revisionVersion());
}
/************************************
* static system variables
************************************/
public static final Object lock = new Object();
/** Processing Graphics using OpenGL to be put in size() method in Processing */
public static final String GL1 = "igeo.p.PIGraphicsGL1";
public static final String GL2 = "igeo.p.PIGraphicsGL2";
public static final String GL3 = "igeo.p.PIGraphicsGL3";
//public static final String GL = GL1; // switch before compile for target // for processing 1.5
//public static final String GL = GL2; // switch before compile for target // for processing 2.0
public static final String GL = GL3; // switch before compile for target // for processing 3.0
/** Processing Graphics using P3D to be put in size() method in Processing; under development. do not use yet. */
public static final String P3D = "igeo.p.PIGraphics3D";
/** alias of IG.P3D */
public static final String P3 = P3D;
/** alias of IG.P3D */
public static final String P = P3D;
/** Processing Graphics using JAVA to be put in size() method in Processing; to be implemented */
//public static final String JAVA = "igeo.p.PIGraphicsJava";
/** multiple IG instances are stored in iglist and switched by IG static methods
in case of applet execution or other occasion but handling of multiple IG
instances and switching are not really tested. */
protected static ArrayList<IG> iglist=null;
protected static int currentId = -1;
/************************************
* static geometry variables
************************************/
/** x-axis vector. do not modify the content. */
public static final IVec xaxis = IVec.xaxis;
/** y-axis vector. do not modify the content. */
public static final IVec yaxis = IVec.yaxis;
/** z-axis vector. do not modify the content. */
public static final IVec zaxis = IVec.zaxis;
/** origin vector. do not modify the content. */
public static final IVec origin = IVec.origin;
/** alias of x-axis vector */
public static final IVec x = IVec.xaxis;
/** alias of y-axis vector */
public static final IVec y = IVec.yaxis;
/** alias of z-axis vector */
public static final IVec z = IVec.zaxis;
/** alias of origin vector */
public static final IVec o = IVec.origin;
/************************************
* object variables
************************************/
/*protected*/ public IServer server;
/*protected*/ public IPanelI panel = null;
/*protected*/ public String inputFile;
/*protected*/ public String outputFile;
/** base file path for file I/O */
public String basePath = null; //".";
/** wrapping inputs in different environment. replacing basePath. */
public IInputWrapper inputWrapper=null;
/** if it's applet. online == true */
public boolean online=false;
/* *
initialize whole IG system with IServer and graphical components
instance of IG should be held by IGPane
@param
owner: if owner contains IGPane, the instance of IG is kept by it.
if not, IGPane is instantiated and the instance of IG is kept by it.
if the ownwer is null, IGPane and all other graphical components are not instantiated.
*/
/*
public static IG init(Container owner){
if(iglist==null) iglist = new ArrayList<IG>();
IG ig = null;
if(owner != null){
IGPane p = findIGPane(owner);
if(p==null) p = new IGPane(owner);
ig = new IG(p);
}
else ig = new IG();
iglist.add(ig);
currentId = iglist.size()-1;
return ig;
}
public static IGPane findIGPane(Container container){
final int defaultSearchDepth = 0;
return findIGPane(container, defaultSearchDepth);
}
public static IGPane findIGPane(Container container, int searchDepth){
Component[] components = container.getComponents();
for(Component c : components){
if(c instanceof IGPane) return (IGPane)c;
else if(searchDepth>0 && c instanceof Container){
IGPane p = findIGPane((Container)c, searchDepth-1);
if(p!=null) return p;
}
}
return null;
}
*/
/***********************************************************************
* static methods
***********************************************************************/
/**
Initialize whole IG system in non-graphic mode.
*/
public static IG init(){
if(iglist==null) iglist = new ArrayList<IG>();
IG ig = new IG();
iglist.add(ig);
currentId = iglist.size()-1;
return ig;
}
/** Initialize whole IG system in graphic mode.
Please instantiate IPanel beforehand.
*/
public static IG init(IPanelI owner){
if(iglist==null) iglist = new ArrayList<IG>();
IG ig = new IG(owner);
iglist.add(ig);
currentId = iglist.size()-1;
return ig;
}
/** alias of cur() */
public static IG current(){ return cur(); }
/** Find the IG instance which is likely to be the current. */
public static IG cur(){
if(iglist==null || currentId<0 || currentId>=iglist.size()) return null;
return iglist.get(currentId);
}
/** object to be used to lock in "synchronized" statement */
public static IG defaultThread(){ return cur(); }
/** object to be used to lock in "synchronized" statement */
public static IDynamicServer dynamicThread(){
IG ig = cur(); if(ig==null) return null; return ig.dynamicServer();
}
/** alias of dynamicThread() */
public static IDynamicServer updateThread(){ return dynamicThread(); }
public static void setCurrent(IG ig){
int idx = iglist.indexOf(ig);
if(idx>=0 && idx<iglist.size()) currentId = idx;
else{ // not in the list
// add? really?
iglist.add(ig);
currentId = iglist.size()-1;
}
// default server for geometry creator
ICurveCreator.server(ig);
ISurfaceCreator.server(ig);
IMeshCreator.server(ig);
}
public static void setCurrent(IPanelI owner){
for(int i=0; i<iglist.size(); i++){
if(iglist.get(i).panel == owner){
currentId = i;
// default server for geometry creator
ICurveCreator.server(iglist.get(i));
ISurfaceCreator.server(iglist.get(i));
return;
}
}
IOut.err("no IG instance found for "+owner);
}
/** Find IG instance linked with the specified IPanel instance. */
public static IG getIG(IPanelI owner){
for(IG ig : iglist) if(ig.panel == owner) return ig;
return null;
}
public static IObject[] open(String file){
IG ig = cur();
if(ig==null) return null;
ArrayList<IObject> objects = ig.openFile(file);
if(objects==null) return null;
return objects.toArray(new IObject[objects.size()]);
}
public static boolean save(String file){
IG ig = cur();
if(ig==null) return false;
return ig.saveFile(file);
}
// dynamics methods
/** set duration of dynamics update */
public static void duration(int dur){ IG ig=cur(); if(ig!=null) ig.setDuration(dur); }
/** get duration of dynamics update */
public static int duration(){ IG ig=cur(); return ig==null?0:ig.getDuration(); }
/** set current time count of dynamics update. recommeded not to chage time. */
public static void time(int tm){ IG ig=cur(); if(ig!=null) ig.setTime(tm); }
/** get current time count of dynamics update */
public static int time(){ IG ig=cur(); return ig==null?-1:ig.getTime(); }
/** pause dynamics update. */
public static void pause(){ IG ig=cur(); if(ig!=null) ig.pauseDynamics(); }
/** resume dynamics update. */
public static void resume(){ IG ig=cur(); if(ig!=null) ig.resumeDynamics(); }
/** check if dynamics is running */
public static boolean isRunning(){ IG ig=cur(); if(ig!=null){ return ig.isDynamicsRunning(); } return false; }
/** start dynamics update. if IConfig.autoStart is true, this should not be used. */
public static void start(){ IG ig=cur(); if(ig!=null) ig.startDynamics(); }
/** stop dynamics update. recommended not to use this because stopping should be done by setting duration. */
public static void stop(){ IG ig=cur(); if(ig!=null) ig.stopDynamics(); }
/** setting update rate time interval in second */
public static void updateRate(double second){ IConfig.updateRate=second; }
/** alias of updateRate() */
public static void updateSpeed(double second){ updateRate(second); }
/** alias of updateRate() */
public static void rate(double second){ updateRate(second); }
/** alias of updateRate() */
public static void speed(double second){ updateRate(second); }
/** getting update rate time interval in second */
public static double updateRate(){ return IConfig.updateRate; }
/** alias of updateRate() */
public static double updateSpeed(){ return updateRate(); }
/** alias of updateRate() */
public static double rate(){ return updateRate(); }
/** alias of updateRate() */
public static double speed(){ return updateRate(); }
/** getting unit of current IG server */
public static IUnit unit(){
IG ig=cur(); if(ig!=null) return ig.server().unit();
return null;
}
/** setting unit of current IG server */
public static void unit(IUnit u){
IG ig=cur(); if(ig!=null) ig.server().unit(u);
}
/** setting unit of current IG server */
public static void unit(IUnit.Type u){
IG ig=cur(); if(ig!=null) ig.server().unit(u);
}
/** setting unit of current IG server */
public static void unit(String unitName){
IG ig=cur(); if(ig!=null) ig.server().unit(unitName);
}
/** to set the name first and save later (likely by key event) */
public static void outputFile(String filename){
IG ig = cur();
if(ig!=null) ig.setOutputFile(filename);
}
public static String outputFile(){
IG ig = cur();
if(ig==null) return null;
return ig.getOutputFile();
}
public static void inputFile(String filename){
IG ig = cur();
if(ig!=null) ig.setInputFile(filename);
}
public static String inputFile(){
IG ig = cur();
if(ig==null) return null;
return ig.getInputFile();
}
/** get all points in the current server */
public static IPoint[] points(){
IG ig = cur(); return ig==null?null:ig.getPoints();
}
/** get all points in the current server; alias */
public static IPoint[] pts(){ return points(); }
/** get all curves in the current server */
public static ICurve[] curves(){
IG ig = cur(); return ig==null?null:ig.getCurves();
}
/** get all curves in the current server; alias */
public static ICurve[] crvs(){ return curves(); }
/** get all curves in the current server
Note that IPolycurve contains multiple ICurve and they show up in curves() as well.
ICurve - IPolycurve relationship is still under work. This is temporary measure.
*/
public static IPolycurve[] polycurves(){
IG ig = cur(); return ig==null?null:ig.getPolycurves();
}
/** get all curves in the current server; alias.
Note that IPolycurve contains multiple ICurve and they show up in curves() as well.
ICurve - IPolycurve relationship is still under work. This is temporary measure.
*/
//public static ICurve[] pcrvs(){ return polycurves(); }
/** get all surfaces in the current server */
public static ISurface[] surfaces(){
IG ig = cur(); return ig==null?null:ig.getSurfaces();
}
/** get all surfaces in the current server; alias */
public static ISurface[] srfs(){ return surfaces(); }
/** get all meshes in the current server */
public static IMesh[] meshes(){
IG ig = cur(); return ig==null?null:ig.getMeshes();
}
/** get all breps in the current server */
public static IBrep[] breps(){
IG ig = cur(); return ig==null?null:ig.getBreps();
}
/** get all texts in the current server */
public static IText[] texts(){
IG ig = cur(); return ig==null?null:ig.getTexts();
}
/** get all geometry objects in the current server */
public static IGeometry[] geometries(){
IG ig = cur(); return ig==null?null:ig.getGeometries();
}
/** get all geometry objects in the current server */
public static IGeometry[] geos(){ return geometries(); }
/** get all objects of the specified class in the current server */
public static IObject[] objects(Class cls){
IG ig = cur(); return ig==null?null:ig.getObjects(cls);
}
/** get all objects of the specified class in the current server; alias */
public static IObject[] objs(Class cls){ return objects(); }
/** get all objects in the current server */
public static IObject[] objects(){
IG ig = cur(); return ig==null?null:ig.getObjects();
}
/** get all objects in the current server; alias */
public static IObject[] objs(){ return objects(); }
/** get a point in the current server */
public static IPoint point(int i){
IG ig = cur(); return ig==null?null:ig.getPoint(i);
}
/** get a point in the current server; alias */
public static IPoint pt(int i){ return point(i); }
/** get a curve in the current server */
public static ICurve curve(int i){
IG ig = cur(); return ig==null?null:ig.getCurve(i);
}
/** get a curve in the current server; alias */
public static ICurve crv(int i){ return curve(i); }
/** get a polycurve in the current server
Note that IPolycurve contains multiple ICurve and they show up in curves() as well.
ICurve - IPolycurve relationship is still under work. This is temporary measure.
*/
public static IPolycurve polycurve(int i){
IG ig = cur(); return ig==null?null:ig.getPolycurve(i);
}
/** get a curve in the current server; alias.
Note that IPolycurve contains multiple ICurve and they show up in curves() as well.
ICurve - IPolycurve relationship is still under work. This is temporary measure.
*/
//public static IPolycurve pcrv(int i){ return polycurve(i); }
/** get a surface in the current server */
public static ISurface surface(int i){
IG ig = cur(); return ig==null?null:ig.getSurface(i);
}
/** get a surface in the current server; alias */
public static ISurface srf(int i){ return surface(i); }
/** get a mesh in the current server */
public static IMesh mesh(int i){
IG ig = cur(); return ig==null?null:ig.getMesh(i);
}
/** get a brep in the current server */
public static IBrep brep(int i){
IG ig = cur(); return ig==null?null:ig.getBrep(i);
}
/** get a text in the current server */
public static IText text(int i){
IG ig = cur(); return ig==null?null:ig.getText(i);
}
/** get a geometry in the current server */
public static IGeometry geometry(int i){
IG ig = cur(); return ig==null?null:ig.getGeometry(i);
}
/** get a geometry in the current server */
public static IGeometry geo(int i){ return geometry(i); }
/** get a object of the specified class in the current server */
public static IObject object(Class cls, int i){
IG ig = cur(); return ig==null?null:ig.getObject(cls,i);
}
/** get a object of the specified class in the current server; alias */
public static IObject obj(Class cls, int i){ return object(cls,i); }
/** get a object in the current server */
public static IObject object(int i){
IG ig = cur(); return ig==null?null:ig.getObject(i);
}
/** get a object in the current server; alias */
public static IObject obj(int i){ return object(i); }
/** number of points in the current server */
public static int pointNum(){
IG ig = cur(); return ig==null?0:ig.getPointNum();
}
/** number of points in the current server; alias */
public static int ptNum(){ return pointNum(); }
/** number of curves in the current server */
public static int curveNum(){
IG ig = cur(); return ig==null?0:ig.getCurveNum();
}
/** number of curves in the current server; alias */
public static int crvNum(){ return curveNum(); }
/** number of polycurves in the current server.
Note that IPolycurve contains multiple ICurve and they show up in curves() as well.
ICurve - IPolycurve relationship is still under work. This is temporary measure.
*/
public static int polycurveNum(){
IG ig = cur(); return ig==null?0:ig.getPolycurveNum();
}
/** number of polycurves in the current server; alias.
Note that IPolycurve contains multiple ICurve and they show up in curves() as well.
ICurve - IPolycurve relationship is still under work. This is temporary measure.
*/
//fpublic static int pcrvNum(){ return polycurveNum(); }
/** number of surfaces in the current server */
public static int surfaceNum(){
IG ig = cur(); return ig==null?0:ig.getSurfaceNum();
}
/** number of surfaces in the current server; alias */
public static int srfNum(){ return surfaceNum(); }
/** number of meshes in the current server */
public static int meshNum(){
IG ig = cur(); return ig==null?0:ig.getMeshNum();
}
/** number of breps in the current server */
public static int brepNum(){
IG ig = cur(); return ig==null?0:ig.getBrepNum();
}
/** number of texts in the current server */
public static int textNum(){
IG ig = cur(); return ig==null?0:ig.getTextNum();
}
/** number of geometries in the cubrrent server */
public static int geometryNum(){
IG ig = cur(); return ig==null?0:ig.getGeometryNum();
}
/** alias of geometryNum() */
public static int geoNum(){ return geometryNum(); }
/** number of objects of the specified class in the current server */
public static int objectNum(Class cls){
IG ig = cur(); return ig==null?0:ig.getObjectNum(cls);
}
/** number of objects of the specified class in the current server; alias */
public static int objNum(Class cls){ return objectNum(cls); }
/** number of objects in the current server */
public static int objectNum(){
IG ig = cur(); return ig==null?0:ig.getObjectNum();
}
/** number of objects in the current server; alias */
public static int objNum(){ return objectNum(); }
public static void del(IObject o){ o.del(); }
public static void del(IObject[] o){
for(int i=0; i<o.length; i++){ if(o[i]!=null) o[i].del(); }
}
public static void del(ArrayList<IObject> o){
for(int i=0; i<o.size(); i++){ if(o.get(i)!=null) o.get(i).del(); }
}
/* delete all objects of specified class */
public static void del(Class cls){
IObject[] o = objects(cls);
del(o);
}
/* alias of clear(): clear all not just objects but all dynamics, graphics and layers */
public static void delAll(){ clear(); }
/* clear all not just objects but all dynamics, graphics and layers */
public static void clear(){
IG ig = cur();
if(ig!=null){ ig.clearServer(); }
}
public static ILayer layer(String layerName){
IG ig = cur();
if(ig==null) return null;
return ig.getLayer(layerName);
}
public static ILayer layer(int i){
IG ig = cur();
if(ig==null) return null;
return ig.getLayer(i);
}
public static ILayer[] layers(){
IG ig = cur();
if(ig==null) return null;
return ig.getAllLayers();
}
public static void delLayer(String layerName){
IG ig = cur();
if(ig==null) return;
ig.deleteLayer(layerName);
}
public static void delLayer(ILayer layer){
IG ig = cur();
if(ig==null) return;
ig.deleteLayer(layer);
}
public static int layerNum(){
IG ig = cur();
if(ig==null) return 0;
return ig.getLayerNum();
}
public static void focus(){
IG ig = cur();
if(ig==null) return;
ig.focusView();
}
public static boolean isGL(){
IG ig = cur();
if(ig==null){
IOut.err("no IG found");
return true; // GL is default
}
if(ig.server().graphicServer()==null){
IOut.err("no graphic server found");
return true; // GL is default
}
return ig.server().graphicServer().isGL();
}
public static void graphicMode(IGraphicMode mode){
IG ig = cur(); if(ig==null) return;
ig.server().setGraphicMode(mode);
}
/** set wireframe graphic mode */
public static void wireframe(){
IGraphicMode.GraphicType gtype = IGraphicMode.GraphicType.J2D;
if(isGL()) gtype = IGraphicMode.GraphicType.GL;
graphicMode(new IGraphicMode(gtype,false,true,false));
}
/** alias of wireframe() */
public static void wire(){ wireframe(); }
/** set fill graphic mode */
public static void fill(){
IGraphicMode.GraphicType gtype = IGraphicMode.GraphicType.J2D;
if(isGL()) gtype = IGraphicMode.GraphicType.GL;
graphicMode(new IGraphicMode(gtype,true,false,false));
}
/** set fill+wireframe graphic mode */
public static void fillWithWireframe(){ wireframeFill(); }
/** set fill+wireframe graphic mode */
public static void fillWireframe(){ wireframeFill(); }
/** set fill+wireframe graphic mode */
public static void fillWire(){ wireframeFill(); }
/** set fill+wireframe graphic mode */
public static void wireframeFill(){
IGraphicMode.GraphicType gtype = IGraphicMode.GraphicType.J2D;
if(isGL()) gtype = IGraphicMode.GraphicType.GL;
graphicMode(new IGraphicMode(gtype,true,true,false));
}
/** set fill+wireframe graphic mode */
public static void wireFill(){ wireframeFill(); }
/** set transparent fill graphic mode */
public static void transparentFill(){ transparent(); }
/** set transparent fill graphic mode */
public static void transFill(){ transparent(); }
/** set transparent fill graphic mode */
public static void transparent(){
IGraphicMode.GraphicType gtype = IGraphicMode.GraphicType.J2D;
if(isGL()) gtype = IGraphicMode.GraphicType.GL;
graphicMode(new IGraphicMode(gtype,true,false,true));
}
/** alias of transparent() */
public static void trans(){ transparent(); }
/** set transparent fill+wireframe graphic mode */
public static void transparentFillWithWireframe(){ wireframeTransparent(); }
/** set transparent fill+wireframe graphic mode */
public static void transparentWireframe(){ wireframeTransparent(); }
/** set transparent fill+wireframe graphic mode */
public static void wireframeTransparent(){
IGraphicMode.GraphicType gtype = IGraphicMode.GraphicType.J2D;
if(isGL()) gtype = IGraphicMode.GraphicType.GL;
graphicMode(new IGraphicMode(gtype,true,true,true));
}
/** alias of wireframeTransparent() */
public static void wireTrans(){ wireframeTransparent(); }
/** alias of wireframeTransparent() */
public static void transWire(){ wireframeTransparent(); }
public static void noGraphic(){
IGraphicMode.GraphicType gtype = IGraphicMode.GraphicType.J2D;
if(isGL()) gtype = IGraphicMode.GraphicType.GL;
graphicMode(new IGraphicMode(gtype,false,false,false));
}
public static IView view(int paneIndex){
IG ig = cur(); if(ig==null) return null;
if(ig==null || ig.panel==null || ig.panel.paneNum()>0 ||
ig.panel.paneNum() <= paneIndex || paneIndex<0 ){ return null; }
if(ig.panel instanceof IScreenTogglePanel){
((IScreenTogglePanel)(ig.panel)).enableFullScreen(ig.panel.pane(paneIndex));
}
return ig.panel.pane(paneIndex).getView();
}
/** put the specified pane on the full screen inside the window if the panel is IGridPanel with 2x2 grid */
public static IPane gridPane(int xindex, int yindex){
IG ig = cur(); if(ig==null) return null;
if(ig.panel!=null && ig.panel instanceof IGridPanel){
IGridPanel gpanel = (IGridPanel)ig.panel;
if(xindex>=0 && xindex < gpanel.gridPanes.length &&
yindex>=0 && yindex < gpanel.gridPanes[xindex].length ){
IPane pane = gpanel.gridPanes[xindex][yindex];
gpanel.enableFullScreen(pane);
return pane;
}
else if(gpanel.gridPanes.length>0 &&
gpanel.gridPanes[0].length>0 ){
IPane pane = gpanel.gridPanes[0][0];
gpanel.enableFullScreen(0);
return pane;
}
}
return null;
}
/** put the specified pane on the full screen inside the window if the panel is IGridPanel with 2x2 grid */
public static void disableFullScreen(){
IG ig = cur(); if(ig==null) return;
if(ig.panel!=null && ig.panel instanceof IGridPanel){
IGridPanel gpanel = (IGridPanel)ig.panel;
gpanel.disableFullScreen();
}
}
/** put top pane on the full screen inside the window if the panel is IGridPanel */
public static IPane topPane(){ return gridPane(0,0); }
/** bottom pane is identical with top pane in IGridPanel */
public static IPane bottomPane(){ return topPane(); }
/** put perspective pane on the full screen inside the window if the panel is IGridPanel */
public static IPane perspectivePane(){ return gridPane(1,0); }
/** axonometric pane is identical with perspective pane in IGridPanel */
public static IPane axonometricPane(){ return perspectivePane(); }
/** put front pane on the full screen inside the window if the panel is IGridPanel */
public static IPane frontPane(){ return gridPane(0,1); }
/** back pane is identical with front pane in IGridPanel */
public static IPane backPane(){ return frontPane(); }
/** put right pane on the full screen inside the window if the panel is IGridPanel */
public static IPane rightPane(){ return gridPane(1,1); }
/** left pane is identical with front pane in IGridPanel */
public static IPane leftPane(){ return rightPane(); }
/** put top view on the full screen inside the window */
public static void top(){
IPane pane = topPane();
if(pane!=null){
pane.getView().setTop();
pane.focus(); // added 20120615
}
}
public static void top(double x, double y){
IPane pane = topPane();
if(pane!=null){ pane.getView().setTop(x,y); }
}
public static void top(double x, double y, double z){
IPane pane = topPane();
if(pane!=null){ pane.getView().setTop(x,y,z); }
}
public static void top(double x, double y, double z, double axonRatio){
IPane pane = topPane();
if(pane!=null){ pane.getView().setTop(x,y,z,axonRatio); }
}
public static void topView(){ top(); }
public static void topView(double x, double y){ top(x,y); }
public static void topView(double x, double y, double z){ top(x,y,z); }
public static void topView(double x, double y, double z, double axonRatio){
top(x,y,z,axonRatio);
}
/** get camera position in top view pane */
public static IVec topPos(){ return getViewPos(topPane()); }
/** get camera direction vector in top view pane */
public static IVec topDir(){ return getViewDir(topPane()); }
/** get camera target position in top view pane */
public static IVec topTarget(){ return getViewTarget(topPane()); }
/** get camera direction yaw angle in top view pane */
public static double topYaw(){ return getViewYaw(topPane()); }
/** get camera direction pitch angle in top view pane */
public static double topPitch(){ return getViewPitch(topPane()); }
/** get camera direction roll angle in top view pane */
public static double topRoll(){ return getViewPitch(topPane()); }
/** put bottom view on the full screen inside the window */
public static void bottom(){
IPane pane = bottomPane();
if(pane!=null){
pane.getView().setBottom();
pane.focus(); // added 20120615
}
}
public static void bottom(double x, double y){
IPane pane = bottomPane();
if(pane!=null){ pane.getView().setBottom(x,y); }
}
public static void bottom(double x, double y, double z){
IPane pane = bottomPane();
if(pane!=null){ pane.getView().setBottom(x,y,z); }
}
public static void bottom(double x, double y, double z, double axonRatio){
IPane pane = bottomPane();
if(pane!=null){ pane.getView().setBottom(x,y,z,axonRatio); }
}
public static void bottomView(){ bottom(); }
public static void bottomView(double x, double y){ bottom(x,y); }
public static void bottomView(double x, double y, double z){ bottom(x,y,z); }
public static void bottomView(double x, double y, double z, double axonRatio){ bottom(x,y,z,axonRatio); }
/** get camera position in bottom view pane */
public static IVec bottomPos(){ return getViewPos(bottomPane()); }
/** get camera direction vector in bottom view pane */
public static IVec bottomDir(){ return getViewDir(bottomPane()); }
/** get camera target position in bottom view pane */
public static IVec bottomTarget(){ return getViewTarget(bottomPane()); }
/** get camera direction yaw angle in bottom view pane */
public static double bottomYaw(){ return getViewYaw(bottomPane()); }
/** get camera direction pitch angle in bottom view pane */
public static double bottomPitch(){ return getViewPitch(bottomPane()); }
/** get camera direction roll angle in bottom view pane */
public static double bottomRoll(){ return getViewPitch(bottomPane()); }
/** put perspective view on the full screen inside the window */
public static void perspective(){
IPane pane = perspectivePane();
if(pane!=null){
pane.getView().setPerspective();
pane.focus(); // added 20120615
}
}
public static void perspective(double x, double y, double z){
IPane pane = perspectivePane();
if(pane!=null){ pane.getView().setPerspective(x,y,z); }
}
public static void perspective(double x, double y, double z,
double yaw, double pitch){
IPane pane = perspectivePane();
if(pane!=null){ pane.getView().setPerspective(x,y,z,yaw,pitch); }
}
public static void perspective(IVecI pos, IVecI dir){
IPane pane = perspectivePane();
if(pane!=null){ pane.getView().setPerspective(pos,dir); }
}
public static void perspectiveView(){ perspective(); }
public static void perspectiveView(double x, double y, double z){ perspective(x,y,z); }
public static void perspectiveView(double x, double y, double z,
double yaw, double pitch){ perspective(x,y,z,yaw,pitch); }
public static void perspectiveView(IVecI pos, IVecI dir){ perspective(pos,dir); }
public static void pers(){ perspective(); }
public static void pers(double x, double y, double z){ perspective(x,y,z); }
public static void pers(double x, double y, double z, double yaw, double pitch){ perspective(x,y,z,yaw,pitch); }
public static void pers(IVecI pos, IVecI dir){ perspective(pos,dir); }
/** put perspective view on the full screen inside the window */
public static void perspective(double perspectiveAngle){
IPane pane = perspectivePane();
if(pane!=null){
pane.getView().setPerspective(perspectiveAngle);
}
}
public static void perspective(double x, double y, double z,
double perspectiveAngle){
IPane pane = perspectivePane();
if(pane!=null){
pane.getView().setPerspective(x,y,z,perspectiveAngle);
}
}
public static void perspective(double x, double y, double z,
double yaw, double pitch,
double perspectiveAngle){
IPane pane = perspectivePane();
if(pane!=null){
pane.getView().setPerspective(x,y,z,yaw,pitch,perspectiveAngle);
}
}
public static void perspective(IVecI pos, IVecI dir, double perspectiveAngle){
IPane pane = perspectivePane();
if(pane!=null){
pane.getView().setPerspective(pos,dir,perspectiveAngle);
}
}
public static void perspectiveView(double perspectiveAngle){ perspective(perspectiveAngle); }
public static void perspectiveView(double x, double y, double z,
double perspectiveAngle){
perspective(x,y,z,perspectiveAngle);
}
public static void perspectiveView(double x, double y, double z,
double yaw, double pitch,
double perspectiveAngle){
perspective(x,y,z,yaw,pitch,perspectiveAngle);
}
public static void perspectiveView(IVecI pos, IVecI dir, double perspectiveAngle){
perspective(pos,dir,perspectiveAngle);
}
public static void pers(double perspectiveAngle){ perspective(perspectiveAngle); }
public static void pers(double x, double y, double z, double perspectiveAngle){
perspective(x,y,z,perspectiveAngle);
}
public static void pers(double x, double y, double z, double yaw, double pitch, double perspectiveAngle){
perspective(x,y,z,yaw,pitch,perspectiveAngle);
}
public static void pers(IVecI pos, IVecI dir, double perspectiveAngle){
perspective(pos,dir,perspectiveAngle);
}
/** get camera position out of pane */
public static IVec getViewPos(IPane pane){
if(pane==null){ IG.err("no pane found"); return new IVec(); }
IView view = pane.getView();
if(view==null){ IG.err("no view found"); return new IVec(); }
return view.location();
}
/** get camera direction out of pane */
public static IVec getViewDir(IPane pane){
if(pane==null){ IG.err("no pane found"); return new IVec(); }
IView view = pane.getView();
if(view==null){ IG.err("no view found"); return new IVec(); }
return view.frontDirection();
}
/** get camera target position out of pane */
public static IVec getViewTarget(IPane pane){
if(pane==null){ IG.err("no pane found"); return new IVec(); }
IView view = pane.getView();
if(view==null){ IG.err("no view found"); return new IVec(); }
return view.target();
}
/** get camera directio yaw angle out of pane */
public static double getViewYaw(IPane pane){
if(pane==null){ IG.err("no pane found"); return 0; }
IView view = pane.getView();
if(view==null){ IG.err("no view found"); return 0; }
return view.getYaw();
}
/** get camera directio pitch angle out of pane */
public static double getViewPitch(IPane pane){
if(pane==null){ IG.err("no pane found"); return 0; }
IView view = pane.getView();
if(view==null){ IG.err("no view found"); return 0; }
return view.getPitch();
}
/** get camera directio roll angle out of pane */
public static double getViewRoll(IPane pane){
if(pane==null){ IG.err("no pane found"); return 0; }
IView view = pane.getView();
if(view==null){ IG.err("no view found"); return 0; }
return view.getRoll();
}
/** get camera position in perspective view pane */
public static IVec persPos(){ return getViewPos(perspectivePane()); }
/** get camera direction vector in perspective view pane */