Change color of a simple object - verold

I have a cube that I'd like to change the color of through code. I'm attempting to use the setProperty() method. When I put the following code in an update loop and attach it to a cube that I've made blue it stays blue, but the console says that it is black (0). When I remove the setProperty() line then I get the color value from the editor.
this.getEntity().setProperty("diffuseColor",0);
console.log(this.getEntity().getProperty('diffuseColor'));

How I've done it is referencing the material using the Asset Registry, then calling the setProperty method on the variable referencing it, like this:
var material = this.getAssetRegistry().getAssetByName("NameOfMaterialInEditor");
material.setProperty("diffuseColor", 0x000000);
You can also use the attribute system to reference the material by creating it in the Code Editor then setting it on the component in the Studio, then whatever you named the attribute can be referenced programmatically with
this.nameOfAttribute.setProperty("diffuseColor", 0x000000);

That code should work fine (and it seems to be working for me). diffuseColor is a property of materials though so make sure that you're setting this property on the MaterialAsset and not your mesh.
If you want to only change the color of the material on one of your meshes, you'll need to create a new material for it (or clone the existing one).
Hope that helps.

Related

How can I test if an item is anchored?

What is the proper way to test if an item has been anchored? For example, take the left side, I have tried:
property bool isAnchored: parent.anchors.left != undefined
But that does not seem to work? I also tried:
property bool isAnchored: !!parent.anchors.left
which also does not seem to work, I also tried:
property bool isAnchored: parent.anchors.left ? true : false
Any other ideas? There has to be a way to check if an item is anchored but I can not find it?
Unfortunately I don't see any way to do it using the provided/exposed properties. The only thing that determines a valid anchor is the Anchors flag type which is defined in the QQuickAnchorLine::anchorLine member, but that's not exposed to QML anywhere (eg. anchors.left.anchorLine is always undefined). Or in the public C++ API for that matter. The actual QQuickAnchorLines attached to each object are always valid/non-null, as you've discovered.
I think you will need to implement your own flags in whatever routine(s) which set or remove the anchors in your code (I assume that has to be determined somewhere). That is, whenever an anchor changes, set a custom property value. There are also the anchor change signals (leftChanged() etc.) which could be connected to.
Alternatively, you could re-implement your own attached Anchors object in C++ and track whatever properties you want (basically same as the above suggestion but centralized in a C++ class). Here is a good example (I think, not my code) of defining your own anchors lines using a custom attached object. With something like this it would be pretty easy to track/query what is anchored to what.

How do I reliably style object layout in apache isis wicket viewer?

I have created a module by copying module-simple. I have everything working well. However, the layout does not follow the layout.xml specification - I did not change anything except to rename the file.
This is the SimpleObject view.
This is my ZiemObject view - only the name is changed.
When I remove the layout.xml and try to use #MemberOrder(name=..,sequence = .. ) I get nothing but the basic object view.
What am I doing wrong?
It isn't clear to me from your question, did you rename the layout file to ZiemObject.layout.xml ? I guess it must be because a layout is the only way to specify tabs. Could you paste a copy of it here?
Even better, perhaps you could upload your app to a github repo so we can take a deeper look?
UPDATE:
I downloaded the sample app from the github repo, and what's there works as expected...
the ZiemObject.layout.xml controls the member order of the ZiemObject, and because it is present the #MemberOrder annotation in that class are ignored
Also, the notes property is no longer shown as multi-line because that metadata is only provided in the .layout.xml file
if I rename the layout file, eg mv ZiemObject.layout.xml ZiemObject.layout.xml.MOVED then the default layout is honoured. In particular, the (framework-defined) id and version fields are no longer shown in tabs.
(Also, the notes is no longer shown as multi-line because that metadata is only provided in the .layout.xml file).
If I change the #MemberOrder#sequence attribute for the name and notes properties to "2" and "1" respectively, then the order of these fields is inverted, as shown below:
Hope that helps
Dan

Unreal Engine 4 Blueprint

Im new to unreal
I have a problem with the communication from Hud_Blueprint to Level_Blueprint.
I want to have a slider in the Hud which controls the rotation of a cube in the level.
In the Hud_Blueprint i have the slider I made in a Widget_Blueprint.
Works perfect, printline values from 0 to 1.
I tried to use a Interface_Blueprint, like in the following link without success.
https://answers.unrealengine.com/questions/22126/pass-variable-from-hud-blueprint-to-level-blueprin.html
my Blueprints:
https://www.dropbox.com/s/k30ah9fjuwlff6x/zusammen.jpg?dl=0 (404 response)
Seems like i have no connection between the Blueprints.
The function works just in the Hud_Blueprint.
Well, your problem is maybe solved, but someone can find it helpful:
First, create new WidgetBlueprint and name it "Slider".
In Slider editor create Event Dispatcher called "ValueChanged" with float input. In designer, add slider and add it's OnValueChanged. From that node you must call ValueChanged with obtained Value as parameter.
In level blueprint, on EventBeginPlay create SliderWidget and Add (return value) To Viewport. You must promote Slider to variable to use it in next step - Assign ValueChanged with new event which will cover up rotation login in it's execution. See image at Dropbox
If you select your cube in the level outliner and drag that into your HUD_BP you can obtain a reference to the object that way. You can then drag a pin off the object reference and call SetActorRotation

Identifying objects in IBM RFT

While executing my script in RFT, my script got failed due to the slight position change of a button. (This button's position slightly changes according to the option selected for previous combo box due to the label appearing near the button)
As there are 2 positions for this button in window, one of my script fails while other passes.
Please suggest how to identify this same object in 2 different places in RFT?
If you're alright with not using pre-mapped values and instead work with objects directly in code (which I've personally found to be extremely useful... it's allowed me to do great and wondrous things with RFT :), the following ought to work fine:
private void clickObject(String uniqueIdentifier) {
// Find object
RootTestObject root = RootTestObject.getRootTestObject();
TestObject[] matchingObjs = root.find(atProperty(".id", uniqueIdentifier));
if (matchingObjs.length > 0) {
// Click the object
((GuiTestObject) matchingObjs[0]).click();
}
// Clean-up
unregister(matchingObjs);
}
Feel free to replace ".id" with whatever property is best suited for the situation... since I work primarily with a web application, the ".id" property has worked splendidly for me.
Because the method finds the object anew each time, it'll grab the object's position wherever it's at at the time the method's called. The clean-up will also prevent any weird, horrible, and otherwise unfortunate UnregisteredObjectExceptions from cropping up.
Without looking at your pages I cannot be sure, but I think the buttons are actually two different buttons. Maybe they are generated by javascript, or they are just un-hidden after the option you select in the combobox.
If they are two different buttons (record them both and look at the recognition properties) you can either replace some properties with a regular expression or check wich button is visible/exists and then click it:
if (btn_button1.exists()) {
btn_button1.click();
} else if (btn_button2.exists()) {
btn_button1.click();
}
Here's a more complete tutorial on Object Recognition.
You can increase the tolerance of Rational Performance Tester AssureScript in the properties tab or you could set the description but hide the value. You can also make a custom code that updates the object map to prepare for this change in a java IF structure

Changing interactive mode Edge Shape in JUNG

I am aware of the ability using an EdgeShapeTransformer to change the look of edges:
vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); // for example
However I am looking for how to change the way the line looks while dragging from one node to another to create an edge interactively. By default the 'hovering' edge which is not yet linked to another node is a large curved line. See the example here for what I mean.
CubicCurveEdgeEffects is where it is done. There is an EdgeEffects interface that can be implemented to do other things instead. It is used by the SimpleEdgeSupport class via the EditingGraphMousePlugin.
(Credit to Tom Nelson, offline communication.)