Can Graphviz render State Transition Diagrams exactly like this?
http://upload.wikimedia.org/wikipedia/commons/c/cf/Finite_state_machine_example_with_comments.svg
=== Edit ===
Marapet's code comes really close (see: http://i.imgur.com/ElzSl.png ). I am accepting his answer.
I'd create nodes for the transition conditions :
digraph g{
Opened[label="1\nOpened\nE: open door"];
Closed[label="2\nClosed\nE: closed door"];
node[shape=plaintext];
Opened -> close_door[arrowhead=none];
close_door -> Closed;
Opened -> open_door[dir=back];
open_door -> Closed[arrowhead=none];
}
I would use label on the arrow instead of creating a node for the close_door:
Opened -> Closed [label=close_door];
Related
This question already has answers here:
How do I make a clickable pin in SwiftUI's new Map view?
(2 answers)
Closed 1 year ago.
I'm building a swiftui app and am trying to implement a searchview for locations. I'm currently displaying the search results as annotations and want the user to be able to select them by tapping on them.
Is this possible, as the Annotations aren't views, I can't use a gesture modifier to solve the problem.
I found a way to use the system style. An apple developer forum thread made me aware that the image used for MapMarker is available as a system symbol/in sf symbols, so this is the implementation I came up with.
MapAnnotation(coordinate: result.coordinate) {
Button {
selectedDestination = result
} label: {
Image(systemName: result == selectedDestination ? "mappin.circle.fill" : "mappin.circle")
}
}
The size of the Image still has to be adjusted and the foreground color as well, but it works in principle.
Apple Map
Core Location
I implemented Apple Map with Core Location and its delegate to add pin and its working perfectly but now i am stuck with the issue to :
Rotate Map as per user movement ( as user travelling with car moves the different direction , the apple map should move )
I found Apple Map native does same work . Here is gif :
I did find solution yet . Kindly suggest me how to do it ?
Note ->
Don't want to use Google Map
Don't want to move Pin (annotation view)
If you want me to update my existing code , i can update again .
Simply add the MKUserTrackingBarButtonItem to your toolbar, it behaves exactly as the button in Maps app and handles all of the magic.
let trackingButton = MKUserTrackingBarButtonItem(mapView: mapView)
toolbarItems = [trackingButton]
Alternatively you could set the MKUserTrackingMode but then you're going to run into some handling issues, and a few caveats of doing it this way. Such as resetting the view after user scrolls the map, and not being able to control the zoom level among other things.
mapView.setUserTrackingMode(MKUserTrackingMode.followWithHeading, animated: true)
I am trying to add a Ctrl+F accelerator to my gtkmm textview program. I already implemented the search function into an gtk Entry field, so the only thing I need is to get focus the find entry when Ctrl+F is pressed.
I googled and checked tutorials/reference of gtkmm (2.4, I'm working with that) but the only things I found were accelerators in context with menus and toolbars using UIManager, which I don't have in that .cc file I use (and I can't add them, cause its an existing program).
I tried to add an action with an AccelKey on a button or tried the function add_accelerator() but I wasn't able to use them properly (I am pretty new to gtkmm and there aren't enough samples - at least none I understand). Here some examples I tried:
_gtkActionGroup->add(
Gtk::Action::create("find", "Find", "search in file"),
Gtk::AccelKey("<control>F"),
sigc::mem_fun(this, &SrcFilesView::onGtkTxtFindAccKeyPressed));
I didn't know how to add this action to the button (in the toolbar) I created...
_gtkAccelGroup(Gtk::AccelGroup::create()) //initialized in the constructor of the class
...
_gtkBtnFind.add_accelerator("find", _gtkAccelGroup, GDK_Find,
Gdk::ModifierType::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
I tried here something, but I didn't really understand neither the parameters I needed to enter here nor how this method works - ofc it didn't work...
I'd be really happy if anyone can explain me how this things work properly and sorry for my bad english. If there are any things you need just tell me please. Thanks in advance
Greetings
edit: I looked up in the gtk sources and tried to understand the parameters of add_accelerator. Now I tried this but still doesn't work...:
_gtkBtnFind.add_accelerator("clicked", _gtkAccelGroup, GDK_KEY_F /* or better GDK_KEY_f ?*/,
Gdk::ModifierType(GDK_CONTROL_MASK), Gtk::AccelFlags(GTK_ACCEL_VISIBLE));
_gtkBtnFind.signal_clicked().connect(
sigc::mem_fun(this, &SrcFilesView::onGtkTxtFindAccKeyPressed));
UPDATE:
Okay I have understood most I think now, and I know why it doesn't work. The problem is that I have to add the accel_group to the window widget, but I got only a scrolled window and boxes in my program....and now I have no clue how to continue... :)
UPDATE2:
Alright I managed to do it without accelerators by using the "on_key_press_event" handler by checking the state and keyval parameter. Hope this helps some ppl at least ^^.
bool on_key_press_event(GdkEventKey* event) { /* declaration in my constructor removed */
if(event->state == GDK_CONTROL_MASK && event->keyval == GDK_KEY_f
|| event->state == (GDK_CONTROL_MASK | GDK_LOCK_MASK)
&& event->keyval == GDK_KEY_F) {
_gtkEntFind.grab_focus();
}
return false;
}
I would be still interested in a solution with the accelerators if there is any ! Greetings
I need to write a C++ GUI such that user can make a flowchart / pipeline by selecting several blocks from a toolbar and putting them into a window and connecting them in some order which he wants and then program runs the flowchart. (For simplicity just consider each block's task is to print some number. My problem is GUI)
Does anyone ever try a similar thing / any experience?
Is it possible to make such a GUI in WxWidget or any other Graphics/Window-form library?
Is it possible to use VTK to make the GUI?
Do you know of any similar open source work?
I have developed several apps with GUIs that do this sort of thing.
The one I am most pleased with is called VASE: A GUI used to create the layout, set parameters and view results of a process flow simulator.
It is not a trivial task, though once you have done one or two, there are many ideas that you can reuse and it goes quickly.
The two biggest challenges drawing the lines connecting the objects ( as you can see, even in VASE, this problem is not completely solved ) and storing that layout in a format that can be easily recovered and redrawn.
Is there any particular issue you need help with?
If you want a really, really, simple example to get you started I have re-implemented a couple of basic features ( all nice and clean, no copyright restrictions ) - left click to select, drag to move, right click to connect.
Here is the source code repository - http://66.199.140.183/cgi-bin/vase.cgi/home
Here's what it looks like
I have implemented a simplified connector, which I call a pipe. To give you a flavour of how to do this kind of stuff, here is the code to add a pipe when the user right clicks
/**
User has right clicked
If he right clicks on a flower
and there is a different flower selected
then connect the selected flower to the right clicked flower
if he right clicks on empty background
create a new flower
*/
void cVase::MouseRightDown( wxMouseEvent& event )
{
// find flower under click
iterator iter_flower_clicked = find( event.GetPosition() );
// check there was a flower under click
if( iter_flower_clicked != end() ) {
// check that we have a selected flower
if( ! mySelected )
return;
// check that selected flower is different from one clicked
if( mySelected == (*iter_flower_clicked) )
return;
// construct pipe from selected flower to clicked flower
myPipe.push_back(cPipe( mySelected, *iter_flower_clicked ));
} else {
// no flower under click
// make one appear!
cFlower * pflower = Add();
pflower->setLocation( event.GetPosition() );
}
// redraw everything
Refresh();
}
And here is the code to draw a pipe
/**
Draw the pipe
From starting flower's exit port to ending flower's entry port
*/
void cPipe::Paint( wxPaintDC& dc )
{
dc.SetPen( *wxBLUE_PEN );
dc.DrawLine( myStart->getExitPort(), myEnd->getEntryPort() );
}
You can see the rest of the wxWidgets code that ties all this together by browsing the source code repository.
I think using a library such as wxArt2D would be easier than using the standard wxWidgets drawing classes. The wires sample of wxArt2D looks similar to what you are looking for.
Maybe you can have a try with the tiny tool called Flowchart to Code, you can get the flowchart needed,like this. It can be downloaded here:http://www.athtek.com/flowchart-to-code.html#.Ug4z29JPTfI
In my project the tabs which are not under more section are properly responding to orientation but the tabs present under the more section are not responding.
For example if I am having two tabs names tab1 and tab2 under more section and if I am putting break point at the "shouldAutorotateToInterfaceOrientation" method of each tab.After that when if I am selecting tab1 from more section and tries to rotate it but the "shouldAutorotateToInterfaceOrientation" of the tab2 gets called.The delagate method of the tab which I am selecting is not getting called.I am working on XCode Ver 4.3.2.
Can someone please help me in solving this problem..
Thanks in advance,
Prajnaranjan Das
Please write followings code of all the root view controller of tab bar controller.
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return yes;
}
i face the same prblm as you facing now...
i was Return YES (shouldAutorotateToInterfaceOrientation Function) to all the view Controller classes inside tababarcontroller and my problem solved..
try to do this...might be you also get success
I used this method for orientation. Its working properly.
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
}
There are several other methods which may help you in orientation such as:
• willRotateToInterfaceOrientation
• didRotateFromInterfaceOrientation
• willAnimateFirstHalfOfRotationToInterfaceOrientation
• willAnimateSecondHalfOfRotationFromInterfaceOrientation