CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > OpenSource CNC Design Center > Coding


Coding Post your Coding for opensource projects here.


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 11-08-2006, 01:56 PM
WayneHill's Avatar  
Join Date: Mar 2004
Location: Michigan
Posts: 769
Blog Entries: 5
WayneHill is on a distinguished road
Thumbs down OpenCascade CAD for Windows - Mega Problems

Does anyone here have OpenCascade CAD working with Windows?

I downloaded the 'Demo' version and could not make heads or tails out of it. My last weekend was spent trying to get to work. Downloaded the (win) Python compiler to interface with it. Didn't work. Downloaded (win) FreeCAD and it did not work. I am about ready to give up on it for a second and final time.
__________________
Wayne Hill
www.codemangler.com
Tweet this Post!Share on Facebook
Reply With Quote

  #2   Ban this user!
Old 11-08-2006, 11:15 PM
 
Join Date: Oct 2006
Location: USA
Posts: 46
jabuffi is on a distinguished road

You too?!?!??! And I thought I was alone with my struggles under OCC... Where did you download from? (I assume from opencascade.org, but you know what happens when we assume...)
Tweet this Post!Share on Facebook
Reply With Quote

  #3   Ban this user!
Old 11-09-2006, 12:58 AM
WayneHill's Avatar  
Join Date: Mar 2004
Location: Michigan
Posts: 769
Blog Entries: 5
WayneHill is on a distinguished road

It would take a rocket scientist to figure how to use OCC on Windows.

I downloaded it from www.opencascade.org

My little matrix rotation program was easier to program than that.

I used the Excel formula to map the 3D to 2D field. This does not help make chips, but does help show how a rotation matrix works.

Code:
#PBFORMS CREATED V1.50
#COMPILE EXE
#DIM ALL
'------------------------------------------------------------------------------
' 3D Matrix Rotation by Wayne Hill -  PB/Win 7.0
'------------------------------------------------------------------------------
'   ** Includes **
'------------------------------------------------------------------------------
#PBFORMS BEGIN INCLUDES
%USEMACROS = 1
#IF NOT %DEF( %WINAPI )
	#INCLUDE "WIN32API.INC"
#ENDIF
#IF NOT %DEF( %COMMCTRL_INC )
	#INCLUDE "COMMCTRL.INC"
#ENDIF
#INCLUDE "PBForms.INC"
#PBFORMS END INCLUDES

'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'   ** Constants **
'------------------------------------------------------------------------------
#PBFORMS BEGIN CONSTANTS
%frm_dialog = 101
%cmd_draw = 102
%IDC_MSCTLS_TRACKBAR32_1 = 104
%IDC_MSCTLS_TRACKBAR32_2 = 105
%IDC_MSCTLS_TRACKBAR32_3 = 106
%IDC_LABEL1 = 107
%IDC_LABEL2 = 108
%IDC_LABEL3 = 109
%IDC_LABEL4 = 110
%IDC_LABEL5 = 111
%IDC_LABEL6 = 112
%IDC_MSCTLS_TRACKBAR32_4 = 113
%IDC_LABEL7 = 114
%IDC_LABEL8 = 115
%IDC_BUTTON1 = 116
%IDC_BUTTON2 = 117
%IDC_BUTTON3 = 118
%IDC_BUTTON4 = 119
%IDC_BUTTON5 = 120
%IDC_LABEL9 = 121
%IDC_LABEL10 = 122
#PBFORMS END CONSTANTS
'------------------------------------------------------------------------------
#INCLUDE "CCDraw.INC"		'CCDraw include file - See Below
'------------------------------------------------------------------------------
'   ** Declarations **
'------------------------------------------------------------------------------
DECLARE CALLBACK FUNCTION Showfrm_dialogProc( )
DECLARE FUNCTION Showfrm_dialog( BYVAL hParent AS DWORD ) AS LONG
DECLARE SUB SetTrackBars( hWnd AS LONG, X AS LONG, Y AS LONG, Z AS LONG )
#PBFORMS DECLARATIONS
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'   ** Main Application Entry Point **
'------------------------------------------------------------------------------
FUNCTION PBMAIN( )
	PBFormsInitComCtls( %ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR %ICC_INTERNET_CLASSES )
	Showfrm_dialog %HWND_DESKTOP
END FUNCTION
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'   ** CallBacks **
'------------------------------------------------------------------------------
CALLBACK FUNCTION Showfrm_dialogProc( )
	LOCAL hTrackX AS DWORD
	LOCAL hTrackY AS DWORD
	LOCAL hTrackZ AS DWORD
	LOCAL hScale AS DWORD
	LOCAL hZoom AS LONG
	LOCAL rc AS RECT

	SELECT CASE AS LONG CBMSG
		CASE %WM_SIZE		'resize control if parent is resized
			IF CBWPARAM <> %SIZE_MINIMIZED THEN
				GETWINDOWRECT ghCCD, rc		' get control's coordinates on screen
				MAPWINDOWPOINTS 0, CBHNDL, rc, 2		' map result to dialog
				SETWINDOWPOS ghCCD, 0, 0, 0, LOWRD( CBLPARAM ) - rc.nleft - 10, _		' width
				  HIWRD( CBLPARAM ) - rc.nTop - 10, _		' height
				  %SWP_NOMOVE OR %SWP_NOZORDER
				INVALIDATERECT ghCCD, BYVAL %NULL, 0 : UPDATEWINDOW ghCCD		' Redraw Window
			END IF
		CASE %WM_HSCROLL
			CONTROL HANDLE CBHNDL, %IDC_MSCTLS_TRACKBAR32_1 TO hTrackX
			CONTROL HANDLE CBHNDL, %IDC_MSCTLS_TRACKBAR32_2 TO hTrackY
			CONTROL HANDLE CBHNDL, %IDC_MSCTLS_TRACKBAR32_3 TO hTrackZ
			CONTROL HANDLE CBHNDL, %IDC_MSCTLS_TRACKBAR32_4 TO hScale
			gXROT = SENDMESSAGE( hTrackX, %TBM_GETPOS, 0, 0 )
			CONTROL SET TEXT CBHNDL, %IDC_LABEL1, STR$( gXROT )
			gYROT = SENDMESSAGE( hTrackY, %TBM_GETPOS, 0, 0 )
			CONTROL SET TEXT CBHNDL, %IDC_LABEL2, STR$( gYROT )
			gZROT = SENDMESSAGE( hTrackZ, %TBM_GETPOS, 0, 0 )
			CONTROL SET TEXT CBHNDL, %IDC_LABEL3, STR$( gZROT )
			gMScale = SENDMESSAGE( hScale, %TBM_GETPOS, 0, 0 )
			CONTROL SET TEXT CBHNDL, %IDC_LABEL8, STR$( gMScale ) + "%"
			INVALIDATERECT ghCCD, BYVAL %NULL, 0 : UPDATEWINDOW ghCCD		' Redraw Window
		CASE %WM_INITDIALOG
			CONTROL HANDLE CBHNDL, %IDC_MSCTLS_TRACKBAR32_1 TO hTrackX
			SENDMESSAGE hTrackX, %TBM_SETRANGE, %TRUE, MAKLNG( 0, 360 * 2 )		' Set min. & max. positions
			SENDMESSAGE hTrackX, %TBM_SETPOS, %TRUE, 360		' Set current position
			CONTROL HANDLE CBHNDL, %IDC_MSCTLS_TRACKBAR32_2 TO hTrackY
			SENDMESSAGE hTrackY, %TBM_SETRANGE, %TRUE, MAKLNG( 0, 360 * 2 )		' Set min. & max. positions
			SENDMESSAGE hTrackY, %TBM_SETPOS, %TRUE, 360		' Set current position
			CONTROL HANDLE CBHNDL, %IDC_MSCTLS_TRACKBAR32_3 TO hTrackZ
			SENDMESSAGE hTrackZ, %TBM_SETRANGE, %TRUE, MAKLNG( 0, 360 * 2 )		' Set min. & max. positions
			SENDMESSAGE hTrackZ, %TBM_SETPOS, %TRUE, 360		' Set current position
			CONTROL HANDLE CBHNDL, %IDC_MSCTLS_TRACKBAR32_4 TO hScale
			SENDMESSAGE hScale, %TBM_SETRANGE, %TRUE, MAKLNG( 1, 1500 )		' Set min. & max. positions
			SENDMESSAGE hScale, %TBM_SETPOS, %TRUE, 100		' Set current position
			gMScale = 100
			INVALIDATERECT ghCCD, BYVAL %NULL, 0 : UPDATEWINDOW ghCCD		' Redraw Window
		CASE %WM_LBUTTONDOWN, %WM_LBUTTONDBLCLK		'start selrect draw
			gMouseDownInParent = 1
		CASE %WM_COMMAND
			SELECT CASE AS LONG CBCTL
				CASE %CMD_draw
					IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
						DIALOG END CBHNDL
					END IF
				CASE %IDC_BUTTON1
					IF CBCTLMSG = %BN_CLICKED THEN
						gXRot = 360 : gYRot = 360 : gZRot = 360
						SetTrackBars( CBHNDL, 360, 360, 360 )
					END IF
				CASE %IDC_BUTTON2
					IF CBCTLMSG = %BN_CLICKED THEN
						gXRot = 270 : gYRot = 360 : gZRot = 360
						SetTrackBars( CBHNDL, 270, 360, 360 )
					END IF
				CASE %IDC_BUTTON3
					IF CBCTLMSG = %BN_CLICKED THEN
						gXRot = 270 : gYRot = 360 : gZRot = 270
						SetTrackBars( CBHNDL, 270, 360, 270 )
					END IF
				CASE %IDC_BUTTON4
					IF CBCTLMSG = %BN_CLICKED THEN
						gXRot = 310 : gYRot = 360 : gZRot = 225
						SetTrackBars( CBHNDL, 310, 360, 225 )
					END IF
				CASE %IDC_BUTTON5
					IF CBCTLMSG = %BN_CLICKED THEN
						CONTROL HANDLE CBHNDL, %IDC_BUTTON5 TO hZoom
						IF SENDMESSAGE( hZoom, %BM_GETCHECK, 0, 0 ) = %BST_CHECKED THEN
							gZoomStatus = 1		'On
						ELSE
							gZoomStatus = 0		'Off
						END IF
					END IF
			END SELECT
	END SELECT
END FUNCTION
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'   ** Dialogs **
'------------------------------------------------------------------------------
FUNCTION Showfrm_dialog( BYVAL hParent AS DWORD ) AS LONG
	LOCAL lRslt AS LONG
#PBFORMS BEGIN DIALOG %frm_dialog->->
	LOCAL hDlg AS DWORD
	DIALOG NEW hParent, "3D Matrix Rotation", 153, 51, 414, 357, %WS_POPUP _
	  OR %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR _
	  %WS_MAXIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME _
	  OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_WINDOWEDGE _
	  OR %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
	  %WS_EX_RIGHTSCROLLBAR, TO hDlg
	CONTROL ADD BUTTON, hDlg, %cmd_draw, "Exit", 355, 10, 44, 16
	CONTROL ADD "msctls_trackbar32", hDlg, %IDC_MSCTLS_TRACKBAR32_1, _
	  "msctls_trackbar32_1", 25, 5, 305, 15, %WS_CHILD OR %WS_VISIBLE OR _
	  %TBS_HORZ OR %TBS_BOTTOM
	CONTROL ADD "msctls_trackbar32", hDlg, %IDC_MSCTLS_TRACKBAR32_2, _
	  "msctls_trackbar32_2", 25, 20, 305, 15, %WS_CHILD OR %WS_VISIBLE OR _
	  %TBS_HORZ OR %TBS_BOTTOM
	CONTROL ADD "msctls_trackbar32", hDlg, %IDC_MSCTLS_TRACKBAR32_3, _
	  "msctls_trackbar32_3", 25, 35, 305, 15, %WS_CHILD OR %WS_VISIBLE OR _
	  %TBS_HORZ OR %TBS_BOTTOM
	CONTROL ADD "msctls_trackbar32", hDlg, %IDC_MSCTLS_TRACKBAR32_4, _
	  "msctls_trackbar32_4", 25, 50, 305, 15, %WS_CHILD OR %WS_VISIBLE OR _
	  %TBS_HORZ OR %TBS_BOTTOM
	CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "360", 330, 5, 20, 10
	CONTROL ADD LABEL, hDlg, %IDC_LABEL2, "360", 330, 20, 20, 10
	CONTROL ADD LABEL, hDlg, %IDC_LABEL3, "360", 330, 35, 20, 10
	CONTROL ADD LABEL, hDlg, %IDC_LABEL4, "X", 5, 5, 15, 10
	CONTROL ADD LABEL, hDlg, %IDC_LABEL5, "Y", 5, 20, 15, 10
	CONTROL ADD LABEL, hDlg, %IDC_LABEL6, "Z", 5, 35, 15, 10
	CONTROL ADD LABEL, hDlg, %IDC_LABEL7, "Scale", 5, 50, 20, 10
	CONTROL ADD LABEL, hDlg, %IDC_LABEL8, "100%", 330, 50, 30, 10
	CONTROL ADD BUTTON, hDlg, %IDC_BUTTON1, "XY", 10, 70, 20, 15
	CONTROL ADD BUTTON, hDlg, %IDC_BUTTON2, "XZ", 35, 70, 20, 15
	CONTROL ADD BUTTON, hDlg, %IDC_BUTTON3, "YZ", 60, 70, 20, 15
	CONTROL ADD BUTTON, hDlg, %IDC_BUTTON4, "ISO", 85, 70, 20, 15
	CONTROL ADD BUTTON, hDlg, %IDC_BUTTON5, "Zoom", 110, 70, 30, 15, _
	  %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR _
	  %BS_DEFPUSHBUTTON OR %BS_PUSHLIKE OR %BS_AUTOCHECKBOX OR %BS_CENTER _
	  OR %BS_VCENTER, %WS_EX_LEFT OR %WS_EX_LTRREADING
	DIALOG SEND hDlg, %DM_SETDEFID, %IDC_BUTTON5, 0
	CONTROL ADD LABEL, hDlg, %IDC_LABEL9, "Label9", 155, 70, 55, 10
	CONTROL ADD LABEL, hDlg, %IDC_LABEL10, "Label10", 215, 70, 50, 10
#PBFORMS END DIALOG
	ghCCD = CreateCcd( hDlg, %ID_CCD, 10, 90, 80, 60, _
	  %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP _
	  , %WS_EX_CLIENTEDGE )
	DIALOG SHOW MODAL hDlg, CALL Showfrm_dialogProc TO lRslt
#PBFORMS BEGIN CLEANUP %frm_dialog
#PBFORMS END CLEANUP
	FUNCTION = lRslt
END FUNCTION
SUB SetTrackBars( hWnd AS LONG, X AS LONG, Y AS LONG, Z AS LONG )
	LOCAL hTrackX AS DWORD
	LOCAL hTrackY AS DWORD
	LOCAL hTrackZ AS DWORD
	LOCAL hScale AS DWORD
	CONTROL HANDLE hWnd, %IDC_MSCTLS_TRACKBAR32_1 TO hTrackX
	CONTROL HANDLE hWnd, %IDC_MSCTLS_TRACKBAR32_2 TO hTrackY
	CONTROL HANDLE hWnd, %IDC_MSCTLS_TRACKBAR32_3 TO hTrackZ
	CONTROL HANDLE hWnd, %IDC_MSCTLS_TRACKBAR32_4 TO hScale
	SENDMESSAGE hTrackX, %TBM_SETPOS, %TRUE, X
	SENDMESSAGE hTrackY, %TBM_SETPOS, %TRUE, Y
	SENDMESSAGE hTrackZ, %TBM_SETPOS, %TRUE, Z
	SENDMESSAGE hScale, %TBM_SETPOS, %TRUE, 100
	gMscale = 100
	gFirstTime = %TRUE
	CONTROL SET TEXT hWnd, %IDC_LABEL1, STR$( gXROT )
	CONTROL SET TEXT hWnd, %IDC_LABEL2, STR$( gYROT )
	CONTROL SET TEXT hWnd, %IDC_LABEL3, STR$( gZROT )
	CONTROL SET TEXT hWnd, %IDC_LABEL8, STR$( gMscale )
	INVALIDATERECT ghCCD, BYVAL %NULL, 0 : UPDATEWINDOW ghCCD		' Redraw Window
END SUB


'
'
'
'
'
'--------------------------------------------------------------
' CCDraw.INC, PB/Win 7.0 Custom Control Draw, by Wayne Hill.
'--------------------------------------------------------------
GLOBAL gXROT AS DOUBLE
GLOBAL gYROT AS DOUBLE
GLOBAL gZROT AS DOUBLE
GLOBAL ghCCD AS LONG
GLOBAL gMScale AS LONG
GLOBAL gxGridZero AS LONG
GLOBAL gyGridZero AS LONG
GLOBAL gZoomStatus AS LONG
GLOBAL gPt AS POINTAPI, gRc AS RECT
GLOBAL gPrevPt AS POINTAPI
GLOBAL gMouseDownInParent AS LONG
GLOBAL gxOffset AS LONG, gYoffset AS LONG
GLOBAL gFirstTime AS LONG
'Equates
%ID_CCD = 150
DECLARE SUB Matrix( hWnd AS DWORD, X AS DOUBLE, Y AS DOUBLE, Z AS DOUBLE, Xpoint AS LONG, Xpoint AS LONG )
DECLARE FUNCTION CreateCCD( BYVAL hWnd AS LONG, BYVAL CtrlId AS LONG, _
  BYVAL vLeft AS LONG, BYVAL vTop AS LONG, _
  BYVAL vWidth AS LONG, BYVAL vHeight AS LONG, _
  BYVAL wStyle AS LONG, BYVAL wStyleEx AS LONG ) AS LONG
DECLARE FUNCTION ctlWndProc( BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
  BYVAL wParam AS LONG, BYVAL lParam AS LONG ) AS LONG
DECLARE FUNCTION ccdPaint( BYVAL hWnd AS LONG, BYVAL wParam AS LONG ) AS LONG
DECLARE SUB DRAWCIRCLE( MemDC AS DWORD, hPen AS DWORD, fromX AS LONG, fromY AS LONG, ToX AS LONG, ToY AS LONG, radius AS LONG )
DECLARE SUB DRAWLINE( MemDC AS DWORD, hPen AS DWORD, fromX AS LONG, fromY AS LONG, ToX AS LONG, ToY AS LONG )
DECLARE SUB selRectBegin( BYVAL hWnd AS DWORD )
DECLARE SUB selRectDraw( BYVAL hWnd AS DWORD, BYVAL x AS LONG, BYVAL y AS LONG )
DECLARE SUB selRectEnd( BYVAL hWnd AS DWORD )

SUB Matrix( hWnd AS DWORD, X AS DOUBLE, Y AS DOUBLE, Z AS DOUBLE, Xpoint AS LONG, Ypoint AS LONG )
	LOCAL XSIN AS DOUBLE, YSIN AS DOUBLE, ZSIN AS DOUBLE
	LOCAL XCOS AS DOUBLE, YCOS AS DOUBLE, ZCOS AS DOUBLE
	LOCAL RMX1 AS DOUBLE, RMX2 AS DOUBLE, RMY1 AS DOUBLE
	LOCAL RMY2 AS DOUBLE, RMZ1 AS DOUBLE, RMZ2 AS DOUBLE
	LOCAL D2R AS DOUBLE
	LOCAL wRect AS RECT
	D2R = 0.0174532925199433
	XSIN = SIN( gXROT * D2R ) : YSIN = SIN( gYROT * D2R ) : ZSIN = SIN( gZROT * D2R )
	XCOS = COS( gXROT * D2R ) : YCOS = COS( gYROT * D2R ) : ZCOS = COS( gZROT * D2R )
	RMX1 = YCOS * ZCOS
	RMY1 = - ZSIN * YCOS
	RMZ1 = YSIN
	RMX2 = ZCOS * - YSIN * - XSIN + ZSIN * XCOS
	RMY2 = - ZSIN * - YSIN * - XSIN + ZCOS * XCOS
	RMZ2 = YCOS * - XSIN
	Xpoint = (( X * RMX1 ) + ( Y * RMY1 ) + ( Z * RMZ1 )) * gMScale
	Ypoint = (( X * RMX2 ) + ( Y * RMY2 ) + ( Z * RMZ2 )) * gMScale
	IF SGN( Ypoint ) THEN Ypoint = - Ypoint		' Mirror -X for Dialog inverse
	GETCLIENTRECT hWnd, wRect
	gxOffset = ( wRect.nRight / 2 ) + gxGridZero
	gyOffset = ( wRect.nBottom / 2 ) + gyGridZero
	Xpoint = Xpoint + gxOffset
	Ypoint = Ypoint + gyOffset
END SUB
' Create control
FUNCTION CreateCCD( BYVAL hWnd AS LONG, BYVAL CtrlId AS LONG, _
	  BYVAL vLeft AS LONG, BYVAL vTop AS LONG, _
	  BYVAL vWidth AS LONG, BYVAL vHeight AS LONG, _
	  BYVAL wStyle AS LONG, BYVAL wStyleEx AS LONG ) AS LONG
	LOCAL hCcd AS LONG
	LOCAL wc AS WNDCLASSEX
	LOCAL szClassName AS ASCIIZ * 20
	szClassName = "CCDRAW"
	IF GETCLASSINFOEX( GETMODULEHANDLE( BYVAL %NULL ), szClassName, wc ) = 0 THEN
		wc.cbSize = SIZEOF( wc )
		wc.style = %CS_DBLCLKS OR %CS_CLASSDC
		wc.lpfnWndProc = CODEPTR( ctlWndProc )
		wc.cbWndExtra = 4
		wc.hInstance = GETMODULEHANDLE( BYVAL %NULL )
		wc.hCursor = LOADCURSOR ( %NULL, BYVAL %IDC_CROSS )
		wc.lpszClassName = VARPTR( szClassName )
		REGISTERCLASSEX wc		'register new class
		IF ERR THEN EXIT FUNCTION		'something bad
	END IF
	CONTROL ADD "CCDRAW", hWnd, CtrlId, "", vLeft, vTop, vWidth, vHeight, wStyle, wStyleEx
	CONTROL HANDLE hWnd, CtrlId TO hCcd
	gFirstTime = %TRUE
	FUNCTION = hCcd		'return the handle
END FUNCTION
' Main Message Handling
FUNCTION ctlWndProc( BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
	  BYVAL wParam AS LONG, BYVAL lParam AS LONG ) AS LONG
	DIM HoldPos AS POINTAPI
	LOCAL hDC AS LONG
	SELECT CASE wMsg
		CASE %WM_LBUTTONDOWN, %WM_LBUTTONDBLCLK		'start selrect draw
			selRectBegin hWnd
			gMouseDownInParent = 0
		CASE %WM_MOUSEMOVE
			IF gMouseDownInParent THEN EXIT FUNCTION
			GETCURSORPOS HoldPos
			SCREENTOCLIENT hWnd, HoldPos
			CONTROL SET TEXT GETPARENT( hWnd ), %IDC_LABEL9, STR$( HoldPos.x )
			CONTROL SET TEXT GETPARENT( hWnd ), %IDC_LABEL10, STR$( HoldPos.y )
			IF ( wParam AND %MK_LBUTTON ) THEN		'if mouse button is down while moved, draw rect

            selRectDraw hWnd, LOWRD( lParam ), HIWRD( lParam )
            INVALIDATERECT ghCCD, BYVAL %NULL, 0 : UPDATEWINDOW ghCCD		' Redraw Window
			END IF
		CASE %WM_LBUTTONUP		'mouse button released - end draw
			selRectEnd hWnd
			gMouseDownInParent = 0
		CASE %WM_ERASEBKGND : FUNCTION = 1		' Don't erase background
		CASE %WM_PAINT : FUNCTION = ccdPaint( hWnd, wParam )
		CASE %WM_DESTROY
			hDc = GETDC( hWnd )
			DELETEDC( hDC )
		CASE ELSE : FUNCTION = DEFWINDOWPROC( hWnd, wMsg, wParam, lParam )		'default message processing
	END SELECT
END FUNCTION
' WM_PAINT message handler
FUNCTION ccdPaint( BYVAL hWnd AS LONG, BYVAL wParam AS LONG ) AS LONG
	LOCAL wRect AS RECT
	LOCAL hBrush AS LONG
	LOCAL YellowPen AS DWORD
	LOCAL RedPen AS DWORD
	LOCAL BluePen AS DWORD
	LOCAL GreenPen AS DWORD
	LOCAL BrownPen AS DWORD
	LOCAL GridLine AS DWORD
	'Create Pens
	RedPen = CREATEPEN( %PS_SOLID, 10, RGB( 255, 0, 0 ))
	YellowPen = CREATEPEN( %PS_SOLID, 10, RGB( 255, 255, 0 ))
	GreenPen = CREATEPEN( %PS_SOLID, 10, RGB( 150, 255, 100 ))
	BluePen = CREATEPEN( %PS_SOLID, 10, RGB( 0, 0, 255 ))
	BrownPen = CREATEPEN( %PS_SOLID, 10, RGB( 150, 100, 50 ))
	GridLine = CREATEPEN( %PS_DOT, 0, RGB( 0, 0, 0 ))
	LOCAL hDC AS LONG
	DIM mpx AS LONG
	DIM mpy AS LONG
	DIM mpx2 AS LONG
	DIM mpy2 AS LONG
	DIM Axes AS DOUBLE
	DIM Cage AS DOUBLE
	DIM Helix AS DOUBLE
	DIM I AS LONG
	DIM X AS DOUBLE, Y AS DOUBLE, Z AS DOUBLE
	'''''''''''''''''''''''''''''
	LOCAL hDCmem AS LONG
	LOCAL hbmMem AS LONG
	LOCAL hbmOld AS LONG
	LOCAL hPen AS LONG
   Local PS As PAINTSTRUCT

	CALL GETCLIENTRECT( hWnd, wRect )
   hDc = BeginPaint hWnd, PS
	hDCmem = CREATECOMPATIBLEDC( hdc ) ' Create off-screen DC
	hbmMem = CREATECOMPATIBLEBITMAP( hdc, wRect.nRight, wRect.nBottom )
	hbmOld = SELECTOBJECT( hDCmem, hbmMem )
	FILLRECT hDCmem, wRect, GETSTOCKOBJECT( %WHITE_BRUSH ) 'Paint Background
	SETBKMODE hDCmem, %TRANSPARENT
	Helix = .875
   ' Draw Quad Helix
	FOR i = 0 TO 360 STEP 10
		X = COS( I * ( 3.14159 / 180 )) * ( Helix )
		Y = SIN( I * ( 3.14159 / 180 )) * ( Helix )
		Z = ( Helix * 2 ) * ( i / 360 ) - Helix
		Matrix( hWnd, X, Y, Z, mpx, mpy )
		CALL DRAWCIRCLE( hDCmem, RedPen, mpx, mpy, mpx, mpy, 3 )
		X = COS(( I + 90 ) * ( 3.14159 / 180 )) * ( Helix )
		Y = SIN(( I + 90 ) * ( 3.14159 / 180 )) * ( Helix )
		Matrix( hWnd, X, Y, Z, mpx, mpy )
		CALL DRAWCIRCLE( hDCmem, BluePen, mpx, mpy, mpx, mpy, 3 )
		X = COS(( I + 180 ) * ( 3.14159 / 180 )) * ( Helix )
		Y = SIN(( I + 180 ) * ( 3.14159 / 180 )) * ( Helix )
		Matrix( hWnd, X, Y, Z, mpx, mpy )
		CALL DRAWCIRCLE( hDCmem, GreenPen, mpx, mpy, mpx, mpy, 3 )
		X = COS(( I + 270 ) * ( 3.14159 / 180 )) * ( Helix )
		Y = SIN(( I + 270 ) * ( 3.14159 / 180 )) * ( Helix )
		Matrix( hWnd, X, Y, Z, mpx, mpy )
		CALL DRAWCIRCLE( hDCmem, YellowPen, mpx, mpy, mpx, mpy, 3 )
	NEXT I
	Cage = 1.0
	' Draw cage
	Matrix( hWnd, Cage, Cage, Cage, mpx, mpy )
	Matrix( hWnd, - Cage, Cage, Cage, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )
	Matrix( hWnd, - Cage, - Cage, Cage, mpx, mpy )
	CALL DRAWLINE( hDCmem, GridLine, mpx2, mpy2, mpx, mpy )
	Matrix( hWnd, Cage, - Cage, Cage, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )
	Matrix( hWnd, Cage, Cage, Cage, mpx, mpy )
	CALL DRAWLINE( hDCmem, GridLine, mpx2, mpy2, mpx, mpy )
	Matrix( hWnd, Cage, Cage, - Cage, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )
	Matrix( hWnd, - Cage, Cage, - Cage, mpx, mpy )
	CALL DRAWLINE( hDCmem, GridLine, mpx2, mpy2, mpx, mpy )
	Matrix( hWnd, - Cage, - Cage, - Cage, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )
	Matrix( hWnd, Cage, - Cage, - Cage, mpx, mpy )
	CALL DRAWLINE( hDCmem, GridLine, mpx2, mpy2, mpx, mpy )
	Matrix( hWnd, Cage, - Cage, Cage, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )
	Matrix( hWnd, Cage, - Cage, - Cage, mpx, mpy )
	Matrix( hWnd, Cage, Cage, - Cage, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )
	Matrix( hWnd, - Cage, Cage, - Cage, mpx, mpy )
	Matrix( hWnd, - Cage, Cage, Cage, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )
	Matrix( hWnd, - Cage, - Cage, - Cage, mpx, mpy )
	Matrix( hWnd, - Cage, - Cage, Cage, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )
	' Draw Axes
	Axes = 1.25
	Matrix( hWnd, - Axes, 0, 0, mpx, mpy )
	Matrix( hWnd, Axes, 0, 0, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )		' X Axis
	TEXTOUT hDCmem, mpx2, mpy2, "X", LEN( "X" )
	Matrix( hWnd, 0, Axes, 0, mpx, mpy )
	TEXTOUT hDCmem, mpx, mpy, "Y", LEN( "Y" )
	Matrix( hWnd, 0, - Axes, 0, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )		' Y Axis
	Matrix( hWnd, 0, 0, Axes, mpx, mpy )
	TEXTOUT hDCmem, mpx, mpy, "Z", LEN( "Z" )
	Matrix( hWnd, 0, 0, - Axes, mpx2, mpy2 )
	CALL DRAWLINE( hDCmem, GridLine, mpx, mpy, mpx2, mpy2 )		' Z Axis
	IF gZoomStatus THEN		' Paint Zoom Window as needed
		hBrush = SELECTOBJECT( hDCmem, GETSTOCKOBJECT( %NULL_BRUSH ))		'for hollow rect
		hPen = SELECTOBJECT( hDCmem, CREATEPEN( %PS_SOLID, 2, GETSYSCOLOR ( %COLOR_3DSHADOW )))		'create pen
		RECTANGLE hDCmem, gRc.nLeft, gRc.nTop, gRc.nRight + 1, gRc.nBottom + 1		'draw rect
		DELETEOBJECT SELECTOBJECT( hDCmem, hPen )		'Destroy hPen
		DELETEOBJECT SELECTOBJECT( hDCmem, hBrush )		'Destroy hBrush
	END IF
    ' Copy Off-screen DC to Screen DC
	BITBLT( hDC, wRect.nLeft, _
	  wRect.nTop, wRect.nRight - wRect.nLeft, _
	  wRect.nBottom - wRect.nTop, _
	  hDCmem, 0, 0, %SRCCOPY )
	SELECTOBJECT( hDCmem, hbmOld )
	DELETEOBJECT hbmMem
	DELETEDC( hDCmem )
   EndPaint hWnd, PS
	'Destroy Pens
	DELETEOBJECT RedPen
	DELETEOBJECT YellowPen
	DELETEOBJECT GreenPen
	DELETEOBJECT BluePen
	DELETEOBJECT BrownPen
	DELETEOBJECT GridLine
END FUNCTION

SUB DRAWCIRCLE( MemDC AS DWORD, hPen AS DWORD, fromX AS LONG, fromY AS LONG, ToX AS LONG, ToY AS LONG, radius AS LONG )
	SELECTOBJECT( MemDC, hPen )		'Get Virtual Pen ready
	ELLIPSE MemDC, fromX - radius, fromY - radius, ToX + radius, ToY + radius
END SUB
SUB DRAWLINE( MemDC AS DWORD, hPen AS DWORD, fromX AS LONG, fromY AS LONG, ToX AS LONG, ToY AS LONG )
	DIM PrevPos AS POINTAPI
	SELECTOBJECT( MemDC, hPen )		'Get Virtual Pen ready
	MOVETOEX MemDC, fromX, fromY, PrevPos		'Move Virtual Pen
	LINETO MemDC, ToX, ToY		'Draw on Virual DC
	MOVETOEX MemDC, PrevPos.x, PrevPos.y, PrevPos		'Return to previous postion
END SUB
SUB selRectBegin( BYVAL hWnd AS DWORD )
	LOCAL rc AS RECT
	SELECT CASE gZoomStatus
		CASE 0
			SETCAPTURE hWnd		' set capture to desired window
			GETCLIENTRECT hWnd, rc		' get client size
			MAPWINDOWPOINTS hWnd, 0, rc, 2		' map client coordiantes to screen
			CLIPCURSOR rc		' clip cursor to client coordinates
			GETCURSORPOS gPt		' get cursor pos on screen
			SCREENTOCLIENT hWnd, gPt		' convert to client coordinates
			gPrevPt.x = gPt.x		'INI Mouse Point X-Y
			gPrevPt.y = gPt.y
		CASE 1
			SETCAPTURE hWnd		' set capture to desired window
			GETCLIENTRECT hWnd, rc		' get client size
			MAPWINDOWPOINTS hWnd, 0, rc, 2		' map client coordiantes to screen
			CLIPCURSOR rc		' clip cursor to client coordinates
			GETCURSORPOS gPt		' get cursor pos on screen
			SCREENTOCLIENT hWnd, gPt		' convert to client coordinates
	END SELECT
	INVALIDATERECT ghCCD, BYVAL %NULL, 0 : UPDATEWINDOW ghCCD		' Redraw Window
END SUB
SUB selRectDraw( BYVAL hWnd AS DWORD, BYVAL x AS LONG, BYVAL y AS LONG )
	SELECT CASE gZoomStatus
		CASE 0
			GETCURSORPOS gPt		' get cursor pos on screen
			SCREENTOCLIENT hWnd, gPt
			gxGridZero = gxGridZero + ( gPt.X - gPrevPt.x )
			gyGridZero = gyGridZero + ( gPt.Y - gPrevPt.Y )		'
			gPrevPt.x = gPt.x		' Store Mouse Position X + Y
			gPrevPt.y = gPt.y
		CASE 1
			' must make sure rect coordinates are correct,
			' so right side always is larger than left, etc.
			IF ( gPt.x < = x ) AND ( gPt.y > = y ) THEN
				SETRECT gRc, gPt.x, y, x, gPt.y
			ELSEIF ( gPt.x > x ) AND ( gPt.y > y ) THEN
				SETRECT gRc, x, y, gPt.x, gPt.y
			ELSEIF ( gPt.x > = x ) AND ( gPt.y < = y ) THEN
				SETRECT gRc, x, gPt.y, gPt.x, y
			ELSE
				SETRECT gRc, gPt.x, gPt.y, x, y
			END IF
			IF gRc.nLeft = gRc.nRight THEN INCR gRc.nRight		'<- ensure we never get a "null rect"
			IF gRc.nTop = gRc.nBottom THEN INCR gRc.nBottom
			' Let Virtual DC do rectangle draw
	END SELECT
END SUB
SUB selRectEnd( BYVAL hWnd AS DWORD )
	LOCAL rc AS RECT
	DIM CenterBox AS POINTAPI
	DIM CenterScreen AS POINTAPI
	LOCAL xs AS DOUBLE, ys AS DOUBLE
	LOCAL hScale AS LONG
	LOCAL NewScale AS LONG
	SELECT CASE gZoomStatus
		CASE 0
			RELEASECAPTURE
			CLIPCURSOR BYVAL %NULL
		CASE 1
			RELEASECAPTURE
			CLIPCURSOR BYVAL %NULL
			GETCURSORPOS gPt		' get cursor pos on screen
			SCREENTOCLIENT hWnd, gPt
			GETCLIENTRECT hWnd, rc
			CenterScreen.x = Rc.nRight / 2
			CenterScreen.y = Rc.nBottom / 2
			CenterBox.x = ( gRc.nRight + gRc.nLeft ) / 2
			CenterBox.y = ( gRc.nBottom + gRc.nTop ) / 2
			' Scale Drawing by ratio of ZoomBox to Screen size
			xs = rc.nRight \ ( gRc.nRight - gRc.nLeft )
			ys = rc.nBottom \ ( gRc.nBottom - gRc.nTop )
			NewScale = MAX( xs, ys )
			' Calculate the difference from GridZero
			' and center of screen then offset scale by difference.
			gxOffset = ( CenterScreen.x - CenterBox.x )
			gYoffset = ( CenterScreen.y - CenterBox.y )
			gxGridZero = gxGridZero + ( gxOffset * xs )
			gyGridZero = gyGridZero + ( gYoffset * ys )
			gMscale = gMscale * NewScale
			CONTROL HANDLE GETPARENT( hWnd ), %IDC_MSCTLS_TRACKBAR32_4 TO hScale
			SENDMESSAGE hScale, %TBM_SETPOS, %TRUE, gMscale
			CONTROL SET CHECK GETPARENT( hWnd ), %IDC_BUTTON5, 0
			gZoomStatus = 0
			CONTROL SET TEXT GETPARENT( hWnd ), %IDC_LABEL8, STR$( gMscale )
			gRc.nLeft = 0
			gRc.nTop = 0
			gRc.nRight = 0
			gRc.nBottom = 0
			INVALIDATERECT ghCCD, BYVAL %NULL, 0 : UPDATEWINDOW ghCCD		' Redraw Window
	END SELECT
END SUB
Attached Files
File Type: zip CCDraw.zip‎ (15.8 KB, 16 views)
__________________
Wayne Hill
www.codemangler.com

Last edited by WayneHill; 11-09-2006 at 01:15 AM. Reason: added code
Tweet this Post!Share on Facebook
Reply With Quote

  #4  
Old 11-09-2006, 05:39 PM
Gold Member
 
Join Date: Mar 2003
Location: United States
Posts: 269
imserv is on a distinguished road

Yes, Wayne, but just think what all you could do if you figured it out. I have manged to get the sample programs working. I think you needed .net for the latest build to work on windows, last I looked was in August, '06.

FAS
Tweet this Post!Share on Facebook
Reply With Quote

  #5   Ban this user!
Old 11-09-2006, 10:11 PM
WayneHill's Avatar  
Join Date: Mar 2004
Location: Michigan
Posts: 769
Blog Entries: 5
WayneHill is on a distinguished road

Hi Fred,

Yes, I did get the sample programs to run. I wanted to dig into the code structure and start working on a GUI. Yuck!!

There is another option that was "found" in my Delphi library. It was there all along. No need to go out wandering aimlessly through the world of C++.

Just wait about 6 months to see what I have dreamed up ...

Wayne
__________________
Wayne Hill
www.codemangler.com
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 11-11-2006, 11:44 PM
 
Join Date: Oct 2006
Location: USA
Posts: 46
jabuffi is on a distinguished road

You working on an opensource cad/cam application with a nice GUI?!?!?? DO TELL!!!
Tweet this Post!Share on Facebook
Reply With Quote

  #7   Ban this user!
Old 11-13-2006, 02:20 AM
WayneHill's Avatar  
Join Date: Mar 2004
Location: Michigan
Posts: 769
Blog Entries: 5
WayneHill is on a distinguished road

It is an OpenGL library for Borland Delphi 7 with a Steema TeeChart interface. Not a true open source, but a better starting point than OpenCascade.

I am too dumb to figure out the proper method of interfacing with OpenCascade through a C++ compiler. My tendancy is to find a better method that does not require the programmer to understand the inner workings of binary assembly language in order order to create useful programs.
__________________
Wayne Hill
www.codemangler.com
Tweet this Post!Share on Facebook
Reply With Quote

  #8   Ban this user!
Old 11-16-2006, 02:57 AM
 
Join Date: Mar 2004
Location: USA
Posts: 32
mpictor is on a distinguished road

Originally Posted by WayneHill View Post
Does anyone here have OpenCascade CAD working with Windows?

I downloaded the 'Demo' version and could not make heads or tails out of it. My last weekend was spent trying to get to work. Downloaded the (win) Python compiler to interface with it. Didn't work. Downloaded (win) FreeCAD and it did not work. I am about ready to give up on it for a second and final time.
You may need to set some environment variables so your programs can find the OCC libraries.

I'm not sure what you mean "demo version" - if you didn't download all of OCC, you probably need to do so.

Also, OpenCascade is *NOT* a cad program. It could be used as PART of a cad program, but it is the backend only. They do include some demos, but they don't do anything terribly useful. That's what you're supposed to code!

Mark
Tweet this Post!Share on Facebook
Reply With Quote

  #9   Ban this user!
Old 11-17-2006, 03:10 AM
WayneHill's Avatar  
Join Date: Mar 2004
Location: Michigan
Posts: 769
Blog Entries: 5
WayneHill is on a distinguished road

Mark,

You has a good start on the Linux version of OCC. My trouble is in the windows version. OCC.org open souce is what I called a demo version. The samples were the demos. Didn't do much. I was not able to change or add any features in the windows version using the windows version of python. That is why I was looking for any help out there in the windows platform.

Just got fed up with the whole thing and deleted it out of my computer.
__________________
Wayne Hill
www.codemangler.com
Tweet this Post!Share on Facebook
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -5. The time now is 01:19 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353