How to remove all cut planes when using restoreState in Forge Viewer - autodesk-forge

I'm using the restoreState function to set cut planes and it works just fine:
NOP_VIEWER.restoreState(JSON.parse('{"cutplanes": [[0,0,0,0]]}'));
But how do I remove the cut planes again? Show all objects do not work and neither do
NOP_VIEWER.restoreState(JSON.parse('{"cutplanes": []}'));
or
NOP_VIEWER.setCutPlanes();

One way to do it is
NOP_VIEWER.restoreState(JSON.parse('{"cutplanes": null}'));

According to documentation you have to pass an empty array to setCutPlanes()
https://forge.autodesk.com/en/docs/viewer/v7/reference/Viewing/Viewer3D/#setcutplanes-planes
Passing an empty list or null is equivalent to setting zero cut planes

Related

Inserting tags by clicking on the objet

I have a question about the coordinates of the model.
Would it be possible to register a problem with a tag in the model, defining the exact location by clicking on the model?
enter image description here
PS.: on this example, only it is possible to use central coordinates of the object
To get the exact x,y,z value, use this 'ALT-key pivot point' technique, to get the surface point of a model, instead of it's centroid:
https://github.com/wallabyway/markupExt/issues/2
Second part:
Once you have the x,y,z value, you can replace 'centroid' position calulation, in this post:
https://forge.autodesk.com/blog/placing-custom-markup-dbid
// get the center of the dbId (based on its fragIds bounding boxes)
const pos = this.viewer.worldToClient(this.getModifiedWorldBoundingBox(id).center());
Does that help?

checking if point is in polygon giving null values

there are many post relating to this matter but most are old and there seem to be many different way of doing it.
I am trying to see if point exists inside a polygon however it is giving null value even though it is point on polygon.
here is my code.
select ST_contains(ST_geomfromtext('
Polygon((127.090656 37.517137,
127.092416 37.512525,
127.098445 37.513836,
127.095227 37.518346))'), Point(127.090656, 37.517137));
Thanks in advance.
In Mysql you need to close the polygon therefore I must add first point at the end of polygon again.
select ST_contains(ST_geomfromtext('
Polygon((**127.090656 37.517137**,
127.092416 37.512525,
127.098445 37.513836,
127.095227 37.518346,
**127.090656 37.517137**))'), Point(127.090656, 37.517137));
which now fixes my problem
and for cleaniness
I can set polygon as
SET #location_1 = ST_geomfromtext('
Polygon((**127.090656 37.517137**,
127.092416 37.512525,
127.098445 37.513836,
127.095227 37.518346,
**127.090656 37.517137**))');
select ST_contains( #location_1, Point(127.090656, 37.517137));
which to me is much cleaner. But maybe it require more memory for #location_1 in db (I'm not sure)?

MySQL ST_CONTAINS on Overlap case

I'm facing a problem using the ST_CONTAINS geospatial function on MySQL 5.6.31.
I've the following MULTIPOLYGON:
I need to check if some point is inside a MULTIPOLYGON, in this case the red one on the image, so i do:
SET #g1 = ST_GEOMFROMTEXT('MULTIPOLYGON(((41.94142040508967 12.41757292797851,41.94442097040815 12.419032049682611,41.93529115206086 12.43456740429687,41.91939065648979 12.425126028564447,41.92475512204906 12.407702398803705,41.94142040508967 12.41757292797851),(41.92552143745503 12.409933996704096,41.90987400689221 12.402638388183588,41.90252797153794 12.421864462402338,41.907446714803015 12.433194113281244,41.92603230927889 12.419461203124994,41.92552143745503 12.409933996704096,41.92552143745503 12.409933996704096),(41.906248516384416 12.397567221513638,41.89551602293968 12.423402258745083,41.90101026279693 12.430268713823208,41.90771770545893 12.420398184648404,41.91033661082307 12.39653725325192,41.906248516384416 12.397567221513599,41.906248516384416 12.397567221513599,41.906248516384416 12.397567221513638,41.906248516384416 12.39756722151363,41.906248516384416 12.39756722151363,41.906248516384416 12.39756722151363,41.906248516384416 12.39756722151363,41.906248516384416 12.39756722151363,41.906248516384416 12.39756722151363,41.906248516384416 12.39756722151363,41.906248516384416 12.39756722151363,41.906248516384416 12.39756722151363,41.906248516384416 12.397567221513638)))');
SET #g2 = POINT(41.9059998,12.4159939);
SELECT ST_CONTAINS(#g1,#g2);
The result is 0.
If i change the point, specifying for example a point in the upper polygon, i got 1.
Why this behaviour? It seems that when two polygons overlaps the ST_CONTAINS see it as en empty part of them.
What can i do?
Thanks to all!
That's a weird (not standard compliant and probably invalid) multipolygon.
Multipolygon is described as something like:
MULTIPOLYGON(((p1_shell), (p1_hole1), (p1_hole2)), ((p2_shell), (p2_hole1), (p2_hole2)))
I.e. polygons are separated by double round brackets, and polygon shell is separated from holes by single round brackets. In your case it is single brackets - so this WKT describes a single polygon with two holes! Note that it is not a valid one (you can call ST_IsValid to check) - the hole is not fully contained within the shell as required by standard But anyway MySql allows this, and since the red point is within hole, it is not contained by the shape, so MySql result is correct.
If the desired semantic of the shape is a multipolygon, not polygon with holes, replace ),( with )),(( to get that semantics. Note that this is still not valid WKT shape - individual polygons in a multipolygon are not allowed to intersect (again check with ST_IsValid). But it should give you correct result anyway (although, being non-standard, this is somewhat undefined behavior).
If you want to be standard-compliant, you should clean this WKT. What you do depends on semantics you need. Maybe ST_UNION these polygons and get a single one. Or to keep all three - the correct way to describe a shape consisting of possibly intersecting polygons is GEOMETRYCOLLECTION with polygons as members.

how to add line chart in October CMS?

I want to add a line chart as a control chart in one of the widget pages in October CMS. CMS has pre-built classes for bar chart and pie chart. I was wondering if they have similar classes for other kind of analytics data.
I want to add the line chart prebuilt class to an html partials page, that can be used as a widget in october cms.
It seems that you are talking about things like this: https://octobercms.com/docs/ui/chart and you are looking for another type of chart besides those mentioned there.
I wanted to say if such a thing is not listed there then probably it does not exist. But... hey... I just went looking into the backend UI JS code.
Look at this file in your October app root: {% app root %}/modules/system/assets/ui/js/chart.line.js
/*
* Line Chart Plugin
*
* Data attributes:
* - data-control="chart-line" - enables the line chart plugin
* - data-reset-zoom-link="#reset-zoom" - specifies a link to reset zoom
* - data-zoomable - indicates that the chart is zoomable
* - data-time-mode="weeks" - if the "weeks" value is specified and the xaxis mo
de is "time", the X axis labels will be displayed as week end dates.
* - data-chart-options="xaxis: {mode: 'time'}" - specifies the Flot configurati
on in JSON format. See https://github.com/flot/flot/blob/master/API.md for detai
ls.
*
* Data sets are defined with the SPAN elements inside the chart element: <span
data-chart="dataset" data-set-data="[0,0],[1,19]">
* Data set elements could contain data attributes with names in the format "dat
a-set-color". The names for the data set
* attributes are described in the Flot documentation: https://github.com/flot/f
lot/blob/master/API.md#data-format
*
* JavaScript API:
* $('.chart').chartLine({ resetZoomLink:'#reset-zoom' })
*
So the functionality is there, it seems, but it's not in the public docs. Looks like you could try out something like this
<div
class="control-chart"
data-control="chart-line"
style="min-height:400px"
data-zoomable="1"
data-reset-zoom-link="#reset-zoom"
data->
<span data-chart="dataset" data-set-label="Graph me tender" data-set-data="[0,0],[1,5],[3,8],[4,2],[5,6]">
Graph me tender
</span>
<span data-chart="dataset" data-set-label="Graph me sweet" data-set-data="[0,0],[1,5],[3,8],[4,2]">
Graph me sweet
</span>
</div>
<a id="#reset-zoom" href="#">Reset zoom</a>
(Edit: There was a somewhat "dirty" tweak necessary here: I added a min-height css attribute, otherwise there was an error thrown. Maybe there should be some additional class for that instead which I do not know. Also, the two data-sets are not plotted in order (the second is plotted first) and are wrongly labeled in the legend, and appear horizontally connected to each other. The zoom function does not seem to work, etc, etc. I think this line graph thingy is possibly still work in progress and that might be the reason why it is not included in the docs yet. )
, play around with it and see what it does. (I have not tested this and hope it works somehow.) If I understand correctly it should give you a zoomable line graph with data points [0,0],[1,5],[3,8],[4,2],[5,6] (x,y coordinate points) and the link below should reset the zoom (edit: zooming does not work. maybe need to set some additional options for that)
The whole thing seems to be based on this Flot JQuery chart library. So you might find some good further hints there or here, besides reading October's {% app root %}/modules/system/assets/ui/js/chart.line.js source code.

Cannot create more then two c3js graphs on a page

We are using the following code (generated by php but finally this is on client side)
c3.generate({'bindto':'#b65d3422__salestaffcommunication_xepan_base_view_chart_chart','data':{'keys':{'x':'name','value':['Email','Call','Meeting']},'groups':[['Email','Call','Meeting']],'json':[],'type':'bar'},'axis':{'x':{'type':'category'},'rotated':true},'onrendered':function(ev,ui){$(".widget-grid").masonry({'itemSelector':'.widget'})}});
c3.generate({'bindto':'#f67e14d8__t_masscommunication_xepan_base_view_chart_chart','data':{'keys':{'x':'name','value':['Newsletter','TeleMarketing']},'groups':[['Newsletter','TeleMarketing']],'json':[],'type':'bar'},'axis':{'x':{'type':'category'},'rotated':true},'onrendered':function(ev,ui){$(".widget-grid").masonry({'itemSelector':'.widget'})}});
c3.generate({'bindto':'#517df254__ableworkforce_xepan_base_view_chart_chart','data':{'columns':[['present',11.111111111111]],'type':'gauge'},'color':{'pattern':['#FF0000','#F97600','#F6C600','#60B044'],'threshold':{'values':[30,60,90,100]}},'onrendered':function(ev,ui){$(".widget-grid").masonry({'itemSelector':'.widget'})}});
And last graph is not drawn. showing
SyntaxError (DOM Exception 12): The string did not match the expected pattern.
However, I can run ANY two and it works fine. that means all code is perfect but once second one is drawn ( no matter in which order). Third one doesn't draws.
Is it any known bug, or any workaround known.
Using v0.4.11 of c3 from c3js.org
Here is my jsfiddle
https://jsfiddle.net/2yy2mjaf/1/
Thank you.
IDs cannot start with a number, which is the case of your third ID.
The simple solution is just adding a letter to it:
'bindto':'#a517df254_ //just put an "a" before the number here
Here is your fiddle: https://jsfiddle.net/7dkLdg32/