Use Windows.pkg Use DFClient.pkg Use gFormatNumbers.pkg Use cComSTL3DViewer.pkg Use Colr_dlg.pkg Use cSplitButton.pkg Use TrckBr.pkg Deferred_View Activate_oTestActiveX for ; Object oTestActiveX is a dbView Set Size to 368 335 Set Location to 2 2 Set Label to "Test STL Viewer" Set pbAutoActivate to True Set Maximize_Icon to True Object oOpenFileDialog is a OpenDialog Set Filter_String to ; 'Stereolithography (*.stl)|*.stl|; GLScene mesh file (*.gslm)|*.gslm|; Wavefront model file (*.obj)|*.obj|; Stripe model file (*.objf)|*.objf|; MD3 files|*.md3|; 3D Studio files (*.3DS)|*.3ds|; All files|*.stl;*.gslm;*.obj;*.objf;*.3ds;*.md3' //Set Initial_Folder to 'C:\Program Files\DataFlex' //Set Filter_Index to 2 End_Object Function CoordToDirTrack Float fCoord Returns Integer Integer iCoord Move (100*fCoord) to iCoord If (iCoord>100) Move 100 to iCoord Else If (iCoord<-100) Move -100 to iCoord Function_Return iCoord End_Function Function CoordToPosTrack Float fCoord Returns Integer Integer iCoord Move (10*fCoord) to iCoord If (iCoord>10) Move 100 to iCoord Else If (iCoord<-10) Move -100 to iCoord Function_Return iCoord End_Function Procedure DisplayCurrentLightSettings Send SetDefaultColor of oLightSourceAmbientColorSelector Send SetDefaultColor of oLightSourceDiffuseColorSelector Send SetDefaultColor of oLightSourceSpecularColorSelector Send SetDefault of oDirectionForm Send SetDefault of oPositionForm Send SetDefault of oLight_cb Send SetDefault of oLightStyleBtn Send SetDefault of oAttenuationTrack End_Procedure Object oOpenButton is a Button Set Location to 209 273 Set Label to 'Open...' Set peAnchors to anBottomRight // fires when the button is clicked Procedure OnClick Boolean bOpen bReadOnly String sFileTitle sFileName String[] sSelectedFiles Get Show_Dialog of oOpenFileDialog to bOpen If bOpen Begin //Get TickReadOnly_State of oOpenFileDialog to bReadOnly Get File_Title of oOpenFileDialog to sFileTitle Get Selected_Files of oOpenFileDialog to sSelectedFiles //If (bReadOnly) Append sSelectedFiles[0] ' (Read-Only)' //Send Info_Box ; // ("File Title=" + sSelectedFiles[0] + "\nFile Name=" + sFileName) //Set ComDoOpenFile of oSTLViewer to sSelectedFiles[0] //"G:\Projects\Embarcadero\STLViewer\IkeaLikeChair2.stl" Send ComDoOpenFile of oSTLViewer sSelectedFiles[0] Send DisplayCurrentLightSettings Send DisplayCubeSize of oCubeSizeForm End Else Send Info_Box "You did NOT choose a file" End_Procedure End_Object Object oSTLViewer is a cComSTL3DViewer Set Size to 195 309 Set Location to 11 14 Set peAnchors to anAll Procedure OnCreate Forward Send OnCreate // Set the ActiveX properties here... End_Procedure Embed_ActiveX_Resource VFBGMAxUU1RMM0RWaWV3ZXILU1RMM0RWaWV3ZXIETGVmdAIYA1RvcAIUBVdpZHRoAxwCBkhlaWdodANtAQdDYXB0aW9uBgtTVEwzRFZpZXdlcgVDb2xvcgcJY2xCdG5G YWNlDEZvbnQuQ2hhcnNldAcPREVGQVVMVF9DSEFSU0VUCkZvbnQuQ29sb3IHDGNsV2luZG93VGV4dAtGb250LkhlaWdodAL1CUZvbnQuTmFtZQYGVGFob21hCkZvbnQu U3R5bGULAA5PbGRDcmVhdGVPcmRlcggNUGl4ZWxzUGVySW5jaAJgClRleHRIZWlnaHQCDQAA. End_Embed_ActiveX_Resource // // For easier creation of a light source object // Returns a DataFlex object handle if exists and created properly // other wise returns 0 // NOTE that you must release the object yourself. // Function CreateLightSourceObject Returns Handle Boolean bIsCreated Handle hoLightSource Get Create (RefClass(cComSTL3DViewerLightSource)) to hoLightSource If (hoLightSource) Begin Get IsComObjectCreated of hoLightSource to bIsCreated If (bIsCreated=False) Begin Send CreateComObject of hoLightSource End Get IsComObjectCreated of hoLightSource to bIsCreated If (bIsCreated=False) Begin // Failed creating Send Destroy of hoLightSource Move 0 to hoLightSource End End Function_Return hoLightSource End_Function End_Object Object oAxis_cb is a CheckBox Set Size to 10 50 Set Location to 213 14 Set Label to "Axis" Set psToolTip to "Display Axis on the picture" Set Checked_State to True Set peAnchors to anBottomLeft // Fires whenever the value of the control is changed Procedure OnChange Boolean bChecked Get Checked_State to bChecked Set ComAxisVisible of oSTLViewer to bChecked End_Procedure End_Object Object oViewStyleBtn is a cSplitButton Set Size to 14 71 Set Location to 210 100 Set Label to 'View Style' Set peAnchors to anBottomRight // fires when the button is clicked Procedure OnClick //Showln (Label(Self)) End_Procedure Object oButtonMenu is a cCJContextMenu Object oMenuItem1 is a cCJMenuItem Set psCaption to "Smooth Shading" Procedure OnExecute Variant vCommandBarControl Delegate Set Label to "Smooth Shading" //Delegate Set psImage to "ActionSaveRecord.ico" Set ComViewStyle of oSTLViewer to OLEacViewSmoothShading End_Procedure End_Object Object oMenuItem2 is a cCJMenuItem Set psCaption to "Flat Shading" Procedure OnExecute Variant vCommandBarControl Delegate Set Label to "Flat Shading" Delegate Set psImage to "" Set ComViewStyle of oSTLViewer to OLEacViewFlatShading End_Procedure End_Object Object oMenuItem3 is a cCJMenuItem Set psCaption to "Flat with Lines" Procedure OnExecute Variant vCommandBarControl Delegate Set Label to "Flat with Lines" Delegate Set psImage to "" Set ComViewStyle of oSTLViewer to OLEacViewFlatLines End_Procedure End_Object Object oMenuItem4 is a cCJMenuItem Set psCaption to "Hidden Lines" Procedure OnExecute Variant vCommandBarControl Delegate Set Label to "Hidden Lines" Delegate Set psImage to "" Set ComViewStyle of oSTLViewer to OLEacViewHiddenLines End_Procedure End_Object Object oMenuItem5 is a cCJMenuItem Set psCaption to "Wireframe" Procedure OnExecute Variant vCommandBarControl Delegate Set Label to "Wireframe" Delegate Set psImage to "" Set ComViewStyle of oSTLViewer to OLEacViewWireFrame End_Procedure End_Object End_Object Set phoButtonPopup to oButtonMenu End_Object Object oBackgroundColorSelector is a Bitmapcontainer Set Size to 14 13 Set Location to 210 68 Set psToolTip to "Set Background Color" Set Enabled_State to False Set Focus_Mode to NonFocusable Set Skip_State to True Set Border_Style to Border_StaticEdge Set peAnchors to anBottomLeft Procedure Activating Integer clColor Forward Send Activating Get ComBackgroundColor of oSTLViewer to clColor Set Color to clColor End_Procedure Procedure Mouse_Down Integer iWindowNumber Integer iPosition Integer clColor Integer clCurrent Forward Send Mouse_Down iWindowNumber iPosition Get ComBackgroundColor of oSTLViewer to clCurrent Get SelectColor of oColorDialog clCurrent to clColor Set ComBackgroundColor of oSTLViewer to clColor //clGreen Set Color to clColor End_Procedure // Mouse_Down End_Object Object oMaterialColorSelector is a Bitmapcontainer Set Size to 14 13 Set Location to 210 82 Set psToolTip to "Set Material Color" Set Enabled_State to False Set Focus_Mode to NonFocusable Set Skip_State to True Set Border_Style to Border_StaticEdge Set peAnchors to anBottomLeft Procedure Activating Integer clColor Forward Send Activating Get ComMaterialColor of oSTLViewer to clColor Set Color to clColor End_Procedure Procedure Mouse_Down Integer iWindowNumber Integer iPosition Integer clColor Integer clCurrent Forward Send Mouse_Down iWindowNumber iPosition Get ComMaterialColor of oSTLViewer to clCurrent Get SelectColor of oColorDialog clCurrent to clColor Set ComMaterialColor of oSTLViewer to clColor //clGreen Set Color to clColor End_Procedure // Mouse_Down End_Object Object oResetButton is a Button Set Size to 14 18 Set Location to 210 173 Set Label to "R" Set psToolTip to "Reset original Camera view" Set peAnchors to anBottomRight // fires when the button is clicked Procedure OnClick Send ComResetCamera of oSTLViewer End_Procedure End_Object Object oLightingButton is a Button Set Size to 14 18 Set Location to 210 191 Set Label to "S" Set psToolTip to "Lighting yes/no, with lights shadows are rendered" Set peAnchors to anBottomRight Procedure OnClick Boolean bVisible Get ComLightingVisible of oSTLViewer to bVisible Move (not(bVisible)) to bVisible Set ComLightingVisible of oSTLViewer to bVisible End_Procedure End_Object Object oCubeExtents_cb is a CheckBox Set Size to 10 50 Set Location to 229 14 Set Label to "Extents Cube" Set Checked_State to True Set psToolTip to "Turn the white extents box in which the object is rendered on/off" Set peAnchors to anBottomLeft Procedure OnChange Boolean bChecked Get Checked_State to bChecked Set ComCubeExtentsBorder of oSTLViewer to bChecked End_Procedure End_Object Object oCubeSizeForm is a Form Set Size to 13 107 Set Location to 227 100 Set Enabled_State to False Set Label to "Size:" Set Label_Col_Offset to 32 Set peAnchors to anBottomLeft Procedure DisplaySize TxCoordinate3 CubeSize String sValue Move (SFormat("X=%1, Y=%2, Z=%3",FormatNumber(CubeSize.X,2),FormatNumber(CubeSize.Y,2),FormatNumber(CubeSize.Z,2))) to sValue Set Value to sValue End_Procedure Procedure DisplayCubeSize TxCoordinate3 llSize Move 0 to llSize.X Move 0 to llSize.Y Move 0 to llSize.Z Get ComCubeExtentsWidth of oSTLViewer to llSize.X Get ComCubeExtentsHeight of oSTLViewer to llSize.Y Get ComCubeExtentsDepth of oSTLViewer to llSize.Z Send DisplaySize llSize End_Procedure End_Object Object oLightSourceSelectCombo is a ComboForm Set Size to 12 53 Set Location to 227 213 Set Entry_State to False Set peAnchors to anBottomRight // Combo_Fill_List is called when the list needs filling Procedure Combo_Fill_List Send Combo_Add_Item "Lamp 0" Send Combo_Add_Item "Lamp 1" Send Combo_Add_Item "Lamp 2" Send Combo_Add_Item "Lamp 3" End_Procedure Procedure OnChange Integer iOld iNew String sValue Get ComCurrentLightSource of oSTLViewer to iOld Get Value to sValue // the current selected item Case Begin Case (sValue="Lamp 0") Move 0 to iNew Case Break Case (sValue="Lamp 1") Move 1 to iNew Case Break Case (sValue="Lamp 2") Move 2 to iNew Case Break Case (sValue="Lamp 3") Move 3 to iNew Case Break Case End If (iOld <> iNew) Begin Set ComCurrentLightSource of oSTLViewer to iNew Send DisplayCurrentLightSettings End End_Procedure End_Object Object oLightGroup is a Group Set Size to 116 313 Set Location to 245 5 Set Label to "Light Settings" Set peAnchors to anBottomLeft Object oLightSourceDiffuseColorSelector is a Bitmapcontainer Set Size to 14 13 Set Location to 10 64 Set psToolTip to "Set Diffuse Color for light source" Set Enabled_State to False Set Focus_Mode to NonFocusable Set Skip_State to True Set Border_Style to Border_StaticEdge Procedure SetDefaultColor Handle hoLightSource Integer clColor Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Get ComDiffuseColor of hoLightSource to clColor Set Color to clColor Send Destroy of hoLightSource End End_Procedure Procedure Mouse_Down Integer iWindowNumber Integer iPosition Handle hoLightSource Integer clColor Integer clCurrent Forward Send Mouse_Down iWindowNumber iPosition Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Get ComDiffuseColor of hoLightSource to clCurrent Get SelectColor of oColorDialog clCurrent to clColor Set ComDiffuseColor of hoLightSource to clColor Set Color to clColor Send Destroy of hoLightSource End End_Procedure // Mouse_Down End_Object Object oLightSourceAmbientColorSelector is a Bitmapcontainer Set Size to 14 13 Set Location to 10 78 Set psToolTip to "Set Ambient Color for the light source" Set Enabled_State to False Set Focus_Mode to NonFocusable Set Skip_State to True Set Border_Style to Border_StaticEdge Procedure SetDefaultColor Handle hoLightSource Integer clColor Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Get ComAmbientColor of hoLightSource to clColor Set Color to clColor Send Destroy of hoLightSource End End_Procedure Procedure Mouse_Down Integer iWindowNumber Integer iPosition Handle hoLightSource Integer clColor Integer clCurrent Forward Send Mouse_Down iWindowNumber iPosition Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Get ComAmbientColor of hoLightSource to clCurrent Get SelectColor of oColorDialog clCurrent to clColor Set ComAmbientColor of hoLightSource to clColor Set Color to clColor Send Destroy of hoLightSource End End_Procedure // Mouse_Down End_Object Object oLightSourceSpecularColorSelector is a Bitmapcontainer Set Size to 14 13 Set Location to 10 92 Set psToolTip to "Set Specular Color for the light source" Set Enabled_State to False Set Focus_Mode to NonFocusable Set Skip_State to True Set Border_Style to Border_StaticEdge Procedure SetDefaultColor Handle hoLightSource Integer clColor Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Get ComSpecularColor of hoLightSource to clColor Set Color to clColor Send Destroy of hoLightSource End End_Procedure Procedure Mouse_Down Integer iWindowNumber Integer iPosition Handle hoLightSource Integer clColor Integer clCurrent Forward Send Mouse_Down iWindowNumber iPosition Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Get ComSpecularColor of hoLightSource to clCurrent Get SelectColor of oColorDialog clCurrent to clColor Set ComSpecularColor of hoLightSource to clColor Set Color to clColor Send Destroy of hoLightSource End End_Procedure // Mouse_Down End_Object Object oLightLabel is a TextBox Set Size to 10 41 Set Location to 12 16 Set Label to "Light Source:" End_Object Object oLightStyleBtn is a cSplitButton Set Size to 14 60 Set Location to 10 107 Set Label to "Light Style" Set peAnchors to anBottomRight // fires when the button is clicked Procedure OnClick //Showln (Label(Self)) End_Procedure Object oButtonMenu is a cCJContextMenu Object oMenuItem1 is a cCJMenuItem Set psCaption to "Spot" Procedure OnExecute Variant vCommandBarControl Handle hoLightSource Delegate Set Label to "Spot" Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Set ComLightStyle of hoLightSource to OLElsSpot Send Destroy of hoLightSource End End_Procedure End_Object Object oMenuItem2 is a cCJMenuItem Set psCaption to "Omnidirectional" Procedure OnExecute Variant vCommandBarControl Handle hoLightSource Delegate Set Label to "Omnidirectional" Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Set ComLightStyle of hoLightSource to OLElsOmni Send Destroy of hoLightSource End End_Procedure End_Object Object oMenuItem3 is a cCJMenuItem Set psCaption to "Parallel" Procedure OnExecute Variant vCommandBarControl Handle hoLightSource Delegate Set Label to "Parallel" Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Set ComLightStyle of hoLightSource to OLElsParallel Send Destroy of hoLightSource End End_Procedure End_Object Object oMenuItem4 is a cCJMenuItem Set psCaption to "Parallel spot" Procedure OnExecute Variant vCommandBarControl Handle hoLightSource Delegate Set Label to "Parallel spot" Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Set ComLightStyle of hoLightSource to OLElsParallelSpot Send Destroy of hoLightSource End End_Procedure End_Object Object oMenuItem5 is a cCJMenuItem Set psCaption to "OFF" Procedure OnExecute Variant vCommandBarControl Boolean bShining Handle hoLightSource Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin //Set ComLightStyle of hoLightSource to OLElsParallelSpot Get ComShining of hoLightSource to bShining If (bShining) Begin Set psCaption to "ON" Delegate Set Label to "OFF" Set ComShining of hoLightSource to False End Else Begin Set psCaption to "OFF" Delegate Set Label to "ON" Set ComShining of hoLightSource to True End Send Destroy of hoLightSource End End_Procedure End_Object End_Object Procedure SetDefault Handle hoLightSource OLETxLightStyle lsStyle Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Get ComLightStyle of hoLightSource to lsStyle Case Begin Case (lsStyle=OLElsSpot) Set Label to "Spot" Case Break Case (lsStyle=OLElsOmni) Set Label to "Omnidirectional" Case Break Case (lsStyle=OLElsParallel) Set Label to "Parallel" Case Break Case (lsStyle=OLElsParallelSpot) Set Label to "Parallel spot" Case Break Case End Send Destroy of hoLightSource End End_Procedure Set phoButtonPopup to oButtonMenu End_Object Object oDirXTrack is a TrackBar Set Size to 16 100 Set Location to 33 15 Set Minimum_Position to -100 // OnSetPosition is always called when the slider changes. Procedure OnSetPosition If (Focus(Self)=Self) Begin Send ChangeDirection of oDirectionForm "X" End End_Procedure End_Object Object oDirYTrack is a TrackBar Set Size to 16 100 Set Location to 51 15 Set Minimum_Position to -100 // OnSetPosition is always called when the slider changes. Procedure OnSetPosition If (Focus(Self)=Self) Begin Send ChangeDirection of oDirectionForm "Y" End End_Procedure End_Object Object oDirZTrack is a TrackBar Set Size to 16 100 Set Location to 69 15 Set Minimum_Position to -100 // OnSetPosition is always called when the slider changes. Procedure OnSetPosition If (Focus(Self)=Self) Begin Send ChangeDirection of oDirectionForm "Z" End End_Procedure End_Object Object oPosXTrack is a TrackBar Set Size to 16 100 Set Location to 33 140 Set Minimum_Position to -100 // OnSetPosition is always called when the slider changes. Procedure OnSetPosition If (Focus(Self)=Self) Begin Send ChangePosition of oPositionForm "X" End End_Procedure End_Object Object oPosYTrack is a TrackBar Set Size to 16 100 Set Location to 51 140 Set Minimum_Position to -100 // OnSetPosition is always called when the slider changes. Procedure OnSetPosition If (Focus(Self)=Self) Begin Send ChangePosition of oPositionForm "Y" End End_Procedure End_Object Object oPosZTrack is a TrackBar Set Size to 16 100 Set Location to 69 140 Set Minimum_Position to -100 // OnSetPosition is always called when the slider changes. Procedure OnSetPosition If (Focus(Self)=Self) Begin Send ChangePosition of oPositionForm "Z" End End_Procedure End_Object Object oXLabel is a TextBox Set Size to 10 12 Set Location to 38 4 Set Label to "X" End_Object Object oYLabel is a TextBox Set Size to 10 12 Set Location to 57 4 Set Label to "Y" End_Object Object oZLabel is a TextBox Set Size to 10 12 Set Location to 76 4 Set Label to "Z" End_Object Object oDirectionForm is a Form Set Size to 13 77 Set Location to 93 39 Set Enabled_State to False Set Label to "Direction" Set Label_Col_Offset to 32 Procedure DisplayCoords TxCoordinate3 Coord String sValue Move (SFormat("%1,%2,%3",FormatNumber(Coord.X,2),FormatNumber(Coord.Y,2),FormatNumber(Coord.Z,2))) to sValue Set Value to sValue End_Procedure Procedure SetDefault Handle hoLightSource TxCoordinate3 llDir Move 0 to llDir.X Move 0 to llDir.Y Move 0 to llDir.Z Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Send ComCurrentDirection of hoLightSource (&llDir.X) (&llDir.Y) (&llDir.Z) Set Current_Position of oDirXTrack to (CoordToDirTrack(Self,llDir.X)) Set Current_Position of oDirYTrack to (CoordToDirTrack(Self,llDir.Y)) Set Current_Position of oDirZTrack to (CoordToDirTrack(Self,llDir.Z)) Send DisplayCoords llDir Send Destroy of hoLightSource End End_Procedure Procedure ChangeDirection String sDir Handle hoLightSource Integer iNewDir TxCoordinate3 llDir Move 0 to llDir.X Move 0 to llDir.Y Move 0 to llDir.Z Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Send ComCurrentDirection of hoLightSource (&llDir.X) (&llDir.Y) (&llDir.Z) If (sDir="X") Begin Get Current_Position of oDirXTrack to iNewDir Move (iNewDir/100.0) to llDir.X End If (sDir="Y") Begin Get Current_Position of oDirYTrack to iNewDir Move (iNewDir/100.0) to llDir.Y End If (sDir="Z") Begin Get Current_Position of oDirZTrack to iNewDir Move (iNewDir/100.0) to llDir.Z End Send ComChangeDirection of hoLightSource llDir.X llDir.Y llDir.Z Send DisplayCoords llDir Send Destroy of hoLightSource End End_Procedure End_Object Object oPositionForm is a Form Set Size to 13 77 Set Location to 93 163 Set Enabled_State to False Set Label to "Position" Set Label_Col_Offset to 32 Procedure DisplayCoords TxCoordinate3 Coord String sValue Move (SFormat("%1,%2,%3",FormatNumber(Coord.X,2),FormatNumber(Coord.Y,2),FormatNumber(Coord.Z,2))) to sValue Set Value to sValue End_Procedure Procedure SetDefault Handle hoLightSource TxCoordinate3 llPos Move 0 to llPos.X Move 0 to llPos.Y Move 0 to llPos.Z Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Send ComCurrentPosition of hoLightSource (&llPos.X) (&llPos.Y) (&llPos.Z) Set Current_Position of oPosXTrack to (CoordToPosTrack(Self,llPos.X)) Set Current_Position of oPosYTrack to (CoordToPosTrack(Self,llPos.Y)) Set Current_Position of oPosZTrack to (CoordToPosTrack(Self,llPos.Z)) Send DisplayCoords llPos Send Destroy of hoLightSource End End_Procedure Procedure ChangePosition String sPos Handle hoLightSource Integer iNewPos Float fWidth fRangeX Float fHeight fRangeY Float fDepth fRangeZ TxCoordinate3 llPos Move 0 to llPos.X Move 0 to llPos.Y Move 0 to llPos.Z Get ComCubeExtentsWidth of oSTLViewer to fWidth Get ComCubeExtentsHeight of oSTLViewer to fHeight Get ComCubeExtentsDepth of oSTLViewer to fDepth Move (1.4*fWidth) to fRangeX Move (1.4*fHeight) to fRangeY Move (1.4*fDepth) to fRangeZ If (fRangeX=0.0) Move 10.0 to fRangeX If (fRangeY=0.0) Move 10.0 to fRangeY If (fRangeZ=0.0) Move 10.0 to fRangeZ Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Send ComCurrentPosition of hoLightSource (&llPos.X) (&llPos.Y) (&llPos.Z) If (sPos="X") Begin Get Current_Position of oPosXTrack to iNewPos Move ((iNewPos*fRangeX)/100.0) to llPos.X End If (sPos="Y") Begin Get Current_Position of oPosYTrack to iNewPos Move ((iNewPos*fRangeY)/100.0) to llPos.Y End If (sPos="Z") Begin Get Current_Position of oPosZTrack to iNewPos Move ((iNewPos*fRangeZ)/100.0) to llPos.Z End Send ComChangePosition of hoLightSource llPos.X llPos.Y llPos.Z Send DisplayCoords llPos Send Destroy of hoLightSource End End_Procedure End_Object Object oLight_cb is a CheckBox Set Size to 10 50 Set Location to 13 187 Set Label to "Light On/Off" Set psToolTip to "Turn a light source on/off" // Fires whenever the value of the control is changed Procedure OnChange Integer iLight Boolean bChecked If (Focus(Self)=Self) Begin Get Checked_State to bChecked Get ComCurrentLightSource of oSTLViewer to iLight Set ComLightShining of oSTLViewer iLight to bChecked End End_Procedure Procedure SetDefault Integer iLight Boolean bChecked Get ComCurrentLightSource of oSTLViewer to iLight Get ComLightShining of oSTLViewer iLight to bChecked Set Checked_State to bChecked End_Procedure End_Object Object oAttenuationTrack is a TrackBar Set Size to 83 18 Set Location to 20 279 Set Orientation_Mode to slVert Set Tick_Orientation to tkBottom Set Minimum_Position to 0 Set Maximum_Position to 100 // OnSetPosition is always called when the slider changes. Procedure OnSetPosition Integer iCurPos Float fAttenuation Handle hoLightSource Get Current_Position to iCurPos Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Move (iCurPos/100.0) to fAttenuation Set ComConstAttenuation of hoLightSource to fAttenuation Send Destroy of hoLightSource End End_Procedure Procedure SetDefault Float fAttenuation Integer iCurPos Handle hoLightSource Get CreateLightSourceObject of oSTLViewer to hoLightSource If (hoLightSource) Begin Get ComConstAttenuation of hoLightSource to fAttenuation Move (fAttenuation*100.0) to iCurPos Set Current_Position to iCurPos Send Destroy of hoLightSource End End_Procedure End_Object End_Object Object oCameraBackligt_cb is a CheckBox Set Size to 10 50 Set Location to 228 271 Set Label to "Camera back light" Set peAnchors to anBottomRight // Fires whenever the value of the control is changed Procedure OnChange Boolean bChecked Get Checked_State to bChecked Set ComCameraLightConnected of oSTLViewer to bChecked End_Procedure End_Object Cd_End_Object Object oColorDialog is a ColorDialog // SelectColor is NOT a predefined method in the OpenDialog class, // SelectColor is just a code sample. // You can call SelectColor from another object, such as a button. Function SelectColor Integer clCurrent Returns Integer Integer iRgbColor Boolean bColorSelected Set SelectedColor to clCurrent Get Show_Dialog to bColorSelected If (bColorSelected) Begin Get SelectedColor to iRgbColor End Else Move clCurrent to iRgbColor Function_Return iRgbColor End_Function End_Object