Autodesk forge highlight child object - visual-studio-code

Recently i've been working on this repository https://github.com/xiaodongliang/forgeviewer_embed_in_powerbi_report to build a custom visual in Power BI to visualize the issues extracted from Bim track'S API.
The idea was visualizing them in associaton to the model's ROOMS.
In order to do that I worked with a NWC file, so i cuold export rooms as a geometry.
What i would like to do now is to highligt the rooms if a connected issue is selected from a table.
The problem is When i select an issue from a table, in the selection tree i can see highlighted the parent object name (ROOM) instead of the child (solid), and i think that is why i can't achieve my purpose (if not please correct me).
what i have
what i wold like to do
Does anyone know a way to do that?

If you would like to change your selection between (FIRST_OBJECT, LAST_OBJECT, LEAF_OBJECT) you can change viewer selection settings in order to test:
If you would like to achieve this programmatically :
Viewer.setSelectionMode();
could help you as well.

If I well understood, you want to highlight the child (which contain the mesh) instead of the parent.
The object highlight (isolate) is done in /forgePowerbiView/src/visual.ts with this code:
const dbIds = options.dataViews[0].table.rows.map(r =>
<number>r[0].valueOf());
console.log('dbIds: ' +dbIds)
this.forge_viewer.showAll();
this.forge_viewer.impl.setGhostingBrightness(true); //for isolate effect
this.forge_viewer.isolate(dbIds);
Take a look at this link Enumerating leaf nodes on Viewer. This will help you to get the dbIds you want to isolate.

Related

PyQGIS: change expression for datadefined symbology

I have a QGIS project that displays calculation results on a map. There are several vector layers, each with >100 calculated fields. The way the data should be visualised is very similar for all these layers/fields. I try to write a script that duplicates a template layer, and changes the expressions for the symbology according to the selected fieldname.
Below is a screenshot of the properties I try to access (if I were to change them using the UI).
How do I access/change the expressions of the line width and line offset of a graduated symbology in PyQGIS?
In case someone else runs into this issue.
I solved it using a workaround. I saved the style of the source layer to a qml-file, for the duplicated layers I create a temporary copy of the qml-file, do a search-and-replace on the qml-file and apply this to the new layer using
newLayer.loadNamedStyle(pathToTheTempQmlFile)
Hope this helps:
rule=layer.renderer().rootRule().children()[0]
rule.setFilterExpression('whatever')
see:
QgsRuleBasedRenderer.Rule

Use Template on Invisible Table for inserting into existing bound sap.m.Table

Excuse the confusing language but hopefully this makes sense: (see code for more clear explanation)
I have a requirement to display a list of "spare parts" in an sap.m.Table but there is the ability if one of these "spare parts" has a related "spare part" (e.g. A heavy duty version, a light version, etc) , that you can click a button on the row and display these related "spare parts" by inserting them immediately below the "spare part" in question.
While I can get the sap.m.Table doing what I want to do, I would like to take advantage of templates and binding to create a temporary sap.m.Table; bind it to the relationship that returns these alternate spare parts; and reuse the template for a row to give me an array of ColumnListItems which I can insert into the Table at the right place.
Unfortunately, doing this, a sap.m.Table has a feature that if it is not displayed, it doesn't actually make the Odata call and leverage the template function.
To explain possibly much clearer, refer to this jsbin:
http://jsbin.com/sihofu/4/edit?html,js,output
Any better ideas on how to generate template output for a binding without using a sap.m.Table; or alternative, getting the sap.m.Table to make the call without placing it on the screen visible (temporarily)?
The specific code to look at is as follows:
var oTable2 = new sap.m.Table();
oTable2.attachUpdateFinished(function() {
console.log("But this one doesn't");
// What I'm trying to do here is insert these entries below Key 1
});
oTable2.bindAggregation("items", {
path: "/ExampleSecondaryValues",
template: oTemplate,
});
Thanks,
Matt
Back from Holidays now and solved this problem with a bit of brute force by simply enhancing/extending the sap.m.table control slightly.
The problem was if the control was invisible, nothing was rendered, and some optimisation within UI5 core means that in the case nothing is rendered, the AfterRender event is not called on the control and this event is what fires the UpdateFinished event.
I won't debate whether that optimisation is appropriate or not, but to fix this I simply extended the table control with a new control which looks like as follows:
sap.m.Table.extend("my.InvisibleTable", {
renderer: function(oRm, oControl) {
oRm.write("<span");
oRm.writeControlData(oControl);
oRm.write("></span>");
}
});
e.g. Simply always rendering something in the render function, causes the AfterRender event to be called; which in turns allows the sap.m.Table to fire the UpdateFinished event which allows me to then safely get the rendered template items to insert in my visible table.
Would love to know a much better way of doing this (possibly using the template control or similar), but this works okay to solve the problem.
Cheers,
Matt

CQ5/AEM: Creating sidekick components using 1 cq:component + multiple data nodes

I am working on a component that is essentially a building tool. I can't go into a lot of detail as to what it is, however the greatest parallel I can draw is that of a product list builder. The concept being that the author wants to create custom lists of products. These lists will live in a singular place and be referenced from many different pages within our content.
work flow:
create && build /content/myproductList
content/mySite/myPage/jcr:content/specialListView #property list points to /content/myproductList
Currently everything is pretty hunky dory and is working fine. The authors wanted the list building to be drag and drop, just like the rest of the site. So I created components to represent the list items and they can just open up a new builder, and drag/drop/reorder the list as much as they like and it will be refreshed within the 'specialListView'.
There is a huge flaw in my design and I want to see if I can overcome it. The flaw is etched in the way that I create the list item components. Essentially all of the items are structurally identical(in terms of markup), they just differ in content. So what I did was created a base component to control the markup and basic workflows (dialog, etc). Then I created a new component for each list item, these components have nothing but cq:template nodes that hold their information.
ex structure:
components/lists
| defaultItem
| defaultItem.jsp
| dialog.xml
| customeItem1
| .content.xml (resourceSuperType = components/lists/defaultItem)
| _cq_template.xml (has custom information)
| customeItem2
| .content.xml (resourceSuperType = components/lists/defaultItem)
| _cq_template.xml (has custom information)
...etc for 25+ items
By setting it up this way, we now have a workflow where the authors can drag and drop the components directly onto the page and not need to configure them or open dialogs and choose the correct dataset/etc. However, this seems extremely long winded and bulky. Scalability is an issue as well (what if they want to create 100 new items tomorrow -- sadly this is my reality).
What I'm proposing is to find a way to normalize this down so that I have a set of data (the list items) and 1 component to act as my structure.
something like:
/etc/data/lists/items
item 1
- nt:unstructured
- label=foo
- type=defaultItem
...etc
... etc, etc for all 25+ items
/apps/myapp/components/lists
defaultItem
| defaultItem.jsp
| dialog.xml
This is where I get stuck. If I have a structure like this, it makes it very difficult to have item1,item2,item3,...etc show up in the sidekick as drag and drop elements. I'm guessing I will need to get into the portion of JS that generates the sidekick items, but I'm not sure how to approach it from there (haven't messed with customizing the sidekick yet). Just looking for guidance if anyone has dealt with anything like this before.
[sidenote]
If you're curious why I'd like to move it to the second design, it's because eventually the authors would like a control panel that would allow them to create items on their own. It would be much easier and a lot more lightweight to have a system that alters a singular node and it's properties rather than one that has to manage creating/altering full component structures. It also decouples the 'item components' that the authors would make from the actual components that the developers create. This is important because the the component code we create is versioned/etc, whereas these faux components would go unchecked and we would need another way to manage them.
As you already described, creating a new component for each product will result in a big overhead. Beside you will create components, which are linked only to one resource, so not re-usable anymore.
First you need to see a difference between the content and components. In this case your defaultItem is the component and the products the content. In AEM the contentfinder is created to display, search, drag and drop your content into the page. The sidekick for components.
The solution will be the following:
Create a custom contentfinder tab which loads all your products;
Loading products can be done by creating a servlet which returns
all relevant products in a json format
Create a generic component (eg. defaultItem) which can display your
product into the page by setting a reference link to the product;
Configure the contentfindertab to create the defaultitem component
when dragging the product into the page
Take care about the CQ.wcm.ContentfinderTab.getResultsBoxConfig. At itemsDDNewParagraph
you can configure the new component type (defaultItem) and the
property to link the component to the product.
How to create a contentfinder tab:
http://helpx.adobe.com/experience-manager/kb/CustomCFTab.html
Note: when dropping a product from the contentfindertab into the page, use the ALT button

Dropping elements into a dynatree

I am just starting out with dynatree (which is indeed v. cool), but I have a non-standard use for it: sorting terms from a long list into the hierarchical Dynatree. Specifically, I want to drag-and-drop from outside the Dynatree onto a Dynatree element--preferably exploiting Dynatree's spring-loaded folders rather than expecting the user to manually open the relevant categories beforehand.
Could I get some specific guidance on how to achieve my dreams?
Thanks,
Steve Upstill
One of he drag'n'drop samples seems to implement your use case:
You can drag the 'Drag me around' box over the right tree.
http://wwwendt.de/tech/dynatree/doc/sample-dnd3.html
The box is a simple query.draggable.
The tree receives the standard events (onDragEnter, onDragOver, onDrop, onDragLeave).
Make sure to enable the autoExpandMS option.
Hope this helps
Martin

How do I get Zend_Navigation to work with database defined data?

I've got a Zend_Navigation component I use to display breadcrumbs on a page. It currently says something like:
"Companies > Edit a Company"
when displaying the edit form. I would like to make it say something like
"Companies > Editing FooBar"
What's the best way to accomplish that?
I had the problem that I wanted to show breadcrumbs even when the parent is set to not visible. Drove me nuts until I found the reason. Your problem is not much different, I think.
I have a unique ID set with basically all links; hence, I can fetch all nodes like the following:
// in view scripts
$navObject = $this->navigation()->findOneById($id);
// now you can manipulate the object however you like
$navObject->setLabel('Editing FooBar');
You can find the node by other means, there is findOneBy() method where you have to pass the target object.
Once I printed the breadcrumbs I had to reset setVisible(false) to the old value, though. Depending on your needs you might have to reset the label, too.