|
Thank you for replying so soon.
What I mean is that there is a arrow mark at one end of every linkable line in the illustration of the article, but when I download your software and run it, there is no arrow mark at the end of the linkable line. I don't know why,
my OS is Windows 2000 professional (build 2195, service pack 4).
Thanks in advance.
Cui Sheng
|
|
|
|
|
Ah,
This is due to my inability to communicate properly
The toolbar button with the line with an arrow will, of course, not draw a line with an arrow. This is just a linkable object, like a box etc.
To link two objects with an arrowed line, do the following:
Draw two boxes.
Select both.
Right-click and select Link from the popup-menu.
Now, the boxes will be connected with an arrowed line (that can be reversed, from the popup menu when the two objects are selected).
The links are not proper drawing objects, but rather instances of CFlowchartLink . The lines you draw from the toolbar are derived from CFlowchartEntityLinkableLineSegment , and can be manipulated as any other objects. They are included to allow a more complicated line-drawing between objects.
Note that I'm currently in the documentation and debug stage of an UML-editor based on the same platform, where all links will be derived from CDiagramEntity . It will have C++-code generation, generation to HTML and import of class objects from h-files as well
|
|
|
|
|
Thank you again for replying so soon.
Really great work! Thanks 1000 times!
|
|
|
|
|
I tested the NetworkMapEditorDemo executable and it's fantastic, but the icons do not print, just the labels and the lines.
...Plug & Pray...
|
|
|
|
|
Horror of all horrors! It seems like ::DrawIconEx will not work (well) with a printer - I get black output on my HP psc 750.
This is what you get for being lazy... I will update the demo to use DIBs instead - but this will take a little time.
If you need printouts in the meantime (why would you have posted otherwise ), the following can be done:
First, create bitmaps with the same contents as the icons. This is not more difficult than creating empty 32x32 bitmaps, and copy/paste the pictures from the icons. You will want to edit the resulting bitmaps outside the resource editor, to set the appropriate background color. The background color of the editor is 230, 230, 230 (you might of course change this). I do this by loading the bitmaps into Paintshop, promote them to 255 colors, and set 230, 230, 230 as the background color.
Then, you'll have to set the new resource IDs in the view, CNetworkMapEditorDemoView::OnButtonAddXXX , in the symbol constructors - that is, change the IDI_ICON_SYMBOL_XXX values to the bitmap dittos.
Finally, you'll have to modify CNetworkSymbol::Draw so:
void CNetworkSymbol::Draw( CDC* dc, CRect rect )
{
ASSERT( m_symbol );
dc->SelectStockObject( BLACK_PEN );
dc->SelectStockObject( WHITE_BRUSH );
CDC memDC;
memDC.CreateCompatibleDC( dc );
HBITMAP hbitmap = (HBITMAP)::LoadImage(AfxGetResourceHandle(),
MAKEINTRESOURCE( m_symbol ),
IMAGE_BITMAP,
0,0,
LR_CREATEDIBSECTION
);
CBitmap* bitmap = CBitmap::FromHandle( hbitmap );
CBitmap* oldbitmap = memDC.SelectObject( bitmap );
dc->StretchBlt( rect.left, rect.top, rect.Width(), rect.Height() - round( 12 * GetZoom() ), &memDC, 0, 0, 32, 32, SRCCOPY );
memDC.SelectObject( oldbitmap );
CRect r( rect );
r.top = r.bottom - round( 12.0 * GetZoom() );
CFont font;
font.CreateFont( -round( 10.0 * GetZoom() ), 0,0,0,FW_NORMAL,0,0,0,0,0,0,0,0, _T( "Arial" ) );
dc->SelectObject( &font );
COLORREF oldback = dc->GetBkColor();
COLORREF oldtext = dc->GetTextColor();
if( IsSelected() )
{
dc->SetTextColor( RGB( 255, 255, 255 ) );
dc->SetBkColor( RGB( 128, 128, 128 ) );
}
dc->DrawText( GetTitle(), r, DT_NOPREFIX | DT_WORDBREAK | DT_CENTER );
dc->SelectStockObject( DEFAULT_GUI_FONT );
dc->SetTextColor( oldtext );
dc->SetBkColor( oldback );
}
|
|
|
|
|
Great job.
How do you draw a bitmap (or Icon) on a view with MM_ISOTROPIC or MM_ANISOTROPIC map mode ?
Any help would be appreciated.
Adrian
|
|
|
|
|
In the flowchart editor, you don't
CDiagramEditor is running in MM_TEXT , for the very simple reason that it needs "differentiated zoom" - that is, the objects are supposed to be scaled, while the drag handles are not.
But generally speaking, you draw them the same way as in MM_TEXT. Of course, they will be distorted, depending on the mode. If you have little or no experience with mapping modes, I suggest that you set up a test project, just drawing a rectangle in the view, experimenting with different modes and settings of the window/viewport relation. As soon as you feel comfortable with this, replace the rectangle with a bitmap.
|
|
|
|
|
This is very nice project - 5! Would be very nicely as a begin for visual script project. If there is ever time for me maybe. If some one is do this now, may be is can collabrate.
|
|
|
|
|
Thanks for the feedback!
It could indeed be used to generate code, but I've been dabbling along the lines of an UML-editor with code-generating capacity.
|
|
|
|
|
Johan Rosengren wrote:
UML-editor with code-generating capacity.
Wow! Is sounds good. I'm not wait to see this!
|
|
|
|
|
I'm happy with the framework - this is actually possible. Currently, I'm working on an editor with objects for UML-classes, segmented links and packages. I'll throw in notes as well
Generating source code will not be difficult, but I'll try to add creating diagrams by parsing header files as well, and the parser will be a bit more difficult. We'll see if it reaches the level of quality necessary for uploading to Codeproject!
|
|
|
|
|
I for one would really like to see the results of your effort.
-- Dave
|
|
|
|
|
I'm currently working on it as a mad person I will post an article and code as soon as it is finished.
|
|
|
|
|
And, as by a miracle (or rather, some extreme programming, sweating and the odd outburst of oaths), the UML-editor is now published.
|
|
|
|
|
You might or might not have noticed that the UML-editor is now published on CP.
|
|
|
|
|
Is there a way that I could vote a little above 5 (Excellent) for this submission? Your work is simply fantastic. Keep it up!
The beginning of knowledge is the fear of God
|
|
|
|
|
This is what is called inflation
But thanks for the feedback - happy if the code is of any use
|
|
|
|
|
Great work in deed. I liked it.
|
|
|
|
|
Thanks for the feedback
|
|
|
|
|
I'm very happy to read your code.
it's excellent starting point of code to flow chart, and chart to code converter.
and I need some help for resizeing chart Object, I followed your instruction for resizeing objects, but only thing I'v got was just resizeing cursors, which doesn't work.
thanks in advance
Nature tells us how to ask
|
|
|
|
|
I'm happy that you liked it!
CFlowchartEntity s stops resizing by calling SetContstraints in the object ctor . Changing - for example - the CFlowchartEntityBox ctor to:
CFlowchartEntityBox::CFlowchartEntityBox()
{
SetType( _T( "flowchart_box" ) );
CString title;
title.LoadString( IDS_FLOWCHART_BOX );
SetTitle( title );
SetConstraints( CSize( 0, 0 ), CSize( -1, -1 ) );
}
will allow resizing of the box. Note that you now have to draw the box - if you just click in the editor, a 0 x 0 large object will be created, and the editor will automatically remove it. So, click and draw it.
You might want to dowload the documentation for CDiagramEntity , where the root base class CDiagramEntity is described. You can find the documentation in the download section at the top here: http://www.codeproject.com/miscctrl/diagrameditor.asp.
|
|
|
|
|
thanks reply so fast, I've found some mistakes in modifying your code,
and thanks twice for your kindness for explaining by very long typing...
Nature tells us how to ask
|
|
|
|
|
Matrix is everywhere wrote:
and thanks twice for your kindness for explaining by very long typing...
This is a habit from microsoft.public.vc.mfc
|
|
|
|
|
great work, thanks for sharing
Im thinking of deriving a specialised editor for editing and showing connections between inbound and destination TCP/IP sockets in a 'routing' app that Im being commsissioned to write .. Im currently deciding on how I register 'links' as being associated with an object on each end, ie, can I traverse the existing collection of objects to determined what is connected to what, or do I need a seperate mechanism underneath - much like a traversable graph node/vertice structure ...
anyway, very nice stuff, best wishes to you and your family
'G'
|
|
|
|
|
Thanks for the feedback - great if you can find any use for the code!
There is currently no traversal mechanism for the links. I would have added a few functions to CXXXEntityContainer to implement that, something like GetNextLink( const CString& objectname ) (architectural questions aside - in RealLife (TM), I would have separated the link array into a class of its own).
A pseudocode implementation:
GetNextLink( objectname, linkfrom )
result is null
Get the size of m_links
Loop the array
Get the link object
Is the to-attribute equal to objectname and have we passed linkfrom?
result equals link object
return result
or, expressed as a flowchart datafile (I'm sorry, but I couldn't resist this )
paper:768,1056;
flowchart_start:152.000000,8.000000,280.000000,40.000000,GetNext(obj\commafrom),0;
flowchart_box:152.000000,56.000000,280.000000,120.000000,result=null max=number of links,5;
flowchart_condition:152.000000,216.000000,280.000000,280.000000,count == max?,37;
flowchart_start:320.000000,232.000000,448.000000,264.000000,return result,59;
flowchart_box:152.000000,304.000000,280.000000,368.000000,Get link at count,132;
flowchart_condition:320.000000,384.000000,448.000000,448.000000,link-from == obj?,138;
flowchart_box:320.000000,536.000000,448.000000,600.000000,result = link,157;
flowchart_box:8.000000,384.000000,136.000000,448.000000,increase count,703;
flowchart_arrow:72.000000,312.000000,72.000000,248.000000,,746;
flowchart_box:152.000000,136.000000,280.000000,200.000000, count=0 search=false,286;
flowchart_condition:152.000000,384.000000,280.000000,448.000000,search == true?,397;
flowchart_condition:152.000000,472.000000,280.000000,536.000000,link-from == from?,434;
flowchart_box:152.000000,560.000000,280.000000,624.000000,search = true,461;
flowchart_arrow:384.000000,640.000000,216.000000,640.000000,,963;
flowchart_arrow:72.000000,640.000000,72.000000,512.000000,,978;
flowchart_link:8,4,,0,5;
flowchart_link:8,4,yes,138,157;
flowchart_link:8,4,no,37,132;
flowchart_link:2,1,yes,37,59;
flowchart_link:32,1,,746,37;
flowchart_link:8,4,,5,286;
flowchart_link:8,4,,286,37;
flowchart_link:8,4,,132,397;
flowchart_link:8,4,no,397,434;
flowchart_link:8,4,yes,434,461;
flowchart_link:2,1,yes,397,138;
flowchart_link:32,8,,978,703;
flowchart_link:8,32,,461,963;
flowchart_link:8,16,,157,963;
flowchart_link:32,16,,963,978;
flowchart_link:4,16,,703,746;
Now, putting an implementation of CFlowchartEditor::GetNamedObject in CFlowchartEntityContainer , you'd be able to traverse the tree, thus (in pseudocode):
Traverse
Loop all drawing-objects
Get drawing-object
GetAllLinkedObjects
GetAllLinkedObjects
link = GetNextLink drawing-object, null
while link
to-object = GetNamedObject( link-to )
link = GetNextLink drawing-object, link
As an example!
You might also want to consider adding links directly to the CDiagramEntity -derived objects, they might for example store the name of the objects linked to. There will have to be additions for copying and pasting - names will have to be updated etc. Also, when deleting an object, all other objects will have to be examined, and links to the object removed. The options are legio and the reference implementations shows what will have to be done
|
|
|
|
|