void __fastcall TfrmMain::Timer1Timer(TObject *Sender) { Chart->Data->Scroll(); _Generate(); _StoreValue( Chart->Data->ValueCount-1 ); Chart->PlotGraph(); }
GenerateSudoku::GenerateSudoku(SudokuField& field, int32 level, BMessenger progress, BMessenger target) : fField(field), fTarget(target), fProgress(progress), fLevel(level), fQuit(false) { fThread = spawn_thread(_GenerateThread, "sudoku generator", B_LOW_PRIORITY, this); if (fThread >= B_OK) resume_thread(fThread); else _Generate(); }
bool udGenerator::Generate(udDiagramItem *src, bool recursive) { m_fRecursive = recursive; /*if(!src) { UMLDesignerApp::Log(wxT("ERROR: No source diagram is specified.")); return false; }*/ // initialize generator IPluginManager::Get()->Log(wxT("Initializing generator...")); if(this->Initialize()) { IPluginManager::Get()->Log(wxT("Initialization is done.")); } else { IPluginManager::Get()->Log(wxT("ERROR: Initialization has failed.")); return false; } // generate code IPluginManager::Get()->Log(wxT("Starting code generation...")); bool fSuccess = _Generate(src); IPluginManager::Get()->Log(wxT("Code generation is done.")); // clean up IPluginManager::Get()->Log(wxT("Cleaning up the generator...")); this->CleanUp(); IPluginManager::Get()->Log(wxT("Clean up process is done.")); if( fSuccess ) { IPluginManager::Get()->Log(wxT("Generation process is done.")); } else IPluginManager::Get()->Log(wxT("Generation process is done with 'ERROR' status.")); return fSuccess; }
void TfrmMain::NewValues() { int nValueCount; ListBox1->Clear(); Chart->Data->Clear(); randomize(); Chart->Options->XAxisDateTimeMode = DateTimeAxisMode->Checked; // Use datetime timestamp labels, just Fer Instance-> if ( !Chart->Options->XAxisDateTimeMode) Chart->Options->XAxisLegendSkipBy = 5; if (LargeDataset576samples1->Checked ) { // A larger bogus data set for demonstration purposes-> nValueCount = 576; // 2->5 minute sample period, 576 samples == 1 day-> Foo = 5; // Used in generating our bogus data below, not really important-> Chart->Options->XAxisValuesPerDivision = 24; // 24 samples * 150 seconds == 1 hour time divisions ( Chart->Options->XAxisValuesPerDivision = 4; } else { // A smaller bogus data set for demonstration purposes-> nValueCount = 24; // 2->5 minute sample period, 24 samples =1 hour-> Foo = 1; // Used in generating our bogus data below, not really important-> Chart->Options->XAxisValuesPerDivision = 4; // five divisions, 4 values per division } //Chart->ResetGraphModule; // Clears YMax-> Fdt = floor(Now()- 1.0); // yesterday, midnight-> Foo1 = random(5)+2; // more randomness Foo2 = random(3)+5; // more randomness FGenerationIndex = 1; for (int i = 0; i < nValueCount; i++) { if (i > 0) { // generate random data that appears to show a sawtooth-frequency-pattern plus a lot of random noise: _Generate(); } else { FHgt = 7000; // First sample always known value, helps me troubleshoot-> FHg0 = 1000; } _StoreValue(i); // Override stored value in special cases: // How to make a gap in the data! if ((nValueCount>100 ) && ShowgapinLineChart1->Checked) { if ((i > 100) && (i < 130)) { Chart->Data->Value[0][i] = NaN; // Use special Math->NaN const Chart->Data->Value[1][i] = NaN; // Use special Math->NaN const Chart->Data->Value[2][i] = NaN; // Use special Math->NaN const } } // Just so that the last two values are visibly different, to make sure // the chart handles the final vaulues correctly, we set all the final // values to known amounts also: if ((i==nValueCount-2)) { Chart->Data->Value[0][i] = 6.0; // Use special Math->NaN const Chart->Data->Value[1][i] = 4.0; // Use special Math->NaN const Chart->Data->Value[2][i] = 2.0; // Use special Math->NaN const } else if ((i==nValueCount-1)) { Chart->Data->Value[0][i] = 3.0; // Use special Math->NaN const Chart->Data->Value[1][i] = 2.0; // Use special Math->NaN const Chart->Data->Value[2][i] = 1.0; // Use special Math->NaN const } ListBox1->Items->Append( Chart->Data->DebugStr(i) ); } // with Chart->Options do { Chart->Options->Title = "Chart Title"; Chart->Options->XAxisHeader = "Date/Time"; Chart->Options->YAxisHeader = "Readings (ng/m3)"; // Try out the pen styles: if (Chart->Options->ChartKind == ckChartStackedBar) Chart->Options->PenStyle[0] = psClear; // THIS IS HOW YOU TEMPORARILY HIDE ONE PEN! else Chart->Options->PenStyle[0] = psSolid; Chart->Options->PenStyle[1] = psDash; Chart->Options->PenStyle[2] = psDot; if (MenuSecondaryAxisMode->Checked) { Chart->Options->PenCount = 4; // Add a pen for right side demo-> Chart->Options->SecondaryYAxis->YMax = 140; // Example shows Q/A percentage-> Experimental results // results are compared to expected results, and the // response percentage, is plotted from 0% to 140% // of expected value-> Chart->Options->SecondaryYAxis->YMin = 0; Chart->Options->SecondaryYAxis->YLegendDecimalPlaces = 2; Chart->Options->PenSecondaryAxisFlag[3] = True; // Move pen index 3 (Fourth pen) to secondary axis-> Chart->Options->PenMarkerKind[3] = pmkDiamond; Chart->Options->PenValueLabels[3] = true; // Label with text-> Chart->Options->PenStyle[3] = psClear; // Markers only, no lines-> Chart->Options->PenColor[3] = clGray; Chart->Options->MarkerSize = 5; // Make "em bigger-> } else { Chart->Options->PenCount = 3; Chart->Options->MarkerSize = 3; // Make "em little } Chart->Options->PenLegends->Clear(); Chart->Options->PenLegends->Add("HgT"); Chart->Options->PenLegends->Add("Hg0"); Chart->Options->PenLegends->Add("Hg2+"); if (MenuSecondaryAxisMode->Checked) Chart->Options->PenLegends->Add("Quality%"); Chart->Options->PenUnit->Clear(); Chart->Options->PenUnit->Add("ug/m3"); Chart->Options->PenUnit->Add("ug/m3"); Chart->Options->PenUnit->Add("ug/m3"); if (MenuSecondaryAxisMode->Checked) Chart->Options->PenUnit->Add("%"); // Optional Pen in percentage scale-> //ShowLegend = TRUE; Chart->Options->Legend = clChartLegendBelow; //ChartKind = ckChartLine; } // Chart->AutoFormatGraph(); // WPostma. Removed. Chart->PlotGraph(); //Chart->ResizeChartCanvas; }
void SudokuWindow::MessageReceived(BMessage* message) { if (message->WasDropped()) { _MessageDropped(message); return; } switch (message->what) { case kMsgOpenFilePanel: fOpenPanel->Show(); break; case B_REFS_RECEIVED: case B_SIMPLE_DATA: _MessageDropped(message); break; case kMsgGenerateSudoku: { int32 level; if (message->FindInt32("level", &level) != B_OK) level = _Level(); _SetLevel(level); _Generate(level); break; } case kMsgAbortSudokuGenerator: if (fGenerator != NULL) fGenerator->Abort(); break; case kMsgSudokuGenerated: { BMessage archive; if (message->FindMessage("field", &archive) == B_OK) { SudokuField* field = new SudokuField(&archive); fSudokuView->SetTo(field); } fSudokuView->SetEditable(true); fProgressWindow->Stop(); delete fGenerator; fGenerator = NULL; break; } case kMsgExportAs: { if (message->FindInt32("as", (int32 *)&fExportFormat) < B_OK) fExportFormat = kExportAsText; fSavePanel->Show(); break; } case B_COPY: fSudokuView->CopyToClipboard(); break; case B_SAVE_REQUESTED: { entry_ref directoryRef; const char* name; if (message->FindRef("directory", &directoryRef) != B_OK || message->FindString("name", &name) != B_OK) break; BDirectory directory(&directoryRef); BEntry entry(&directory, name); entry_ref ref; if (entry.GetRef(&ref) == B_OK) fSudokuView->SaveTo(ref, fExportFormat); break; } case kMsgNewBlank: _ResetStoredState(); fSudokuView->ClearAll(); break; case kMsgStartAgain: fSudokuView->ClearChanged(); break; case kMsgMarkInvalid: case kMsgMarkValidHints: { BMenuItem* item; if (message->FindPointer("source", (void**)&item) != B_OK) return; uint32 flag = message->what == kMsgMarkInvalid ? kMarkInvalid : kMarkValidHints; item->SetMarked(!item->IsMarked()); if (item->IsMarked()) fSudokuView->SetHintFlags(fSudokuView->HintFlags() | flag); else fSudokuView->SetHintFlags(fSudokuView->HintFlags() & ~flag); break; } case kMsgStoreState: delete fStoredState; fStoredState = new BMessage; fSudokuView->Field()->Archive(fStoredState, true); fRestoreStateItem->SetEnabled(true); break; case kMsgRestoreState: { if (fStoredState == NULL) break; SudokuField* field = new SudokuField(fStoredState); fSudokuView->SetTo(field); break; } case kMsgSudokuSolved: { BAlert* alert = new BAlert(B_TRANSLATE("Sudoku request"), B_TRANSLATE("Sudoku solved - congratulations!\n"), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_IDEA_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); break; } case B_OBSERVER_NOTICE_CHANGE: { int32 what; if (message->FindInt32(B_OBSERVE_WHAT_CHANGE, &what) != B_OK) break; if (what == kUndoRedoChanged) { fUndoItem->SetEnabled(fSudokuView->CanUndo()); fRedoItem->SetEnabled(fSudokuView->CanRedo()); } break; } default: BWindow::MessageReceived(message); break; } }