aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/circle.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/circle.js')
-rwxr-xr-xjs/lib/geom/circle.js72
1 files changed, 65 insertions, 7 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index f94d4e6b..7d1a3452 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -53,13 +53,13 @@ var Circle = function GLCircle() {
53 if(strokeMaterial){ 53 if(strokeMaterial){
54 this._strokeMaterial = strokeMaterial; 54 this._strokeMaterial = strokeMaterial;
55 } else { 55 } else {
56 this._strokeMaterial = MaterialsModel.exportFlatMaterial(); 56 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
57 } 57 }
58 58
59 if(fillMaterial) { 59 if(fillMaterial) {
60 this._fillMaterial = fillMaterial; 60 this._fillMaterial = fillMaterial;
61 } else { 61 } else {
62 this._fillMaterial = MaterialsModel.exportFlatMaterial(); 62 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
63 } 63 }
64 64
65 this.exportMaterials(); 65 this.exportMaterials();
@@ -551,7 +551,65 @@ var Circle = function GLCircle() {
551 } 551 }
552 }; 552 };
553 553
554 this.export = function() { 554 this.exportJSON = function()
555 {
556 var jObj =
557 {
558 'type' : this.geomType(),
559 'xoff' : this._xOffset,
560 'yoff' : this._yOffset,
561 'width' : this._width,
562 'height' : this._height,
563 'strokeWidth' : this._strokeWidth,
564 'strokeColor' : this._strokeColor,
565 'fillColor' : this._fillColor,
566 'innerRadius' : this._innerRadius,
567 'strokeStyle' : this._strokeStyle,
568 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(),
569 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : MaterialsModel.getDefaultMaterialName(),
570 'materials' : this.exportMaterialsJSON()
571 };
572
573 return jObj;
574 };
575
576 this.importJSON = function( jObj )
577 {
578 this._xOffset = jObj.xoff;
579 this._yOffset = jObj.yoff;
580 this._width = jObj.width;
581 this._height = jObj.height;
582 this._strokeWidth = jObj.strokeWidth;
583 this._strokeColor = jObj.strokeColor;
584 this._fillColor = jObj.fillColor;
585 this._innerRadius = jObj.innerRadius;
586 this._strokeStyle = jObj.strokeStyle;
587 var strokeMaterialName = jObj.strokeMat;
588 var fillMaterialName = jObj.fillMat;
589 this.importMaterialsJSON( jObj.materials );
590
591 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
592 if (!strokeMat) {
593 console.log( "object material not found in library: " + strokeMaterialName );
594 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
595 }
596 else
597 strokeMat = strokeMat.dup();
598 this._strokeMaterial = strokeMat;
599
600 var fillMat = MaterialsModel.getMaterial( fillMaterialName );
601 if (!fillMat) {
602 console.log( "object material not found in library: " + fillMaterialName );
603 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
604 }
605 else
606 fillMat = fillMat.dup();
607 this._fillMaterial = fillMat;
608 };
609
610
611 this.export = function()
612 {
555 var rtnStr = "type: " + this.geomType() + "\n"; 613 var rtnStr = "type: " + this.geomType() + "\n";
556 614
557 rtnStr += "xoff: " + this._xOffset + "\n"; 615 rtnStr += "xoff: " + this._xOffset + "\n";
@@ -568,7 +626,7 @@ var Circle = function GLCircle() {
568 if (this._strokeMaterial) { 626 if (this._strokeMaterial) {
569 rtnStr += this._strokeMaterial.getName(); 627 rtnStr += this._strokeMaterial.getName();
570 } else { 628 } else {
571 rtnStr += "flatMaterial"; 629 rtnStr += MaterialsModel.getDefaultMaterialName();
572 } 630 }
573 631
574 rtnStr += "\n"; 632 rtnStr += "\n";
@@ -577,7 +635,7 @@ var Circle = function GLCircle() {
577 if (this._fillMaterial) { 635 if (this._fillMaterial) {
578 rtnStr += this._fillMaterial.getName(); 636 rtnStr += this._fillMaterial.getName();
579 } else { 637 } else {
580 rtnStr += "flatMaterial"; 638 rtnStr += MaterialsModel.getDefaultMaterialName();
581 } 639 }
582 rtnStr += "\n"; 640 rtnStr += "\n";
583 641
@@ -602,7 +660,7 @@ var Circle = function GLCircle() {
602 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); 660 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
603 if (!strokeMat) { 661 if (!strokeMat) {
604 console.log( "object material not found in library: " + strokeMaterialName ); 662 console.log( "object material not found in library: " + strokeMaterialName );
605 strokeMat = MaterialsModel.exportFlatMaterial(); 663 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
606 } 664 }
607 665
608 this._strokeMaterial = strokeMat; 666 this._strokeMaterial = strokeMat;
@@ -610,7 +668,7 @@ var Circle = function GLCircle() {
610 var fillMat = MaterialsModel.getMaterial( fillMaterialName ); 668 var fillMat = MaterialsModel.getMaterial( fillMaterialName );
611 if (!fillMat) { 669 if (!fillMat) {
612 console.log( "object material not found in library: " + fillMaterialName ); 670 console.log( "object material not found in library: " + fillMaterialName );
613 fillMat = MaterialsModel.exportFlatMaterial(); 671 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
614 } 672 }
615 this._fillMaterial = fillMat; 673 this._fillMaterial = fillMat;
616 674