Enterprise Architect Communication Diagrams question - uml

I want to achieve something like this in Enterprise Architect's Communication Diagrams:
start() ---------------- 1. create() ------------
------------> | RGController | ---------------> | U : User |
---------------- ------------
But I am facing 2 problems:
It seems I have to always make a
connection between 2 objects (I
can't have the start() message just
come out of nowhere, like I'd want).
I can't control the numbering as I'd
want. Is there any way I could just
set the numbering by myself? If I
define that an actor is calling
start() on RGController, it will
call it message 1 when I'd want
message 1 to be User.create().

A) Which Object is sending the start() message to RGController? Add it to the diagram and create the connection between these two objects.
Alternatively you could send the initial message from an Inital element (in the Activity toolbox).
You could also hack an invisible start element by creating an empty shape rendering script.
Just create a new Stereotype in Settings->UML...->Stereotypes, set the name to hidden, applied to , and set the shape script as:
shape main {
}
Then apply this stereotype to your initial element. It should be rendered as invisible.
B) I'm not sure how to manually set the message labeling. Are you aware of the message numbering settings?
right clicking one of the message
labels an selecting "Sequence
Communication Messages".
checking "start new group" in the
Message Properties->Sequnce
Expressions section.

Are you trying to draw an architecture which uses a Front-controller or Facade for handling incoming request?
If so in that case the client will call the start(). E.g. In case of an ASP.net application, it will be the UI code or presentation logic.
Client/User/Customer ---start()---> RGBController--- create() ---> u: User

Related

How can I simulate hand rays on HoloLens 1?

I'm setting a new project which is intended to deploy to both HoloLens 1 and 2, and I'd like to use hand rays in both, or at least be able to simulate them on HoloLens 1 in preparation for HoloLens 2.
As far as I have got is:
Customizing the InputSimulationService to be gesture only (so I can test in editor)
Adding the GGVHand Controller Type to DefaultControllerPointer Options in the MRTK/Pointers section.
This gets it to show up and respond to clicks both in editor and device, but it does not use the hand coordinates and instead raycasts forward from 0,0,0, which suggests that the GGV Hand Controller is providing a GripPosition (of course with no rotation due to HL1) but not providing a Pointer Pose.
I imagine the cleanest way to do this would be to add a pointer pose to the GGV Hand controller, or add (estimated) rotation to the GripPosition and use this as the Pose Action in the ShellHandRayPointer. I can't immediately see where to customize/insert this in the MRTK.
Alternatively, I could customize the DefaultControllerPointer prefab but I am hesitant to do so as the MRTK seems to still be undergoing frequent changes and this would likely lead to upgrade headaches.
You could create a custom pointer that would set the pointer's rotation to be inferred based on the hand position, and then like you suggested use Grip Pose instead of Pointer Pose for the Pose Action.
The code of your custom pointer would look something like this:
// Note you could extend ShellHandRayPointer if you wanted the beam bending,
// however configuring that pointer requires careful setup of asset.
public class HL1HandRay : LinePointer
{
public override Quaternion Rotation
{
get
{
// Set rotation to be line from head to head, rotated a bit
float sign = Controller.ControllerHandedness == Handedness.Right ? -1f : 1f;
return Quaternion.Euler(0, sign * 35, 0) * Quaternion.LookRotation(Position - CameraCache.Main.transform.position, Vector3.up);
}
}
// We cannot use the base IsInteractionEnabled
// Because HL1 hands are always set to have their "IsInPointing pose" field as false
// You may want to do more thorough checks here, following BaseControllerPointer implementation
public override bool IsInteractionEnabled => IsFocusLocked || IsTracked;
}
Then create a new pointer prefab and configure your pointer profile to use the new pointer prefab. Creating your own prefab instead of modifying MRTK prefabs has advantage of ensuring that MRTK updates will not overwrite your prefabs.
Here's some captures of the simple pointer prefab I made to test this with relevant changes highlighted:
And then the components I used:

Correct way of updating an actor with changes applied to SetUserTransform

I have a poly actor which has a vtkBoxWidget that is connected to a callback as from the example in the docs:
def widget_callback(obj, event):
t = vtk.vtkTransform()
obj.GetTransform(t)
obj.GetProp3D().SetUserTransform(t)
All works fine and I am able to move and transform the actor with the widget but the transformation is applied to the UserTransform and not processed down to the actor properties.
So if I call:
actor.GetPosition()
It returns the initial position prior to making the changes with the widget. And if I call:
actor.GetUserTransform().GetPosition()
I get the updated position relative to the starting point of the first interaction.
Do I have to connect it all through a vtkTransformPolyDataFilter and then update the input connection to the mapper and also calculate the coordinate space offset or is there a simpler way of doing it? ... in short:
What is the correct way of updating an actor with changes applied to SetUserTransform?
After trying out many variations with vtkTransformPolyDataFilter and start/end interaction events linked to various steps in the process I found that for my purpose the absolute simplest way of handling this was simply linking the widget transformation directly to the actor properties:
def widget_callback(self, obj, event):
t = vtk.vtkTransform()
obj.GetTransform(t)
self.actor.SetPosition(t.GetPosition())
self.actor.SetScale(t.GetScale())
self.actor.SetOrientation(t.GetOrientation())

Connecting an overloaded PyQT signal using new-style syntax

I am designing a custom widget which is basically a QGroupBox holding a configurable number of QCheckBox buttons, where each one of them should control a particular bit in a bitmask represented by a QBitArray. In order to do that, I added the QCheckBox instances to a QButtonGroup, with each button given an integer ID:
def populate(self, num_bits, parent = None):
"""
Adds check boxes to the GroupBox according to the bitmask size
"""
self.bitArray.resize(num_bits)
layout = QHBoxLayout()
for i in range(num_bits):
cb = QCheckBox()
cb.setText(QString.number(i))
self.buttonGroup.addButton(cb, i)
layout.addWidget(cb)
self.setLayout(layout)
Then, each time a user would click on a checkbox contained in self.buttonGroup, I'd like self.bitArray to be notified so the corresponding bit in the array can be set/unset accordingly. For that I intended to connect QButtonGroup's buttonClicked(int) signal to QBitArray's toggleBit(int) method and, to be as pythonic as possible, I wanted to use new-style signals syntax, so I tried this:
self.buttonGroup.buttonClicked.connect(self.bitArray.toggleBit)
The problem is that buttonClicked is an overloaded signal, so there is also the buttonClicked(QAbstractButton*) signature. In fact, when the program is executing I get this error when I click a check box:
The debugged program raised the exception unhandled TypeError
"QBitArray.toggleBit(int): argument 1 has unexpected type 'QCheckBox'"
which clearly shows the toggleBit method received the buttonClicked(QAbstractButton*) signal instead of the buttonClicked(int) one.
So, the question is, how can I specify the signal connection, using new-style syntax, so that self.bitArray receives the buttonClicked(int) signal instead of the default overload - buttonClicked(QAbstractButton*)?
EDIT: The PyQT's New-style Signal and Slot Support documentation states you can use pyqtSlot decorators to specify which signal you want to connect to a given slot, but that is for a slot you are creating. What to do when the slot is from a "ready made" class? Is the only option subclassing it and then reimplementing the given slot with the right decorator?
While browsing for related questions I found this answer to be exactly what I needed. The correct new-style signal syntax for connecting only QButtonGroup's buttonClicked(int) signal to QBitArray's toggleBit(int), ignoring the other overloaded signatures, involves specifying the desired type in brackets, like this:
self.buttonGroup.buttonClicked[int].connect(self.bitArray.toggleBit)

Cucumber: Creating a step definition that depends on another step

I need to setup a cascading "Given" -- one factory that belongs_to the factory before it ... in plain rspec, I'd create he first factory, then take it's ID and pass it to the next factory.
#widget = Factory(:something)
#otherthing = Factory(:other, :widget_id => #widget.id)
What's the best way to do this in a step definition? My scenario says: "Given a widget AND a thing", but that creates two steps that don't seem to know anything about the other.
You can use the same approach as RSpec. A step can access instance variables set in a different step.
As Andy says - steps within a scenario can share state with each other through instance variables (because each scenario is executed within a new instance of the World object).
In your case I'd write something like:
Given /^a widget$/ do
#the_widget = Factory(:something)
end
Given /^a thing$/ do
raise "Must create a widget first!" if #the_widget.nil? # In case the scenario author forgets the widget-creation step
#the_otherthing = Factory(:other, :widget_id => #widget.id)
end

How to create an observableCollection Sortable and multithreading

Here is my problem , I have created a SortableCollection : ObservableCollection
and added a sort method (sort colors).
When I sort The collection with the principal Thread , it works every thing is fine and works
But When I try to sort this customCollection by using an item in the collection I have an expetion : (The calling thread cannot access this object because a different thread owns it).
I have looked in web and I found several solution , One Solution
This type of solution put the collection multithread for insertion , removing moving operation.
But not for the custom sort.
Thanks for help,
WPF classes have thread affinity. What this means is that all changes to those objects must be in the same thread where they were created. It truly is difficult to create a user interface API that is thread-safe, so Microsoft chose to keep it singlethreaded and force run-time checking to make sure of it.
That said, there are a few options you have to perform your sort in a background thread, and then apply it in the UI thread. The first option is to copy your SortableCollection into a plain old List or Array and perform the sort in the background. Once the background thread is complete, you use a Dispatcher to execute code in the UI thread. Every UI element in WPF extends System.Windows.Threading.DispatcherObject and most extend System.Windows.Freezable. The DispatcherObject is where you get the Dispatcher to execute code in the UI thread.
Logically, the execution would be something like this:
public void BackgroundSort()
{
List<T> items = new List<T>(this.ToArray());
BackgroundSortDelegate del = Sort;
del.BeginInvoke(SortCompleted, del);
}
private void SortCompleted(IAsyncResult result)
{
BackgroundSortDelegate del = result.AsyncState as BackgroundSortDelegate;
List<T> items = del.EndInvoke(result);
this.Dispatcher.Invoke(()=>{this.Collection = items;});
}
The short explanation of what happened is that the background worker/delegate is using a copy of the items in this list. Once the sort is complete, we are calling the Dispatcher object and invoking an action. In that action we are assigning the new sorted list back to our object.
The key to assigning the result of any background work within the UI thread is to use the UI's Dispatcher object. There's actually probably a half dozen ways to invoke a background worker in C#, but the approach to get your work in a background thread into the UI thread is the same.

Resources