PlantUML Activity Diagram Go Back - uml

I am using PlantUML to create an Activity diagram.
I want the arrow that comes out of Modify Details to go back to OP2 instead of the diamond.
I have this diagram:
#startuml
|Swimlane1|
start
:OP1;
|Swimlane2|
:OP2;
if (Form Valid?) then (No)
|Swimlane1|
:Modify Details; /' <-- This should point _back_ to OP2 '/
|Swimlane2|
else (Yes)
:Add Detals to System;
endif
:OP3;
|Swimlane2|
:foo5;
stop
#enduml
Which gives this image:

Can you express it with a while or repeat? Below is not quite your logic as OP2 would not always occur, but perhaps it will help you express your logic within the diagram constraints:
|Swimlane1|
start
:OP1;
|Swimlane2|
while (Form Valid) is (no)
:OP2;
|Swimlane1|
:Modify Details;
endwhile (yes)
|Swimlane2|
:Add Detals to System;
:OP3;
:foo5;
stop
#enduml

Related

PlantUML Activity diagram special Box Layout Output is needed

I have a problem and tried to solve it for the last 2 Days.
I want to design an activity diagram/flow chart like this:
Step1
Step2
Step3 --------->Output of Step 3
Step4
I can't draw/program an arrow which starts directly out of the box "Step3" and the Box "Output of Step 3" too without any layout problems.
My current code:
#startuml Test1
title Flowchart
|System 1|
start
:Step1;
:Step2;
split
:Step3;
|System 2|
split again
:Output of Step3;
detach
|System 1|
end split
:Step 4;
stop
#enduml
Activity Diagrams in UML have certain rules. Using split is probably a bad idea, as it's intended for the SDL aspect of PlantUML.
Perhaps you can try with fork if you want to show the output in a separate swimlane:
#startuml Test1
title Flowchart
|System 1|
start
:Step1;
:Step2;
:Step3;
fork
:Step 4;
|System 2|
fork again
:Output of Step3]
stop
|System 1|
end fork
stop
#enduml
I put a stop at the end of the output (which is now an object using the ] ending) to prevent the line rejoining the flow in System 1.
Another alternative is to use the legacy syntax for Activity diagrams, which doesn't allow for swimlanes, but can do partitions.
#startuml Test2
title Flowchart
partition "System 1" {
(*) --> "Step 1"
--> "Step 2"
--> "Step 3"
--> "Step 4"
--> (*)
}
partition "System 2" {
"Step 3" -> "<< object >>\nOutput of Step 3"
}
#enduml
In the legacy syntax for Activity Diagrams, it's not possible (as far as I know) to make an "object" (rectangle) shape.

insert GlyphProperty.null in shouldGenerateGlyphs causes cursor misplacement problem

I am hiding the character * by inserting GlyphProperty.null then calling setGlyphs(_:properties:characterIndexes:font:forGlyphRange:) inside layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:) as described in the answer in https://stackoverflow.com/a/57697139/9568961, it works but after a certain sequence of text editing, the cursor starts to misplace, as shown in the gif https://github.com/dzAtZJU/Demos/blob/master/cursor_misplace.GIF?raw=true
GIF Description: When the second line becomes qq, I try to move the cursor to the end of first line, but it move directly to the beginning. I then try to delete characters, then the cursor move to the end correctly.
The sample project is here https://github.com/dzAtZJU/HideText.
Is it a bug? Have anyone run into this? How can I work around this?
This is a year-old question, but for anyone struggling with the same problem, here's a solution.
My Markdown-like parser knows the ranges for both the line on which the cursor is now, and where it was previously. I'm calling hideAndShowMarkup whenever text view selection changes.
You need to invalidate current glyphs for both of the ranges, and then redraw them synchronously before updating insertion point. The most crucial step is invalidating layout for the range where you want to show Markdown symbols. Without that, your caret gets drawn into the wrong position.
Code is in Objective C, but should be easy to implement in Swift, too.
-(void)hideAndShowMarkup {
// Just for reference
Line* line = currentLine;
Line* prevLine = previouslySelectedLine;
[self.layoutManager invalidateGlyphsForCharacterRange:line.range changeInLength:0 actualCharacterRange:nil];
[self.layoutManager invalidateGlyphsForCharacterRange:prevLine.range changeInLength:0 actualCharacterRange:nil];
[self.layoutManager invalidateLayoutForCharacterRange:line.range actualCharacterRange:nil];
if (NSGraphicsContext.currentContext) {
[self.layoutManager drawGlyphsForGlyphRange:line.range atPoint:self.frame.origin];
[self.layoutManager drawGlyphsForGlyphRange:prevLine.range atPoint:self.frame.origin];
}
[self updateInsertionPointStateAndRestartTimer:NO];
}

vtkProperty SetLineStipplePattern working but SetLineWidth not..?

I have created a vtkLineSource that is passed to vtkPolyDataMapper, passed to vtkActor.
actor->GetProperty()->SetLineStipplePattern(0xf0f0);
works like a charm. However
actor->GetProperty()->SetLineWidth(5.0);
does nothing.
Both methods are marked "This is only implemented for OpenGL."
Here's the snippet:
vtkSmartPointer<vtkLineSource> line1 = vtkSmartPointer<vtkLineSource>::New();
line1->SetPoint1(posvel1.x, posvel1.y, posvel1.z);
line1->SetPoint2(posvel2.x, posvel2.y, posvel2.z);
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(line1->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetLineWidth(2.0); // TODO: Has no effect.
actor->GetProperty()->SetColor(1, 1, 1);
actor->GetProperty()->SetOpacity(0.5);
actor->GetProperty()->SetLineStipplePattern(0xf0f0);
actor->GetProperty()->SetLineStippleRepeatFactor(1);
// Further up, add actor to vtkAssembly
Line shows and has stipple pattern, but width is unaffected by whatever value I pass to SetLineWidth.
Edit: I already had a comment in my code. "Replace with vtkPoints polygon drawing instead of LineSource needed probably..." Tested this: Does not solve the issue, stipple pattern is there, line width does not work.
== Edit ==
What alternatives are there to draw a 2D dashed/dotted line in a 3D scene with vtk?

Make VIM function return text without indent

I guess this question could be taken in two ways...
(Generic) - is there a way to specify settings 'local' to a function (setlocal changes seem to persist after the function call)...
(Specific) - I have a function which gets called from an imap mapping (which takes a user input to pass into the function. The function works perfectly if I run set paste or set noai | set nosi either just before running my shortcut, or added into the function itself. The problem is, whichever way I do it, those setting changes persist after my function call.
Essentially, my workflow is:
In insert mode, type //// at which point I get prompted for input text, which I enter and press enter.
The function is called with my input. I need the function to disable indenting, return my string and then re-enable the previous settings. The string would just be a PHP-block comment like this:
/**
* Blah {INPUT TEXT}
*/
Any suggestions appreciated. My script currently looks like this:
function CommentInjector(txt)
return "\/**" ."\<CR>"
\ . " * foo " . a:txt . " bar " . "\<CR>"
\ . " */"
endfunction
imap <silent> //// <C-R>=CommentInjector(input("Enter some text:"))<CR>
UPDATE
Managed to figure it out at least how to dump a comment in... Would appreciate knowing how to get/restore settings though...
function! CommentInjector(txt)
set paste
exe "normal! i/**\<CR>"
\ . " * fooo " . a:txt . " bar\<CR>"
\ . " */\<Esc>"
set nopaste
endfunction
map <C-C><C-C><C-C> :call CommentInjector(input("Enter some text:"))<CR>
Using this you can just pres Ctrl+C 3 time, enter text when prompted and you get a nice comment written in. It assumes you had "set paste" disabled before running though...
Since you've posted an update and are really just looking at how to save/restore settings, I'll give a general solution.
At the start of your function save the initial value of the setting: let save_paste = &paste
Make any changes to paste that you'd like to make
Restore it at the end: let &paste = save_paste
An example of this can be found in the documentation with :help use-cpo-save where they talk about saving and restoring the value of cpoptions.

Draw a line in mfc with help of toolbar

I am trying to make a paint application in MFC using visul basic c++ 6.0 i have already created a window using Create function and also have created a toolbar with a tool line but i am stuck on how to code for the line because the function i know goes like d.lineTo(x,y) and d.Moveto(x2,y2) but it comes under the line function how do i use OnLButtonDown to Trap the co-ordiantes or is there any other way i can draw a line ..? any help will be useful
have a look at the MFC Scribble tutorial :
http://msdn.microsoft.com/en-us/library/aa716527%28v=vs.60%29.aspx)
It will get you started on how to handling mouse click and mouse move and drawing.
M.
Ok, you're going to have to override several member functions to do this. I've outlined an approach below. My example below deals with a single line-drawing operation (from mouse down, to mouse up). An exercise for you, is to make it so that once you've done one, you can then do another at a different place. It's easy, btw!
CWnd::OnLButtonDown(UINT _flags, CPoint _pt);
CWnd::OnLButtonUp(UINT _flags, CPoint _pt);
CWnd::OnMouseMove(UINT _flags, CPoint _pt);
CWnd::OnPaint()
Apologies if some of these function signatures are wrong! Add some members to your window class:
// at the top of your file
#include <vector>
// in your class
typedef std::vector<POINT> PointVector;
PointVector m_Points;
CYourWnd::OnLButtonDown(UINT _flags, CPoint _pt);
{
// NOTE: For more than one set of drawing, this will be different!
m_Points.clear();
m_Points.push_back(POINT(_pt.x, _pt.y));
}
CYourWnd::OnMouseMove(UINT _flags, CPoint _pt);
{
if(_flags & MK_LBUTTON)
{
const POINT& last(m_Points.back());
if(_pt.x != last.x || _pt.y != last.y)
{
m_Points.push_back(POINT(_pt.x, _pt.y));
Invalidate();
}
}
}
CYourWnd::OnPaint()
{
CPaintDC dc(this);
CRect rcClient; GetClientRect(&rc);
FillSolidRect(&rcClient, RGB(255, 255, 255));
if(m_Points.size())
{
dc.MoveTo(m_Points[0].x, m_Points[0].y);
for(PointsVector::size_type p(1);
p < m_Points.size();
++p)
dc.LineTo(m_Points[p].x, m_Points[p].y);
}
}
Obviously, this is crude and gives you a single drawing operation. Once you click the left button down again, it erases what you've done. So, once you have this working:
Make it so you can draw an unlimited amount of lines. You could accomplish this in several ways such as an additional container (to store vectors), or even drawing-operation classes that you can store in a single vector and then execute.
This solution may well flicker. How might you stop this? Perhaps OnEraseBkgnd holds the clue...
How about more colours?
All signs point towards creating some drawing-classes that encapsulate this for you, but I hope this has got you started.

Resources