Introduction
CET 12.5 introduced a new elevation view cm.abstract.materialHandling.tools.elevationG2. This elevation view is only available in material handling. The new elevation view uses a concept called Content Snappers. Content snappers are snappers that live in elevation space and is a representation of a snapper that live in model space. A content snapper is responsible for producing elevation view graphics and other custom behaviors. By default, content snappers will use the model space snapper’s 3d graphic to produce its elevation view graphics. This behavior is encouraged to override with simpler custom graphics, which will affect performance. The elevation view is also interactive, meaning when a change has occurred in model space it will be reflected in the elevation view.
Features
-
A new insert animation has been created to give better control at insertion of what will be included in the elevation view by utilizing a select rect.
-
User alternatives support has been added so you can select your elevation view as a view in view clip 2D.
-
Custom graphics support gives you the ability to create specific elevation view graphics for your snapper by overloading build2D for the snapper's content snapper.
-
Event based updates if something is changed in model space that is included in your elevation view, the elevation view will update accordingly.
Limitations
- By default, you will not be able to make changes to your content snappers that will be reflected in model space.
Getting Started
For default behavior add cm.abstract.materialHandling.tools.elevationG2.MhElevArrow to your library.
To take advantage of custom graphics and other functionality you need to create a cm.abstract.materialHandling.tools.elevationG2.MhElevContentEditor by extending it. You will register your content editor with cm.abstract.materialHandling.tools.elevationG2.registerContentEditor.
In your elevation content editor you need to override MhElevContentEditor.affects and add code that returns true if your elevation content editor will provide a content snapper for the snapper passed in. Override MhElevContentEditor.snapperAutoEnvs and provide a cm.abstract.materialHandling.tools.elevationG2.MhElevContentSnapperEnv by extending it.
The elevation auto snapper env is responsible for instantiating your content snappers, this is done in MhElevAutoSnapperEnv.instantiateSnapper. Based on the owner that is passed in with the MhElevEnv you can return your content snapper classes. All your content snapper classes will need to extend from cm.abstract.materialHandling.tools.elevationG2.MhElevContentSnapper or it will not be recognized by this system.
In your extended elevation content snapper you can provide custom graphics by extending build2D, and add all other custom functionality you want to have for your content snapper.
Example
use cm.win; use cm.std.accessories; use cm.abstract.materialHandling.tools.elevationG2; use cm.core; use cm.geometry; use cm.geometry2D; use cm.draw; /** * My elevation content editor. */ private class MyElevationContentEditor extends MhElevContentEditor { /** * Affects. */ public bool affects(Snapper z) { return z in Snowman; } /** * Override what envs that this snapper creates. */ public MhElevAutoSnapperEnv[] snapperAutoEnvs(MhElevEnv cEnv) { MhElevAutoSnapperEnv[] res(); res << MyElevationAutoSnapperEnv(cEnv); return res; } } /** * My elevation content snapper. */ public class MyElevContentSnapper extends MhElevContentSnapper { /** * Build2D. */ public void build2D() { if (!owner) { return; } orientation arrowRot = arrow.rot; box bound = owner.bound(); double w = bound.w; double d = bound.d; double h = bound.h; color c; if (fill.solid) { c = fillColor; } else if (fill.transparent) { c = color(colorType.none); } else { c = white; } alignment textAlignment = alignment.middle; GInstance g(); if (arrowRot.yaw.inside(-45deg, 45deg)) { GRect r(rect((0, 0), (w, h)), c, lt); g << r; GText t((w/2, h/2.0), "Front", textAlignment); g << t; } else if (arrowRot.yaw.inside(45deg, 135deg)) { GRect r(rect((0, 0), (d, h)), c, lt); g << r; GText t((d/2, h/2.0), "right", textAlignment); g << t; } else if (arrowRot.yaw.inside(135deg, 225deg)) { GRect r(rect((-w, 0), (0, h)), c, lt); g << r; GText t((-w+w/2, h/2.0), "back", textAlignment); g << t; } else if (arrowRot.yaw.inside(225deg, 315deg)) { GRect r(rect((-d, 0), (0, h)), c, lt); g << r; GText t((-d+d/2, h/2.0), "left", textAlignment); g << t; } graph = g; boundGraph = GRect(graph.bound); } } /** * My elevation auto snapper env. */ private class MyElevationAutoSnapperEnv extends MhElevContentSnapperEnv { /** * Instantiate snapper. */ public Snapper instantiateSnapper(MhElevEnv cEnv) { Snapper owner = cEnv.owner; if (owner in Snowman) { return MyElevContentSnapper(owner); } return null; } } { registerContentEditor("myContentEditor", new MyElevationContentEditor()); MhElevArrow elevationArrow(); elevationArrow.initAfterInstantiate(); animate(elevationArrow.insertAnimation(StartInsertAnimationEnv(null, elevationArrow))); }
Comments
0 comments
Please sign in to leave a comment.