
Preface
To preempt those who may complain that this is not a new project (for whatever reason) I have the following three points to make:
- I agree that it is not an entirely new project (see the original article)
- However, if I don't repost it to the 'Tools' section the very people who requested it (.NET, Delphi, C++ Builder, etc users) will not find it.
- If you take to time to read the article you will see that there are aspects of it that are entirely diffrent from those of the original article.
If you do not think that it is original enough to (re)vote for it then I'm cool with that, but please take a moment to reflect if you're tempted to vote it down for the same reasons.
Introduction
When I first wrote CodePlotter as a VC6 addin I was very aware that .NET users might also be interested in a similar tool.
At the time however I did not see an easy way to resolve this except by writing a .NET specific addin.
So in the best tradition of ostrichs I ignored the issue and waited until I was forced to deal with it.
In due time one or two .NET users posted comments expressing an interest in a CodePlotter addin for VC7/.NET and I knew that I would have to deal with it, especially since so many people were voting it up.
Now, I had already made a short foray into VC7 addins when I tried to port ProjectZip to .NET and wasn't that a scary experience!
I don't know what Microsoft thought they were up to when they redesigned the plugin architecture for VC7 but it certainly was not portability of VC6 addins - I could not make head nor tail of the object model in the short time that I tried.
Fortunately, a C++ Builder coder who also dabbles in VB and Delphi came to my rescue and asked for a standalone executable .
This, I thought, smells like an opportunity not to be missed; and may yet save me from having to write a .NET port.
Still another poster asked for the modal dialog in the CodePlotter addin to be made modeless so that he could scroll his code as he drew the diagram. This however generates another problem because the addin relied on the selection not changing so that it could paste the edited diagram over the top of the original diagram.
An executable was therefore beginning to look like an excellent solution, since although it would lose its tight coupling with VC6, this would more than be made up for by the considerably greater flexibility of a standalone application.
CodePlotter Remoded
The first design to take form would have the user:
- copy and paste the diagram in their code into the CodePlotter interface
- edit the diagram
- copy (somehow) and paste the diagram back into their code.
This was okay I thought but lacked some of the finesse of the VC6 addin which was much slicker in how it used the selection mechanism of the object model to both select and replace the code diagram (a feature that in retrospect, was also its greatest constraint since the user has no scope for inserting the diagram at any other place in the code except by manually copying and pasting it afterwards) .
I left it for a bit and later when I got to thinking about it some more I found that my brain had made the link between 'copying and pasting' and the 'clipboard'.
Not a tremendously exciting or impressive leap but a valuable one nonetheless since it allowed me to postulate the programmatic use of the clipboard as the final piece in the puzzle; the piece that would possibly give it the slickness it was so far missing.
So I searched back through all my old code to see if I had something to get me started and I came across the following fragment:
OpenClipboard();
CString sText((LPCTSTR)::GetClipboardData(CF_TEXT));
CloseClipboard();
Gee, I though, surely it can't be this easy (and I'm sure some of you will be itching to tell me just how difficult it really should be), but it was.
So all I had to do then was ensure CodePlotter was notified whenever the clipboard contents changed, via SetClipboardViewer(), and I was set.
One final matter that was not discovered until I had the basic implementation up and running was how to prevent the user from having to run CodePlotter manually every time they wanted to edit a diagram, whilst at the same time not having it take up valuable space in the taskbar.
You've guessed it - our friend the system tray to the rescue.
So the way it works is this:
- The first time you want to use CodePlotter each session requires a manual start, unless you add it to your startup folder.
- Thereafter it resides as an icon in the system tray until it detects that you've just copied a diagram to the clipboard, whereupon it shows itself with the diagram already parsed.
- When you're done editing, the diagram is automatically copied back to the clipboard for you to paste back into your code.
Installing CodePlotter is as easy as...
- drop the executable into your "...\program files\microsoft visual studio\common\tools" folder
- Create a new tool for CodePlotter from the 'Tools|Customize...|Tools' tab
- Add the tool to your toolbar for easy access
Using CodePlotter
For a short tutorial on using CodePlotter I will refer you to this same section in the original article.
Other features only present in the standalone version include:
- A 'Copy' button for copying the current diagram to the clipboard without having to dismiss the dialog.
- A system tray context menu for exiting or displaying CodePlotter.
Inside CodePlotter
This section too is essentially unchanged from the original article except that in order not to have to copy the code, the CodePlotter exe borrows heavily from the Addin project.
This is more significant than it sounds because I also use Visual SourceSafe (VSS) at home.
The beef here is that VC6 when integrated with VSS does not allow more than one project to reside in the same hard drive directory (I had anticipated simply having two .dsp files in the same folder and share the code freely).
So I had to have two distinct project folder.
I know, I thought, I'll be really tricky and use VSS's share functionality to have a copy of the shared code in each of the project folders. That way each project will appear to have its own copy whilst in fact they are the same VSS file.
Half an hour later I remembered why this is a really bad idea � if the file is checked out to one folder and you check it back in from the other then it really easy to lose changes and end up completely b****red (that's 'battered' to you folk out there who were wondering if I was swearing).
So after about 3 false starts I decided for the KISS (keep it simple, stupid) approach � the CodePlotter executable project would share files from the addin project by including them in the Workspace|Files tab in VC6.
What's so significant about that?
Well, standard source files are ok, we do that all the time, but it was the first time I'd tried sharing an .rc file.
I knew already that VC6, except under considerable duress and with much incanting of spells and funny handshakes, will not let you have two .rc files in the same project so I just checked away the default one and added the addin's .rc file just as I had the other shared source files.
But then I hit another snag, the .rc2 file (just what is the point of that file anyway. I know what its intention is but I swear I have never seen an app use it � please someone show me a bonafide use for it).
The problem is that the .rc file includes this by relative path � relative to the project root that is � so although i was compiling the addin's .rc file in its original location the preprocessor wanted to locate CodePlotterAddin.rc2 in the standalone's folder.
So I did what any good hacker does. That's right, I simply deleted it to make it go away, and surprisingly enough it worked. More or less.
A bit more bodging of the .rc file to remove all references to it was required, as was a dummy .tlb file to stop the preprocessor from spitting the dummy (the .tlb file is the type library without which the addin would not export the necessary interfaces to communicate with VC6 � I know this because I tried deleting it too!)
Further Work
- Keyboard editing
- Better path finding when starting from the side opposite to the target box (the current implementation produces some very counter-intuitive solutions)
- Diamond shaped boxes
Copyright
The code is supplied here for you to use and abuse without restriction, except that you may not modify it and pass it off as your own.
History
- 1.0 Initial Release
- 1.1
- In-place editing of box text (thanks to =[ Abin ]=)
- Improved path finding (thanks to to_be_unknown)
- fixed bug relating to boxes resizing when moved (thanks to to_be_unknown)
- 1.2
- improved diagram verification (thanks to sunil_g7)
- context menus added for all non-drag'n'drop editing
- Enter/Escape keys can be used when editing box text
- 1.3
- reworked UI
- resizeable (and remembered between sessions) (thanks to Anonymous)
- Alternative comment styles for coder's wishing to working VB, NSBasic or C (thanks to Adrian Nicolaiev)
- 1.4
- 'Flip Connecton' added to context menu to reverse a connection's direction (thanks to Ralph Wetzel)
- press <F2> to edit the selected box's text (thanks to Anonymous)
- 1.6
- 'Copy' button bug fixed (thanks to Robert Etheridge)
- 'Resize box to fit' command removed for now (thanks to Robert Etheridge)
- '*' and '#' replaced by arrows at both the start and end of a connection (suggested by Robert Etheridge)
- user can define visual page width for guidance on line length (automatically takes any preceding comment length into account) (suggested by Robert Etheridge)
- some minor speed improvements
| You must Sign In to use this message board. |
|
|
 |
|
 |
I have not been able to get CodePlotter to work with Microsoft Visual C++ 2005 Express Edition. Is this a know limitation, or should I keep trying.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
The .EXE version works with anything as long as you have a text editor that can copy to the clipboard.
If you are talking about the Visual Studio add-in (in the earlier article) then the add-in was designed for Visual Studio 6 it cannot handle anything past that ie VS.Net (2002/7.0, 2003/7.1, 2005/8.0).
Andrew Phillips aphillips @ expertcomsoft.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks for the reply. I was asking about the VS add-in; thanks for letting me know that it will not work, and that I should quit trying.
--Malcolm
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I like such tools and actually was looking for one that I can decorate my code-comments better - as they say a picture is work a thousand words!
Cheers, Rohit Wason
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
In VC++6 sp6, When i go to Tools -> Customise -> Tools, and add a new tool, and close the Studio and reopen it, my tool gets disappeared.
Any Idea, as to why this is happening? Please help me if you know the reason or fix for it. As this is very urgent.
Thank you.
Regards, Chetan Sanghadia.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
First of all, thanks for a great tool! I'm amazed of it's simplicity and usefulness. This is something I've always needed, without knowing it 
I have a couple of requests/suggestions for upcoming versions:
1. Boxes may contain elements. This would allow for modeling of namespaces/packages and more.
2. Text elements, flexibility could easily be improved by allowing the user to place text directly into the diagram. This would be an easy way to support relationship multiplicity, stereotypes, etc.
3. Formatting. This is probably a matter of personal preference,
|__|---->|___| is clearer than |__>---->__| imho.
4. Text input in boxes, moving focus to another box does not save the current entered text. 'Enter' is required to save text, which is (imho) a bit unintuitive (but not a big deal). Although it would be nice to be able to enter multi-line text in a box.
Once again, many thanks for a great tool!
Live by the code!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
This is a great piece of software! Thanks for taking time not only to code it but also to support it.
I created some diagrams and added about 20 boxes and connections. After spending lots of time optimizing the layout I get in a state where the 'Copy' and 'Done' buttons are grayed-out.
Do you have any idea what can cause that?
Thanks again!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
the buttons are grayed out when the diagram cannot be 'verified'.
what happens when you make a change is that the text version of the diagram is recomputed and then re-interpreted to ensure that it has been correctly created.
essentially the problem is that the algorithm can sometimes get confused if there are too many lines and boxes and crossovers.
the best thing to do is to try spacing the boxes a little further apart in order to avoid connections running alongside boxes.
rgds
.dan.g.
AbstractSpoon Software
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Your soft is really great!
What is the reason to forbid "V" in the edit box? You set it in TextDiagramCtrl.cpp line 41.
Thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
doh!
sorry, i didn't think this thru properly.
before i changed the connection ends to use >,<,V,^ i used *,# so i excluded these to simplify the parsing of existing diagrams.
then i changed the connection ends to be more visually pleasing and excluded >,<,V,^ for the same reason.
clearly it didn't occur to me that excluding 'V' would cause any problems.
i will modify the source and re-post.
thanks for raising this.
regards
dang!
AbstractSpoon (subscribe)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Why do I get the following build errors? I'm using VS.NET 2003.
c:\codeplotter_src\Shared\TextDiagram.cpp(723): error C2440: 'initializing' : cannot convert from 'const CString' to 'CString &' c:\codeplotter_src\CodePlotterAddin\CDEditorDlg.cpp(79): error C2440: 'static_cast' : cannot convert from 'void (__thiscall CCDEditorDlg::* )(TDNHDR *,LRESULT *)' to 'void (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)' c:\codeplotter_src\CodePlotterAddin\CDEditorDlg.cpp(80): error C2440: 'static_cast' : cannot convert from 'void (__thiscall CCDEditorDlg::* )(TDNHDR *,LRESULT *)' to 'void (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)' c:\codeplotter_src\CodePlotterAddin\CDEditorDlg.cpp(81): error C2440: 'static_cast' : cannot convert from 'void (__thiscall CCDEditorDlg::* )(TDNHDR *,LRESULT *)' to 'void (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)' c:\codeplotter_src\CodePlotterAddin\CDEditorDlg.cpp(82): error C2440: 'static_cast' : cannot convert from 'void (__thiscall CCDEditorDlg::* )(TDNHDR *,LRESULT *)' to 'void (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)' c:\codeplotter_src\CodePlotterAddin\CDEditorDlg.cpp(83): error C2440: 'static_cast' : cannot convert from 'void (__thiscall CCDEditorDlg::* )(TDNHDR *,LRESULT *)' to 'void (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)'
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
it looks as though a couple of things have changed in .NET.
1. the first problem relates to changes in the definition of CString.
this can probably be solved by replacing line 723 with:
CString& sLine = diagram.ElementAt(nY);
2. the rest of the problems relate to a tightening up of the compiler in .NET - it clearly doesn't like the use of TDNHDR in the function definitions.
so, replace TDNHDR with NMHDR in the function parameters in both the .h and .cpp files and add replace all references to 'pTDHdr' with ((TDNHDR*)pTDHdr) in the function bodies.
let me know how it goes.
ps. i'll try to post an update as soon as i can.
regards
dang!
AbstractSpoon (subscribe)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi dang:
Thanks for the interesting project.
I'm using vs2008 compiling your project. Trying to get familiar with the compiler.
Not having the 1st error for CString happened to TLWallace
With your suggestions on 2nd part errors, it works.
But having two other errors: h:\codeproj test\tools\codeplotter_src\codeplotteraddin\cdeditordlg.cpp(319) : error C2039: 'ptCursor' : is not a member of 'tagNMHDR' h:\program files\microsoft sdks\windows\v6.0a\include\winuser.h(2857) : see declaration of 'tagNMHDR' h:\codeproj test\tools\codeplotter_src\shared\textdiagram.cpp(756) : error C2440: 'initializing' : cannot convert from 'const CString' to 'CString &'
Please advise.
Thanks.
Ke
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
May be some one like this format style, it's a good idea for support style choose .
aaaaa | |--aaaaa | |--aaaaa
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
- Add the standard Windows F2 shortcut to enter in the edit mode when a box is selected - Add a way to load a previously generated code - Change the main window to be resizable with minimize and maximize - Add a way to enable or disable the tray icon - Add a way to draw arrows by drag and drop
Thank you for this funny tool
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
thanks, all good requests.
>> Add the standard Windows F2 shortcut to enter in the edit mode when a box is selected
next release
>> Add a way to load a previously generated code
do you mean via MRU? or via the OpenFile dialog?
>> Change the main window to be resizable with minimize and maximize
next release
>> Add a way to enable or disable the tray icon
in what way?
>> Add a way to draw arrows by drag and drop
much more tricky, but i'll definitely give it some thought.
regards
dang!
AbstractSpoon
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I've some wishes for next release too 
1. Instead of the #---*, replace the * with arrowheads to specify direction (v^<>) 2. Allow labelling of connections (currently i've to place a box beside the line) 3. Is it possible, other than exporting to ascii text, allow for export to images, so that users can use it for other purpose too?
thanks!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
hi zichun,
thanks for your requests.
1. i used '*' originally to make it easier to figure out how to parse the diagrams but i agree that its probably time to switch over to arrows. 2. this is not really possible because there is no way to attach a label to a connection. one possibility would be to provide a specific comment style box which is different from the 'class' boxes. any thoughts? 3. the best thing here would probably be to use windows meta files. any thoughts?
regards
dang!
AbstractSpoon (subscribe)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
thanks matthew
if you look at the 'Further Work' section you'll see that diamond shapes is already on my list of to-dos 
what problems may arise, however, are more related to how well these shapes scale and how easily this can be encoded into a set of rules.
currently its in the back of my mind while i wait for a solution to gel.
regards
dang!
AbstractSpoon
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Great work, I like it.
Some minor user-interface suggestions: 1) System tray applications are usually opened after single click on the tray icon, and not double-click. 2) Select new rectangle and set focus to Text edit box after new rectangle is created. 3) Some users like minimize button on the dialog. 4) While in-place editing of a rectangle Enter key is ignored, Esc key closes a dialog.
I write this like some QA person (sorry). No offence, I hope.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
thanks alex.
2) and 4) have been dealt with in the latest release.
1) and 3) i'll do for the next release
ps. i rely on people such as yourself pointing out valid bugs/problems and i certainly don't take offense. in fact i'm just glad that when you find these problems that you don't take offense 
regards
dang!
AbstractSpoon
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
Copy the plotter window to clipboard (as bitmap) or directly print it! 
Best regards, Paul.
Jesus Christ is LOVE! Please tell somebody.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
thanks paul.
these should not be difficult to achieve, although my current focus is to improve the path finding algorithm to make it both faster and more reliable.
regards
dang!
AbstractSpoon
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Directly enter the class name, then the edit box will be gone too 
Best regards, Paul.
Jesus Christ is LOVE! Please tell somebody.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
thanks paul,
i think that this may be handled in the latest version.
as soon as a new box is created, the in-place edit box gets the focus and when you're done editing just hit the return key.
let me know if this is not what you meant. regards
dang!
AbstractSpoon
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|