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 4b155b4c..fec62308 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();
@@ -598,7 +598,65 @@ var Circle = function GLCircle() {
598 } 598 }
599 }; 599 };
600 600
601 this.export = function() { 601 this.exportJSON = function()
602 {
603 var jObj =
604 {
605 'type' : this.geomType(),
606 'xoff' : this._xOffset,
607 'yoff' : this._yOffset,
608 'width' : this._width,
609 'height' : this._height,
610 'strokeWidth' : this._strokeWidth,
611 'strokeColor' : this._strokeColor,
612 'fillColor' : this._fillColor,
613 'innerRadius' : this._innerRadius,
614 'strokeStyle' : this._strokeStyle,
615 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(),
616 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : MaterialsModel.getDefaultMaterialName(),
617 'materials' : this.exportMaterialsJSON()
618 };
619
620 return jObj;
621 };
622
623 this.importJSON = function( jObj )
624 {
625 this._xOffset = jObj.xoff;
626 this._yOffset = jObj.yoff;
627 this._width = jObj.width;
628 this._height = jObj.height;
629 this._strokeWidth = jObj.strokeWidth;
630 this._strokeColor = jObj.strokeColor;
631 this._fillColor = jObj.fillColor;
632 this._innerRadius = jObj.innerRadius;
633 this._strokeStyle = jObj.strokeStyle;
634 var strokeMaterialName = jObj.strokeMat;
635 var fillMaterialName = jObj.fillMat;
636 this.importMaterialsJSON( jObj.materials );
637
638 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
639 if (!strokeMat) {
640 console.log( "object material not found in library: " + strokeMaterialName );
641 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
642 }
643 else
644 strokeMat = strokeMat.dup();
645 this._strokeMaterial = strokeMat;
646
647 var fillMat = MaterialsModel.getMaterial( fillMaterialName );
648 if (!fillMat) {
649 console.log( "object material not found in library: " + fillMaterialName );
650 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
651 }
652 else
653 fillMat = fillMat.dup();
654 this._fillMaterial = fillMat;
655 };
656
657
658 this.export = function()
659 {
602 var rtnStr = "type: " + this.geomType() + "\n"; 660 var rtnStr = "type: " + this.geomType() + "\n";
603 661
604 rtnStr += "xoff: " + this._xOffset + "\n"; 662 rtnStr += "xoff: " + this._xOffset + "\n";
@@ -627,7 +685,7 @@ var Circle = function GLCircle() {
627 if (this._strokeMaterial) { 685 if (this._strokeMaterial) {
628 rtnStr += this._strokeMaterial.getName(); 686 rtnStr += this._strokeMaterial.getName();
629 } else { 687 } else {
630 rtnStr += "flatMaterial"; 688 rtnStr += MaterialsModel.getDefaultMaterialName();
631 } 689 }
632 690
633 rtnStr += "\n"; 691 rtnStr += "\n";
@@ -636,7 +694,7 @@ var Circle = function GLCircle() {
636 if (this._fillMaterial) { 694 if (this._fillMaterial) {
637 rtnStr += this._fillMaterial.getName(); 695 rtnStr += this._fillMaterial.getName();
638 } else { 696 } else {
639 rtnStr += "flatMaterial"; 697 rtnStr += MaterialsModel.getDefaultMaterialName();
640 } 698 }
641 rtnStr += "\n"; 699 rtnStr += "\n";
642 700
@@ -675,7 +733,7 @@ var Circle = function GLCircle() {
675 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); 733 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
676 if (!strokeMat) { 734 if (!strokeMat) {
677 console.log( "object material not found in library: " + strokeMaterialName ); 735 console.log( "object material not found in library: " + strokeMaterialName );
678 strokeMat = MaterialsModel.exportFlatMaterial(); 736 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
679 } 737 }
680 738
681 this._strokeMaterial = strokeMat; 739 this._strokeMaterial = strokeMat;
@@ -683,7 +741,7 @@ var Circle = function GLCircle() {
683 var fillMat = MaterialsModel.getMaterial( fillMaterialName ); 741 var fillMat = MaterialsModel.getMaterial( fillMaterialName );
684 if (!fillMat) { 742 if (!fillMat) {
685 console.log( "object material not found in library: " + fillMaterialName ); 743 console.log( "object material not found in library: " + fillMaterialName );
686 fillMat = MaterialsModel.exportFlatMaterial(); 744 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
687 } 745 }
688 this._fillMaterial = fillMat; 746 this._fillMaterial = fillMat;
689 747