/***************************************************************************** * * Copyright (c) 1999, KL GROUP INC. All Rights Reserved. * http://www.klgroup.com * * This file is provided for demonstration and educational uses only. * Permission to use, copy, modify and distribute this file for * any purpose and without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies, and that the name of KL Group not be used in advertising * or publicity pertaining to this material without the specific, * prior written permission of an authorized representative of * KL Group. * * KL GROUP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. KL GROUP SHALL NOT BE LIABLE FOR ANY * DAMAGES SUFFERED BY USERS AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * *****************************************************************************/ //--------------------------------------------------------------------------- #include #pragma hdrstop #include "dstrange1.h" #include "oc_color.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "OlectraChart3D_TLB" #pragma resource "*.dfm" TfrmDistRanges *frmDistRanges; //--------------------------------------------------------------------------- __fastcall TfrmDistRanges::TfrmDistRanges(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::FormCreate(TObject *Sender) //This is where it all begins! { //Start with the form in the top-left corner Top = 5; Left = 5; SetupTheChart(); //Load the first Data Set rbData1Click(rbData1); } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::mnuExitClick(TObject *Sender) //End the program. { exit(0); } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::mnuLFilter1Click(TObject *Sender) //Change the number of labels displayed in the Legend. { Variant vLegend = Chart3D1->Legend_; //Update the check marks on the Legend Filter Menu vLegend.OlePropertySet("LabelFilter", 1); mnuLFilter1->Checked = true; mnuLFilter2->Checked = false; mnuLFilter3->Checked = false; mnuLFilter4->Checked = false; mnuLFilter5->Checked = false; mnuLFilter6->Checked = false; mnuLFilter7->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::mnuLFilter2Click(TObject *Sender) //Change the number of labels displayed in the Legend. { Variant vLegend = Chart3D1->Legend_; //Update the check marks on the Legend Filter Menu vLegend.OlePropertySet("LabelFilter", 2); mnuLFilter1->Checked = false; mnuLFilter2->Checked = true; mnuLFilter3->Checked = false; mnuLFilter4->Checked = false; mnuLFilter5->Checked = false; mnuLFilter6->Checked = false; mnuLFilter7->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::mnuLFilter3Click(TObject *Sender) //Change the number of labels displayed in the Legend. { Variant vLegend = Chart3D1->Legend_; //Update the check marks on the Legend Filter Menu vLegend.OlePropertySet("LabelFilter", 3); mnuLFilter1->Checked = false; mnuLFilter2->Checked = false; mnuLFilter3->Checked = true; mnuLFilter4->Checked = false; mnuLFilter5->Checked = false; mnuLFilter6->Checked = false; mnuLFilter7->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::mnuLFilter4Click(TObject *Sender) //Change the number of labels displayed in the Legend. { Variant vLegend = Chart3D1->Legend_; //Update the check marks on the Legend Filter Menu vLegend.OlePropertySet("LabelFilter", 4); mnuLFilter1->Checked = false; mnuLFilter2->Checked = false; mnuLFilter3->Checked = false; mnuLFilter4->Checked = true; mnuLFilter5->Checked = false; mnuLFilter6->Checked = false; mnuLFilter7->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::mnuLFilter5Click(TObject *Sender) //Change the number of labels displayed in the Legend. { Variant vLegend = Chart3D1->Legend_; //Update the check marks on the Legend Filter Menu vLegend.OlePropertySet("LabelFilter", 5); mnuLFilter1->Checked = false; mnuLFilter2->Checked = false; mnuLFilter3->Checked = false; mnuLFilter4->Checked = false; mnuLFilter5->Checked = true; mnuLFilter6->Checked = false; mnuLFilter7->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::mnuLFilter6Click(TObject *Sender) //Change the number of labels displayed in the Legend. { Variant vLegend = Chart3D1->Legend_; //Update the check marks on the Legend Filter Menu vLegend.OlePropertySet("LabelFilter", 6); mnuLFilter1->Checked = false; mnuLFilter2->Checked = false; mnuLFilter3->Checked = false; mnuLFilter4->Checked = false; mnuLFilter5->Checked = false; mnuLFilter6->Checked = true; mnuLFilter7->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::mnuLFilter7Click(TObject *Sender) //Change the number of labels displayed in the Legend. { Variant vLegend = Chart3D1->Legend_; //Update the check marks on the Legend Filter Menu vLegend.OlePropertySet("LabelFilter", 7); mnuLFilter1->Checked = false; mnuLFilter2->Checked = false; mnuLFilter3->Checked = false; mnuLFilter4->Checked = false; mnuLFilter5->Checked = false; mnuLFilter6->Checked = false; mnuLFilter7->Checked = true; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::rbData1Click(TObject *Sender) //Load a Data Set based on the user's selection. { Variant vCG = Chart3D1->ChartGroups; Variant vCG1 = vCG.OlePropertyGet("Item", 1); Variant vCG1Data = vCG1.OlePropertyGet("ElevationData"); //Set the Mouse Cursor to an Hourglass Cursor = crHourGlass; vCG1Data.OleFunction("Load", "data1.dat"); //Set the Mouse Cursor back to its default state Cursor = crDefault; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::rbData2Click(TObject *Sender) //Load a Data Set based on the user's selection. { Variant vCG = Chart3D1->ChartGroups; Variant vCG1 = vCG.OlePropertyGet("Item", 1); Variant vCG1Data = vCG1.OlePropertyGet("ElevationData"); //Set the Mouse Cursor to an Hourglass Cursor = crHourGlass; vCG1Data.OleFunction("Load", "data2.dat"); //Set the Mouse Cursor back to its default state Cursor = crDefault; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::rbDistDataClick(TObject *Sender) //Change the number of Distribution Levels used based on the user's selection. { Variant vLegend = Chart3D1->Legend_; vLegend.OlePropertySet("DistributionRange", oc3dDistributionRangeData); } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::rbDistAllClick(TObject *Sender) //Change the number of Distribution Levels used based on the user's selection. { Variant vLegend = Chart3D1->Legend_; vLegend.OlePropertySet("DistributionRange", oc3dDistributionRangeAll); } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::rbGridLinesOnClick(TObject *Sender) //Turn the Grid Lines On. { //Set the Mouse Cursor to an Hourglass Cursor = crHourGlass; //Batch all the updates to the Chart so all the changes occur at once Chart3D1->IsBatched = true; Variant vCA = Chart3D1->ChartArea_; Variant vAxes = vCA.OlePropertyGet("Axes"); Variant vXAxis = vAxes.OlePropertyGet("Item", "X"); Variant vYAxis = vAxes.OlePropertyGet("Item", "Y"); Variant vZAxis = vAxes.OlePropertyGet("Item", "Z"); Variant vMGrid = vXAxis.OlePropertyGet("MajorGrid"); vMGrid.OlePropertySet("IsOnXYPlane", true); vMGrid.OlePropertySet("IsOnXZPlane", true); vMGrid = vYAxis.OlePropertyGet("MajorGrid"); vMGrid.OlePropertySet("IsOnXYPlane", true); vMGrid.OlePropertySet("IsOnYZPlane", true); vMGrid = vZAxis.OlePropertyGet("MajorGrid"); vMGrid.OlePropertySet("IsOnXZPlane", true); vMGrid.OlePropertySet("IsOnYZPlane", true); //Resume regular updates to the Chart Chart3D1->IsBatched = false; //Set the Mouse Cursor back to its default state Cursor = crDefault; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::rbGridLinesOffClick(TObject *Sender) //Turn the Grid Lines Off. { //Set the Mouse Cursor to an Hourglass Cursor = crHourGlass; //Batch all the updates to the Chart so all the changes occur at once Chart3D1->IsBatched = true; Variant vCA = Chart3D1->ChartArea_; Variant vAxes = vCA.OlePropertyGet("Axes"); Variant vXAxis = vAxes.OlePropertyGet("Item", "X"); Variant vYAxis = vAxes.OlePropertyGet("Item", "Y"); Variant vZAxis = vAxes.OlePropertyGet("Item", "Z"); Variant vMGrid = vXAxis.OlePropertyGet("MajorGrid"); vMGrid.OlePropertySet("IsOnXYPlane", false); vMGrid.OlePropertySet("IsOnXZPlane", false); vMGrid = vYAxis.OlePropertyGet("MajorGrid"); vMGrid.OlePropertySet("IsOnXYPlane", false); vMGrid.OlePropertySet("IsOnYZPlane", false); vMGrid = vZAxis.OlePropertyGet("MajorGrid"); vMGrid.OlePropertySet("IsOnXZPlane", false); vMGrid.OlePropertySet("IsOnYZPlane", false); //Resume regular updates to the Chart Chart3D1->IsBatched = false; //Set the Mouse Cursor back to its default state Cursor = crDefault; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::rbLegendContinuousClick(TObject *Sender) //Display the Legend in a Continuous Style. { //Set the Mouse Cursor to an Hourglass Cursor = crHourGlass; Variant vLegend = Chart3D1->Legend_; vLegend.OlePropertySet("Type", oc3dLegendTypeContinuous); //Set the Mouse Cursor back to its default state Cursor = crDefault; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::rbLegendSteppedClick(TObject *Sender) //Display the Legend in a Stepped Style. { //Set the Mouse Cursor to an Hourglass Cursor = crHourGlass; Variant vLegend = Chart3D1->Legend_; vLegend.OlePropertySet("Type", oc3dLegendTypeStepped); //Set the Mouse Cursor back to its default state Cursor = crDefault; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::rbMeshingOnClick(TObject *Sender) //Turn on the surface mesh. { Variant vCG = Chart3D1->ChartGroups; Variant vCG1 = vCG.OlePropertyGet("Item", 1); Variant vElevation = vCG1.OlePropertyGet("Elevation"); //Set the Mouse Cursor to an Hourglass Cursor = crHourGlass; vElevation.OlePropertySet("IsMeshed", true); //Set the Mouse Cursor back to its default state Cursor = crDefault; } //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::rbMeshingOffClick(TObject *Sender) //Turn off the surface mesh. { Variant vCG = Chart3D1->ChartGroups; Variant vCG1 = vCG.OlePropertyGet("Item", 1); Variant vElevation = vCG1.OlePropertyGet("Elevation"); //Set the Mouse Cursor to an Hourglass Cursor = crHourGlass; vElevation.OlePropertySet("IsMeshed", false); //Set the Mouse Cursor back to its default state Cursor = crDefault; } //--------------------------------------------------------------------------- void TfrmDistRanges::SetupTheChart() //Setup how the Chart looks. { Variant vCG = Chart3D1->ChartGroups; Variant vCG1 = vCG.OlePropertyGet("Item", 1); //Batch all the updates to the Chart so all the changes occur at once Chart3D1->IsBatched = true; //Turn on some visual settings so we get a Legend Variant vElevation = vCG1.OlePropertyGet("Elevation"); vElevation.OlePropertySet("IsMeshed", true); vElevation.OlePropertySet("IsShaded", true); Variant vContour = vCG1.OlePropertyGet("Contour"); vContour.OlePropertySet("IsContoured", true); vContour.OlePropertySet("IsZoned", true); //Swith to True Type fonts Chart3D1->UseTrueType = true; //Select the True Type Font to use Variant vCA = Chart3D1->ChartArea_; Variant vAxes = vCA.OlePropertyGet("Axes"); Variant vXAxis = vAxes.OlePropertyGet("Item", "X"); Variant vAnnoFont = vXAxis.OlePropertyGet("AnnotationFont"); Variant vTrueType = vAnnoFont.OlePropertyGet("TrueType"); vTrueType.OlePropertySet("Name", "Arial"); //Change the size of the font //SPECIAL NOTE: // The Axis font size is measured in units which are each 1/1000 of the // unit cube length. The default axis font size is 80, which means the // characters are 8% of the length of hte unit cube high. //UNIT CUBE DEFINITION: // The unit cube is defined to be the smallest cube which encloses the // entire 3D scene (including axis). vAnnoFont.OlePropertySet("Size", 90); //Change the color of the Chart Variant vInterior = Chart3D1->Interior_; vInterior.OlePropertySet("BackgroundColor", (int)ocColorDarkSlateGray); vInterior.OlePropertySet("ForegroundColor", (int)ocColorBlanchedAlmond); //Setup the Header Variant vHeader = Chart3D1->Header; vHeader.OlePropertySet("Text", "Distribution Range"); Variant vFont = vHeader.OlePropertyGet("Font"); vFont.OlePropertySet("Name", "Arial"); vFont.OlePropertySet("Size", 14); Variant vBorder = vHeader.OlePropertyGet("Border"); vBorder.OlePropertySet("Type", oc3dBorderBevel); vBorder.OlePropertySet("Width", 4); //Setup the Legend Variant vLegend = Chart3D1->Legend_; vLegend.OlePropertySet("Text", "Range"); vFont = vLegend.OlePropertyGet("Font"); vFont.OlePropertySet("Name", "Arial"); vFont.OlePropertySet("Size", 8); vBorder = vLegend.OlePropertyGet("Border"); vBorder.OlePropertySet("Type", oc3dBorderShadow); vBorder.OlePropertySet("Width", 4); vInterior = vLegend.OlePropertyGet("Interior"); vInterior.OlePropertySet("ForegroundColor", (int)ocColorCoral); //Add some styled grid lines to the Chart rbGridLinesOnClick(rbGridLinesOn); Variant vMGrid = vXAxis.OlePropertyGet("MajorGrid"); Variant vStyle = vMGrid.OlePropertyGet("Style"); vStyle.OlePropertySet("Color", (int)ocColorCoral); Variant vYAxis = vAxes.OlePropertyGet("Item", "Y"); vMGrid = vYAxis.OlePropertyGet("MajorGrid"); vStyle = vMGrid.OlePropertyGet("Style"); vStyle.OlePropertySet("Color", (int)ocColorCoral); Variant vZAxis = vAxes.OlePropertyGet("Item", "Z"); vMGrid = vZAxis.OlePropertyGet("MajorGrid"); vStyle = vMGrid.OlePropertyGet("Style"); vStyle.OlePropertySet("Color", (int)ocColorCoral); //Load the Distribution Levels Variant vLevels = vContour.OlePropertyGet("Levels"); vLevels.OleFunction("Load", "levels.lvl"); //Resume regular updates to the Chart Chart3D1->IsBatched = false; //Set the starting value for this holding value mnuLFilter1Click(mnuLFilter1); } void __fastcall TfrmDistRanges::FormResize(TObject *Sender) //Resize the Chart to fill the form. { Chart3D1->Height = ClientHeight - Chart3D1->Top; Chart3D1->Width = ClientWidth; } //--------------------------------------------------------------------------- // Show the 'About This Demo' Help Page //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::mnuAboutThisDemoClick(TObject *Sender) { Application->HelpContext(97); } //--------------------------------------------------------------------------- // Show the 'About Olectra Chart' Help Page //--------------------------------------------------------------------------- void __fastcall TfrmDistRanges::mnuAboutOlectraChartClick(TObject *Sender) { Application->HelpContext(12); } //---------------------------------------------------------------------------