//--------------------------------------------------------------------------- #include #pragma hdrstop #include "MainForm.h" #include "ChildForm.h" #include "ToolWin.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TfrmTools *frmTools; //--------------------------------------------------------------------------- __fastcall TfrmTools::TfrmTools(TComponent* Owner) : TForm(Owner), myForm(NULL) { this->Left = Form1->Width - this->Width - 40; this->Top = Form1->Top + 40; comboDriver->ItemIndex = 0; cbTruncation->ItemIndex = 0; } //--------------------------------------------------------------------------- void TfrmTools::AssignChild(TfrmChild* frm){ myForm = NULL; txtP->Text = String(frm->schlafli_p); txtQ->Text = String(frm->schlafli_q); txtMaxIso->Text = String(frm->settings.maxIsometries); shpPrimal->Brush->Color = (TColor)frm->settings.primalColor; shpDual->Brush->Color = (TColor)frm->settings.dualColor; shpSnub->Brush->Color = (TColor)frm->settings.snubColor; shpBoundary->Brush->Color = (TColor)frm->settings.boundaryColor; shpBack->Brush->Color = (TColor)frm->settings.backColor; chkEnablePrimal->Checked = frm->settings.drawPrimal; chkEnableDual->Checked = frm->settings.drawDual; chkEnableSnub->Checked = frm->settings.drawSnub; chkEnableBoundary->Checked = frm->settings.drawBoundary; chkLabelVerts->Checked = frm->settings.showVertexLabels; chkLabelSegments->Checked = frm->settings.showSegmentLabels; rgModel->ItemIndex = frm->settings.hyperbolicModel; rgQuality->ItemIndex = frm->settings.doCurveLines; rgSnubParity->ItemIndex = frm->settings.snubParity; chkRandomJitter->Checked = frm->settings.doRandomJitter; chkAlternateDraw->Checked = frm->settings.doAlternateDraw; chkDrawGrid->Checked = frm->settings.drawGrid; chkDrawSchwarzPolygon->Checked = frm->settings.drawSchwarzPolygon; chkFadeOutColors->Checked = frm->settings.fadeOutColors; chkTriangle1->Checked = frm->settings.drawTriangle1; chkTriangle2->Checked = frm->settings.drawTriangle2; chkDrawExperimental->Checked = frm->settings.drawExperimental; comboDriver->ItemIndex = frm->driverSelection; chkAntiAlias->Checked = frm->antiAlias; txtLineThickness->Text = String(frm->lineThickness); cbTruncation->ItemIndex = frm->currentOperation; myForm = frm; } //--------------------------------------------------------------------------- void TfrmTools::SetChild(TfrmChild* frm){ frm->schlafli_p = atoi(txtP->Text.c_str()); frm->schlafli_q = atoi(txtQ->Text.c_str()); frm->settings.maxLevels = 1000; frm->settings.maxIsometries = atoi(txtMaxIso->Text.c_str()); frm->settings.primalColor = (int)shpPrimal->Brush->Color; frm->settings.dualColor = (int)shpDual->Brush->Color; frm->settings.snubColor = (int)shpSnub->Brush->Color; frm->settings.boundaryColor = (int)shpBoundary->Brush->Color; frm->settings.backColor = (int)shpBack->Brush->Color; frm->settings.hyperbolicModel = rgModel->ItemIndex; frm->settings.doCurveLines = rgQuality->ItemIndex; frm->settings.snubParity = rgSnubParity->ItemIndex; frm->settings.drawPrimal = chkEnablePrimal->Checked; frm->settings.drawDual = chkEnableDual->Checked; frm->settings.drawSnub = chkEnableSnub->Checked; frm->settings.drawBoundary = chkEnableBoundary->Checked; frm->settings.showVertexLabels = chkLabelVerts->Checked; frm->settings.showSegmentLabels = chkLabelSegments->Checked; frm->settings.doRandomJitter = chkRandomJitter->Checked; frm->settings.doAlternateDraw = chkAlternateDraw->Checked; frm->settings.drawGrid = chkDrawGrid->Checked; frm->settings.drawSchwarzPolygon = chkDrawSchwarzPolygon->Checked; frm->settings.fadeOutColors = chkFadeOutColors->Checked; frm->settings.drawTriangle1 = chkTriangle1->Checked; frm->settings.drawTriangle2 = chkTriangle2->Checked; frm->settings.drawExperimental = chkDrawExperimental->Checked; frm->lineThickness = atoi(txtLineThickness->Text.c_str()); frm->setDriver(comboDriver->ItemIndex); if(cbTruncation->ItemIndex != -1) frm->setCurrentOperation(cbTruncation->ItemIndex); //update wythoff coeffs in this window... txtWythoff0->Text = String(frm->currentWythoff[0]); txtWythoff1->Text = String(frm->currentWythoff[1]); txtWythoff2->Text = String(frm->currentWythoff[2]); frm->setAntiAlias(chkAntiAlias->Checked); } //--------------------------------------------------------------------------- void TfrmTools::RemoveChild(TfrmChild* frm){ if(myForm == frm) myForm = NULL; } //--------------------------------------------------------------------------- void __fastcall TfrmTools::txtPChange(TObject *Sender){ if(!myForm) return; int p = atoi(txtP->Text.c_str()); if((p-2)*(myForm->schlafli_q-2) <= 4) return; SetChild(myForm); myForm->drawIt(); } //--------------------------------------------------------------------------- void __fastcall TfrmTools::txtQChange(TObject *Sender){ if(!myForm) return; int q = atoi(txtQ->Text.c_str()); if((myForm->schlafli_p-2)*(q-2) <= 4) return; SetChild(myForm); myForm->drawIt(); } //--------------------------------------------------------------------------- void __fastcall TfrmTools::txtMaxIsoChange(TObject *Sender){ if(!myForm) return; int i = atoi(txtMaxIso->Text.c_str()); if((i < 10) || (i > 200000)) return; SetChild(myForm); myForm->drawIt(); } //--------------------------------------------------------------------------- void __fastcall TfrmTools::txtLineThicknessChange(TObject *Sender){ if(!myForm) return; int i = atoi(txtLineThickness->Text.c_str()); if((i < 1) || (i > 16)) return; SetChild(myForm); myForm->drawIt(); } //--------------------------------------------------------------------------- void __fastcall TfrmTools::simpleChange(TObject *Sender){ if(!myForm) return; SetChild(myForm); myForm->drawIt(); } //--------------------------------------------------------------------------- void __fastcall TfrmTools::shpMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y){ ColorDialog1->Color = ((TShape*)Sender)->Brush->Color; if(!ColorDialog1->Execute()) return; ((TShape*)Sender)->Brush->Color = ColorDialog1->Color; if(!myForm) return; SetChild(myForm); myForm->drawIt(); } //--------------------------------------------------------------------------- void __fastcall TfrmTools::cmdResetOrientationClick(TObject *Sender){ if(!myForm) return; myForm->resetOrientation(); myForm->drawIt(); } //--------------------------------------------------------------------------- void __fastcall TfrmTools::cmdMakeSnubUniformClick(TObject *Sender){ if(!myForm) return; myForm->makeSnubUniform(); myForm->drawIt(); } //---------------------------------------------------------------------------