use of org.cesiumjs.cs.scene.interaction.options.CorridorPrimitiveOptions in project gwt-cs by iSergio.
the class DrawInteraction method startDrawing.
private void startDrawing(Object event) {
if (!active) {
return;
}
MouseDownEvent mouseDownEvent = (MouseDownEvent) event;
if (mouseDownEvent.position == null) {
return;
}
Cartesian3 cartesian;
if (scene.mode.equals(SceneMode.SCENE3D())) {
Ray ray = scene.camera().getPickRay(mouseDownEvent.position);
cartesian = scene.globe.pick(ray, scene);
} else {
cartesian = scene.camera().pickEllipsoid(mouseDownEvent.position, scene.globe.ellipsoid);
}
if (cartesian == null) {
return;
}
Event startEvent = new Event(EventType.DRAW_START, options.type);
if (type == PrimitiveType.RECTANGLE) {
if (rectangle == null) {
firstPoint = scene.globe.ellipsoid.cartesianToCartographic(cartesian);
Rectangle value = getExtent(firstPoint, firstPoint);
updateExtent(value);
// startEvent.setPrimitive();
} else {
finishDrawing();
}
} else if (type == PrimitiveType.POLYGON || type == PrimitiveType.CORRIDOR) {
if (polygon == null && type == PrimitiveType.POLYGON) {
polygon = new PolygonPrimitive(options);
JsObject.setProperty(polygon, "asynchronous", false);
collection.add(polygon);
startEvent.setPrimitive(polygon);
for (Listener listener : drawStartListeners) {
listener.onDraw(startEvent);
}
} else if (corridor == null && type == PrimitiveType.CORRIDOR) {
corridor = new CorridorPrimitive(scene, new CorridorPrimitiveOptions(options));
JsObject.setProperty(corridor, "asynchronous", false);
collection.add(corridor);
startEvent.setPrimitive(corridor);
for (Listener listener : drawStartListeners) {
listener.onDraw(startEvent);
}
}
if (markers == null) {
markers = new MarkerGroup(scene, options);
}
if (positions.size() == 0) {
positions.add(cartesian.clone());
markers.add(positions.get(0));
}
if (positions.size() >= options.minPoints) {
if (type == PrimitiveType.POLYGON) {
polygon.setPositions(positions.toArray(new Cartesian3[positions.size()]));
polygon.createPrimitive = true;
} else {
corridor.setPositions(positions.toArray(new Cartesian3[positions.size()]));
corridor.createPrimitive = true;
}
}
positions.add(cartesian);
markers.add(cartesian);
} else if (type == PrimitiveType.CIRCLE) {
if (circle == null) {
CirclePrimitiveOptions circlePrimitiveOptions = new CirclePrimitiveOptions(options);
circlePrimitiveOptions.center = cartesian;
circlePrimitiveOptions.radius = 0;
circle = new CirclePrimitive(circlePrimitiveOptions);
collection.add(circle);
startEvent.setPrimitive(circle);
for (Listener listener : drawStartListeners) {
listener.onDraw(startEvent);
}
// Markers
markers = new MarkerGroup(scene, options);
markers.add(cartesian);
// Create radius
CorridorPrimitiveOptions radiusOptions = new CorridorPrimitiveOptions(options);
radiusOptions.color = Color.YELLOW();
radiusOptions.minPoints = 2;
radius = new CorridorPrimitive(scene, radiusOptions);
JsObject.setProperty(radius, "asynchronous", false);
collection.add(radius);
if (positions.size() == 0) {
positions.add(cartesian.clone());
}
radius.setPositions(positions.toArray(new Cartesian3[positions.size()]));
radius.createPrimitive = true;
positions.add(cartesian);
} else {
// Done
finishDrawing();
}
} else if (type == PrimitiveType.POINT) {
if (point == null) {
point = new org.cesiumjs.cs.scene.interaction.PointPrimitive(scene, new CorridorPrimitiveOptions(options));
positions.add(cartesian.clone());
point.setPositions(positions.toArray(new Cartesian3[positions.size()]));
collection.add(point);
finishDrawing();
}
}
}
Aggregations