Drawing Thicker Lines

Drawing Thicker Lines

Hello All,

I am using some of the Fortran Graphics primitives (CVF) for drawing lines , curves etc. However, I could not find a call to setup a thicker linestyle. How does one go about doing that. The call to setlinestyle helps me draw dotted and solid lines. How can I make them look thicker other than drawing multiple lines each offset by a small amount.

If there was a way to setline thickness that would be most helpful.

Thanks for any help

Sumit

11 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You can forget about QuickWin in this case. You will have
to use the Windows API functions CreatePen, SelectObject
and get into Device contexts. You will have to write a
win32 application, which opens a window and has a message
loop so that you can intercept the WM_PAINT messages and
do some thing like (where hWndDC is the handle stored to
a Device context on which you do all your plotting between
your BeginPaint and EndPaint commands)

		case (WM_PAINT)
!	hWndDC=ghWndDC
	retlog=getclientrect(hWnd,rc)
	ixwidth=rc%right-rc%left
 	iywidth=rc%bottom-rc%top
	XYRAT=DBLE(IXWIDTH)/DBLE(IYWIDTH)
	hWndDC=BeginPaint(hWnd,ps)
	retlog=MoveToEx(hWndDC,rc%left+2,rc%top+2, NULL_POINT)
	retlog=MSFWIn$LineTo(hWndDC,rc%right-3,rc%top+2 )
	retlog=MSFWIn$LineTo(hWndDC,rc%right-3,rc%bottom-3)
	retlog=MSFWIn$LineTo(hWndDC,rc%left+2,rc%bottom-3)
	retlog=MSFWIn$LineTo(hWndDC,rc%left+2,rc%top+2)
	CALL IGPLOT(hWnd, hWndDC,ISTATUS)

	retlog=EndPaint(hWnd,ps)

	MainWndProc=0
	return

where IGPLOT plots your lines etc and which will contain commands such as

C
C CREATE THE PEN AND SELECT IT INTO THE DEVICE CONTEXT
C
C  NOW SET THE LINE STYLE
C 0 = SOLID, 1 = LONG DASHED; 2 = SHORT DASHES; 3 = DOTTED
	IF(ISTYLE(I).EQ.0) hnewPen=CreatePen(PS_SOLID,0,ICOLOR(I))
	IF(ISTYLE(I).EQ.1) hnewPen=CreatePen(PS_DASH,0,ICOLOR(I))
	IF(ISTYLE(I).EQ.2) hnewPen=CreatePen(PS_DASHDOT,0,ICOLOR(I))
	IF(ISTYLE(I).EQ.3) hnewPen=CreatePen(PS_DOT,0,ICOLOR(I))
C	CHANGE THIS TEST VALUE TO 2 IF YOU WANT PIXELS SET FOR
C      ISTYLE = 3
	 IF(ISTYLE(I).LE.3) THEN
		hOldPen=SelectObject(hWndDC,hnewPen)
		DO  K=KBEGIN,KHALT
	     IF(DEPTH(K).EQ.1) THEN
	retlog=MoveToEx(hWndDC,int((XYZBEG(IABII,K)-xorig)/xscale)+4, &
     	4-int((XYZBEG(IABJJ,K)-yorig)/yscale), NULL_POINT)
	retlog=MSFWIn$LineTo(hWndDC,int((XYZEND(IABII,K)-xorig)/xscale)+4,  &
     	4-int((XYZEND(IABJJ,K)-yorig)/yscale))
!	     CALL MOVETO_W(XYZBEG(IABII,K),XYZBEG(IABJJ,K),WM)
!           LSTAT=LINETO_W(XYZEND(IABII,K),XYZEND(IABJJ,K))
 	     ENDIF
	    ENDDO
	hpen=SelectObject(hWndDC,hOldPen)
	retlog=DeleteObject(hpen)
	 ELSE

Good luck!

Thanks for the help and suggestion.
At least it tells me not to look for a quickwin solution.

Regards,

Sumit

Hello All,

Actually I was able to accomplish this in quickwin graphics by using the Polygon_W command and use the $GFillinterior option.

Sorry, message got posted before I could ask my queries to the group.
Is it possible to select a section of the graphics or more specifically, can I run (link) a subroutine by clicking on a certain section of the graphics. I was thinking that the screen co-ordinates are available and if we reserve a section of the screen for such tasks such that if we click on the red rectangle on the bottom right then call A , if on Green rectangle call B.
Probably not but I thought I will ask.

My second problem is with respect to modal dialog boxes and usage in quickwin. I typically use menus (Chaos example in CVF) to launch dialog boxes and now if I open two or more dialog boxes by clicking on different menus, the program crashes because of violation error. Is there a way to close any open dialog box automatically if a new item from the menu is chosen.

Thanks for any suggestion.
Regards,

Sumit

Re position-dependent callbacks: You can register mouse callback only for entire window, but you can test the mouse positon within it. Of course, that requires that you keep track about your objects drawn on the screen, i.e. to know where your "red" and "green" rectangles are.

Re dialog boxes: it's something strange. If you use modal dialogs (DLGMODAL) you shouldn't be even able to click on menu. Even if you use modeless dialogs, no crash should occur unless you try to launch the same dialog twice; however, in that case, you should normally disable the corresponding menu item.

Jugoslav

Jugoslav
www.xeffort.com

Thanks Jugoslav again,

I found that in some of the dialog calls I had not made a call to unusedqq(checked) just before initializing it (IDD_Dialog) and that caused me to access other items in the menu even though I did not close the open dialog box. Inserting that call seems to have taken care of the crash problem.

On the position dependent callbacks I will try following your lead.

Thanks

Sumit

I found that in some of the dialog calls I had not made a call to unusedqq(checked) just before initializing it (IDD_Dialog) and that caused me to access other items in the menu even though I did not close the open dialog box

This is becoming even more fishy. Unusedqq does nothing, as docs say, so it shouldn't be able to affect anything; however, it apparently does in your case. I'd guess that you have a hidden error of yours somewhere. "Array bounds check" and "Prevent constant arguments from changing" are probably on, aren't they? Maybe you mismatched callback prototype somewhere? Check whether all menu callbacks have a (checked), and dialog callbacks (Dlg,ID,iEvent) in arg-list.

Jugoslav

Jugoslav
www.xeffort.com

Hi Jugoslav,

Sorry was not able to get back to you as I was out for a while. Getting back to the issue. The reason it looks fishy to you is because I use the dialog box buttons and fields to draw to a window, say(5). So I change some values and click on an update command button and the drawing updates using the new values. At this stage the dialog works as a modal. I cannot click on any item on the menu. There is an OK button on the dialog and I exit the dialog pressing it leaving behind an window with the graphics still on it. I have made a mouse event such that when I right click I get an option to close that graph/drawing. It just makes a call to close unit 5. So far so good.

The problem occurs when the user is not disciplined enough to right click and close the graph. Say with the graph still displayed, if I click on the same menu item to open the dialog box, now the dialog box is not modal. I just verified this. I can now access any other menu item with that dialog box open and soon enough the application crashes.

I also tried to put the close(5) option in the ok calback and that works okay only if a graph has been displayed. If I opened the dialog box and did not click on " Draw" and pressed okay, the whole menu bar disappear leaving me with something of a main frame window.

So what I am looking for is a way to check if unit #5 window is open. If open close it before launching the dialog box.

What is the call for such a thing.
hWnd= GetHWNDQQ(5)or GetHWNDQQ($FRAMEWINDOW)! Dont know which one to use
if (hwnd.ne.-1) then
close (5)
end if
I tried the above with no success.

Thanks in advance for any help.

Sumit

The problem occurs when the user is not disciplined enough to right click and close the graph. Say with the graph still displayed, if I click on the same menu item to open the dialog box, now the dialog box is not modal. I just verified this. I can now access any other menu item with that dialog box open and soon enough the application crashes.

I also tried to put the close(5) option in the ok calback and that works okay only if a graph has been displayed. If I opened the dialog box and did not click on " Draw" and pressed okay, the whole menu bar disappear leaving me with something of a main frame window.

Sumit, I feel as if I'm reading science fiction :-). I do believe you, but at the moment I don't have a slightest idea what could have gone wrong.

You can send me an e-mail privately with complete compilable workspace (and input files, if any), but I can't make any promise when I will be able to take a look at it (I'm taking the next week free).

Jugoslav

Jugoslav
www.xeffort.com

QuickWin is broken in this regard and there isn't any workaround to my best knowledge. Alternatives are using Win32 API or my XFTGDI wrapper for it; alas, you can't use them in QuickWin child windows.

Additional caveat: Win9x family doesn't support non-solid (i.e. dotted, dashed) pens thicker than 1 pixel either. (Fortunately, that "OS" slowly goes to history).

Jugoslav

Jugoslav
www.xeffort.com

Leave a Comment

Please sign in to add a comment. Not a member? Join today