-
Notifications
You must be signed in to change notification settings - Fork 1
Implementation and tests for Drawingelement #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ba129f3
implementation and tests for Drawingelement
5f482fb
update entities each loop
06f3c7e
update README file
db6d41c
fix each loop from the entities
442f3ce
fix path to file opened for tests
57d176c
undef TEXT
9ad0c49
Merge branch 'main' into dev/anton.chalakov/drawing_element
71ae398
changes based on pull request comments
5f525a1
fixes based on pull request comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,146 @@ | ||
| #include <stdbool.h> | ||
| #include <drawing_element.h> | ||
| #include <not_implemented.h> | ||
| #include <utils.h> | ||
| #include <SketchUpAPI/sketchup.h> | ||
|
|
||
| static VALUE Sketchup_DrawingElement_bounds(VALUE self) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| struct SUBoundingBox3D* bbox = 0; | ||
| SUDrawingElementGetBoundingBox(drawing_element, bbox); | ||
| return Data_Make_Struct(rb_path2class(GEOM_BOUNDINGBOX), struct SUBoundingBox3D, 0, RUBY_DEFAULT_FREE, bbox); | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Get_casts_shadows(VALUE self) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| bool casts_shadows_flag = false; | ||
| SUDrawingElementGetCastsShadows(drawing_element, &casts_shadows_flag); | ||
| return casts_shadows_flag ? Qtrue : Qfalse; | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Set_casts_shadows(VALUE self, VALUE casts_shadows_flag) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| SUDrawingElementSetCastsShadows(drawing_element, RTEST(casts_shadows_flag)); | ||
| return casts_shadows_flag; | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Get_receives_shadows(VALUE self) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| bool receives_shadows_flag = false; | ||
| SUDrawingElementGetReceivesShadows(drawing_element, &receives_shadows_flag); | ||
| return receives_shadows_flag ? Qtrue : Qfalse; | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Set_receives_shadows(VALUE self, VALUE receives_shadows_flag) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| SUDrawingElementSetReceivesShadows(drawing_element, RTEST(receives_shadows_flag)); | ||
| return receives_shadows_flag; | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Get_hidden(VALUE self) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| bool hide_flag = false; | ||
| SUDrawingElementGetHidden(drawing_element, &hide_flag); | ||
| return hide_flag ? Qtrue : Qfalse; | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Set_hidden(VALUE self, VALUE hide_flag) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| SUDrawingElementSetHidden(drawing_element, RTEST(hide_flag)); | ||
| return hide_flag; | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Get_visible(VALUE self) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| bool hide_flag = false; | ||
| SUDrawingElementGetHidden(drawing_element, &hide_flag); | ||
| return hide_flag ? Qfalse : Qtrue; | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Set_visible(VALUE self, VALUE visible_flag) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| SUDrawingElementSetHidden(drawing_element, RTEST(visible_flag)); | ||
| return visible_flag; | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Get_material(VALUE self) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| SUMaterialRef material = SU_INVALID; | ||
| SUDrawingElementGetMaterial(drawing_element, &material); | ||
| if (SUIsInvalid(material)) | ||
| return Qnil; | ||
| return Data_Wrap_Struct(rb_path2class(SKETCHUP_MATERIAL), 0, 0, material.ptr); | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Set_material(VALUE self, VALUE material) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| if (rb_type(material) == T_NIL) | ||
| { | ||
| SUMaterialRef empty_material = SU_INVALID; | ||
| SUDrawingElementSetMaterial(drawing_element, empty_material); | ||
| return Qnil; | ||
| } | ||
| if (!rb_obj_is_kind_of(material, rb_path2class(SKETCHUP_MATERIAL))) | ||
| rb_raise(rb_eTypeError, "Wrong type of object given"); | ||
|
|
||
| SUMaterialRef drawing_element_material = {DATA_PTR(material)}; | ||
| SUDrawingElementSetMaterial(drawing_element, drawing_element_material); | ||
noelwarren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return material; | ||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Get_layer(VALUE self) | ||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| SULayerRef layer = SU_INVALID; | ||
| SUDrawingElementGetLayer(drawing_element, &layer); | ||
| return Data_Wrap_Struct(rb_path2class(SKETCHUP_LAYER), 0, 0, layer.ptr); | ||
noelwarren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| static VALUE Sketchup_DrawingElement_Set_layer(VALUE self, VALUE layer) | ||
| { | ||
| if (rb_type(layer) == T_NIL) | ||
noelwarren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| SULayerRef drawing_element_layer = SU_INVALID; | ||
| SUDrawingElementSetLayer(drawing_element, drawing_element_layer); | ||
| return Qnil; | ||
| } | ||
| if (!rb_obj_is_kind_of(layer, rb_path2class(SKETCHUP_LAYER))) | ||
| rb_raise(rb_eArgError, "Wrong type of object given"); | ||
|
|
||
| SUDrawingElementRef drawing_element = {DATA_PTR(self)}; | ||
| SULayerRef drawing_element_layer = {DATA_PTR(layer)}; | ||
| SUDrawingElementSetLayer(drawing_element, drawing_element_layer); | ||
| return layer; | ||
| } | ||
noelwarren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| VALUE DrawingElement_Init(VALUE Sketchup, VALUE Sketchup_Entity) | ||
| { | ||
| VALUE Sketchup_DrawingElement = rb_define_class_under(Sketchup, DRAWINGELEMENT, Sketchup_Entity); | ||
| rb_undef_alloc_func(Sketchup_DrawingElement); | ||
| rb_define_method(Sketchup_DrawingElement, "bounds", Sketchup_DrawingElement_bounds, 0); | ||
| rb_define_method(Sketchup_DrawingElement, "casts_shadows?", Sketchup_DrawingElement_Get_casts_shadows, 0); | ||
| rb_define_method(Sketchup_DrawingElement, "casts_shadows=", Sketchup_DrawingElement_Set_casts_shadows, 1); | ||
| rb_define_method(Sketchup_DrawingElement, "receives_shadows?", Sketchup_DrawingElement_Get_receives_shadows, 0); | ||
| rb_define_method(Sketchup_DrawingElement, "receives_shadows=", Sketchup_DrawingElement_Set_receives_shadows, 1); | ||
| rb_define_method(Sketchup_DrawingElement, "hidden?", Sketchup_DrawingElement_Get_hidden, 0); | ||
| rb_define_method(Sketchup_DrawingElement, "hidden=", Sketchup_DrawingElement_Set_hidden, 1); | ||
| rb_define_method(Sketchup_DrawingElement, "visible?", Sketchup_DrawingElement_Get_visible, 0); | ||
| rb_define_method(Sketchup_DrawingElement, "visible=", Sketchup_DrawingElement_Set_visible, 1); | ||
| rb_define_method(Sketchup_DrawingElement, "material", Sketchup_DrawingElement_Get_material, 0); | ||
| rb_define_method(Sketchup_DrawingElement, "material=", Sketchup_DrawingElement_Set_material, 1); | ||
| rb_define_method(Sketchup_DrawingElement, "layer", Sketchup_DrawingElement_Get_layer, 0); | ||
| rb_define_method(Sketchup_DrawingElement, "layer=", Sketchup_DrawingElement_Set_layer, 1); | ||
| return Sketchup_DrawingElement; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| #include <stdbool.h> | ||
| #include <not_implemented.h> | ||
| #include <utils.h> | ||
| #include <SketchUpAPI/sketchup.h> | ||
|
|
||
| VALUE BoundingBox_Init(VALUE Geom, VALUE Sketchup_Object) | ||
| { | ||
| VALUE Geom_BoundingBox = rb_define_class_under(Geom, BOUNDINGBOX, Sketchup_Object); | ||
| rb_undef_alloc_func(Geom_BoundingBox); | ||
| return Geom_BoundingBox; | ||
| } | ||
|
|
||
| VALUE Face_Init(VALUE Sketchup, VALUE DrawingElement) | ||
| { | ||
| VALUE Sketchup_Face = rb_define_class_under(Sketchup, FACE, DrawingElement); | ||
| rb_undef_alloc_func(Sketchup_Face); | ||
| return Sketchup_Face; | ||
| } | ||
|
|
||
| VALUE Layer_Init(VALUE Sketchup, VALUE Entity) | ||
| { | ||
| VALUE Sketchup_Layer = rb_define_class_under(Sketchup, LAYER, Entity); | ||
| rb_undef_alloc_func(Sketchup_Layer); | ||
| return Sketchup_Layer; | ||
| } | ||
|
|
||
| VALUE ConstructionLine_Init(VALUE Sketchup, VALUE DrawingElement) | ||
| { | ||
| VALUE Sketchup_ConstructionLine = rb_define_class_under(Sketchup, CONSTRUCTIONLINE, DrawingElement); | ||
| rb_undef_alloc_func(Sketchup_ConstructionLine); | ||
| return Sketchup_ConstructionLine; | ||
| } | ||
|
|
||
| VALUE ConstructionPoint_Init(VALUE Sketchup, VALUE DrawingElement) | ||
| { | ||
| VALUE Sketchup_ConstructionPoint = rb_define_class_under(Sketchup, CONSTRUCTIONPOINT, DrawingElement); | ||
| rb_undef_alloc_func(Sketchup_ConstructionPoint); | ||
| return Sketchup_ConstructionPoint; | ||
| } | ||
|
|
||
| VALUE Dimension_Init(VALUE Sketchup, VALUE DrawingElement) | ||
| { | ||
| VALUE Sketchup_Dimension = rb_define_class_under(Sketchup, DIMENSION, DrawingElement); | ||
| rb_undef_alloc_func(Sketchup_Dimension); | ||
| return Sketchup_Dimension; | ||
| } | ||
|
|
||
| VALUE Edge_Init(VALUE Sketchup, VALUE DrawingElement) | ||
| { | ||
| VALUE Sketchup_Edge = rb_define_class_under(Sketchup, EDGE, DrawingElement); | ||
| rb_undef_alloc_func(Sketchup_Edge); | ||
| return Sketchup_Edge; | ||
| } | ||
|
|
||
| VALUE Group_Init(VALUE Sketchup, VALUE DrawingElement) | ||
| { | ||
| VALUE Sketchup_Group = rb_define_class_under(Sketchup, GROUP, DrawingElement); | ||
| rb_undef_alloc_func(Sketchup_Group); | ||
| return Sketchup_Group; | ||
| } | ||
|
|
||
| VALUE Image_Init(VALUE Sketchup, VALUE DrawingElement) | ||
| { | ||
| VALUE Sketchup_Image = rb_define_class_under(Sketchup, IMAGE, DrawingElement); | ||
| rb_undef_alloc_func(Sketchup_Image); | ||
| return Sketchup_Image; | ||
| } | ||
|
|
||
| VALUE SectionPlane_Init(VALUE Sketchup, VALUE DrawingElement) | ||
| { | ||
| VALUE Sketchup_SectionPlane = rb_define_class_under(Sketchup, SECTIONPLANE, DrawingElement); | ||
| rb_undef_alloc_func(Sketchup_SectionPlane); | ||
| return Sketchup_SectionPlane; | ||
| } | ||
|
|
||
| VALUE Text_Init(VALUE Sketchup, VALUE DrawingElement) | ||
| { | ||
| VALUE Sketchup_Text = rb_define_class_under(Sketchup, TEXT, DrawingElement); | ||
| rb_undef_alloc_func(Sketchup_Text); | ||
| return Sketchup_Text; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #include <ruby.h> | ||
|
|
||
| VALUE BoundingBox_Init(VALUE namespace_object, VALUE parent_class); | ||
| VALUE Face_Init(VALUE namespace_object, VALUE parent_class); | ||
| VALUE Layer_Init(VALUE namespace_object, VALUE parent_class); | ||
| VALUE ConstructionLine_Init(VALUE namespace_object, VALUE parent_class); | ||
| VALUE ConstructionPoint_Init(VALUE namespace_object, VALUE parent_class); | ||
| VALUE Dimension_Init(VALUE namespace_object, VALUE parent_class); | ||
| VALUE Edge_Init(VALUE namespace_object, VALUE parent_class); | ||
| VALUE Group_Init(VALUE namespace_object, VALUE parent_class); | ||
| VALUE Image_Init(VALUE namespace_object, VALUE parent_class); | ||
| VALUE SectionPlane_Init(VALUE namespace_object, VALUE parent_class); | ||
| VALUE Text_Init(VALUE namespace_object, VALUE parent_class); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.