void COptionsDlg::OnNotify() { TCHAR msg[MAX_PATH]; CButton *button = (CButton *) GetDlgItem(IDC_NOTIFY); assert(button != NULL); if (button->GetCheck() == 1) { _stprintf(msg, _T("Printing to stderr can cause unexpected failures.\n") _T("Are you sure you want to set this option?\n")); int res = ::MessageBox(NULL, msg, _T("Confirmation"), MB_YESNO | MYMBFLAGS); if (res == IDYES) { CheckOption(NOTIFY); } else { button->SetCheck(0); } } else { CheckOption(NOTIFY); } }
void COptionsDlg::OnProfCounts() { CButton *button = (CButton *) GetDlgItem(IDC_NOTIFY); assert(button != NULL); if (button->GetCheck() == 1) { CButton *text = (CButton *) GetDlgItem(IDC_TRACEDUMP_TEXT); assert(text != NULL); CButton *binary = (CButton *) GetDlgItem(IDC_TRACEDUMP_BINARY); assert(binary != NULL); if (text->GetCheck() == 0 && binary->GetCheck() == 0) { ::MessageBox(NULL, _T("Count profiling results are only visible in a trace dump.\n") _T("Don't forget to select either a text or binary trace dump."), _T("Reminder"), MB_OK | MYMBFLAGS); } } CheckOption(PROF_COUNTS); }
void COptionsDlg::OnTraceDumpBinary() { CButton *text = (CButton *) GetDlgItem(IDC_TRACEDUMP_TEXT); assert(text != NULL); CButton *binary = (CButton *) GetDlgItem(IDC_TRACEDUMP_BINARY); assert(binary != NULL); if (text->GetCheck() == 1 && binary->GetCheck() == 1) { ::MessageBox(NULL, _T("Trace dump must be either text or binary, not both"), _T("Mutually Exclusive"), MB_OK | MYMBFLAGS); binary->SetCheck(0); } else { CheckOption(TRACEDUMP_BINARY); } }
void COptionsDlg::OnInstrlibname() { UpdateData(TRUE); // TRUE means read from controls if (CheckLibraryExists(m_InstrLibName.GetBuffer(0), TRUE)) CheckOption(INSTRLIBNAME); else { CButton *button = (CButton *) GetDlgItem(IDC_INSTRLIBNAME); button->SetCheck(0); } }
void MainFrame::SetSystemTrayIcon(const wxString& icon, const wxString& tooltip) { if(CheckOption(wxT("UD_MINIMIZE_TO_SYSTEM_TRAY"))){ wxIcon i = wxIcon(icon,wxBITMAP_TYPE_ICO_RESOURCE,g_iconSize,g_iconSize); if(!m_systemTrayIcon->SetIcon(i,tooltip)){ etrace("system tray icon setup failed"); wxSetEnv(wxT("UD_MINIMIZE_TO_SYSTEM_TRAY"),wxT("0")); } } }
void MainFrame::OnMove(wxMoveEvent& event) { if(!IsMaximized() && !IsIconized()){ GetPosition(&m_x,&m_y); GetSize(&m_width,&m_height); } // hide window on minimization if system tray icon is turned on if(CheckOption(wxT("UD_MINIMIZE_TO_SYSTEM_TRAY")) && IsIconized()) Hide(); event.Skip(); }
void MainFrame::SetWindowTitle(wxCommandEvent& event) { if(event.GetString().IsEmpty()){ if(CheckOption(wxT("UD_DRY_RUN"))){ SetTitle(*m_title + wxT(" (Dry Run)")); } else { SetTitle(*m_title); } } else { SetTitle(event.GetString()); } }
void COptionsDlg::OnLoggingButton() { UpdateData(TRUE); // get values from controls int level = _ttoi(m_LogLevel); if (level < 0) level = 0; if (level > 4) level = 4; int mask; int res = _stscanf(m_LogMask, _T("%X"), &mask); if (res <= 0 || res == EOF) mask = 0; CLoggingDlg dlg(level, mask); res = dlg.DoModal(); if (res == IDCANCEL) return; m_LogLevel.Format(_T("%d"), dlg.GetLevel()); m_LogMask.Format(_T("0x%04X"), dlg.GetMask()); UpdateData(FALSE); // write to controls #if 1 UpdateValue(LOGLEVEL); UpdateValue(LOGMASK); #else // FIXME: change in place...for now we just remove and re-add CButton *button = (CButton *) GetDlgItem(checkboxes[LOGLEVEL]); assert(button != NULL); if (button->GetCheck() > 0) { RemoveOption(LOGLEVEL); CheckOption(LOGLEVEL); } button = (CButton *) GetDlgItem(checkboxes[LOGMASK]); assert(button != NULL); if (button->GetCheck() > 0) { RemoveOption(LOGMASK); CheckOption(LOGMASK); } #endif }
void MainFrame::AdjustSystemTrayIcon(wxCommandEvent& WXUNUSED(event)) { if(CheckOption(wxT("UD_MINIMIZE_TO_SYSTEM_TRAY"))){ if(!m_systemTrayIcon->IsIconInstalled()){ wxString icon(wxT("tray")); if(m_busy){ if(m_paused) icon = wxT("tray_paused"); else icon = wxT("tray_running"); } SetSystemTrayIcon(icon,wxT("UltraDefrag")); if(m_systemTrayIcon->IsIconInstalled()){ if(IsIconized()) Hide(); } } } else { if(m_systemTrayIcon->IsIconInstalled()){ m_systemTrayIcon->RemoveIcon(); Show(); } } }
void COptionsDlg::OnBrowseInstrlibname() { CFileDialog fileDlg(TRUE, _T(".dll"), NULL, // hide the "open as read-only" checkbox OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, szFilter); int res = fileDlg.DoModal(); if (res == IDCANCEL) return; CButton *button = (CButton *) GetDlgItem(checkboxes[INSTRLIBNAME]); assert(button != NULL); if (button->GetCheck() > 0 && _tcscmp(m_InstrLibName, fileDlg.GetPathName()) != 0) { m_InstrLibName = fileDlg.GetPathName(); UpdateData(FALSE); // FALSE means set controls RemoveOption(INSTRLIBNAME); CheckOption(INSTRLIBNAME); } else { m_InstrLibName = fileDlg.GetPathName(); UpdateData(FALSE); // FALSE means set controls } }
//=========================================================================== // main //=========================================================================== int main(int argc, char **argv) { int i; PrintBanner(); myargc = argc; myargv = argv; if(CheckOption("-f")) fullImport = true; if(argc == 1) { PrintUsage(); return 0; } InitData(); // Go through each command line option and process them. for(i = 1; i < argc; i++) { if(argv[i][0] == '-') // This is an option. { if(!stricmp(argv[i], "-i")) // Import (decompile). { if(i + 2 >= argc) { printf("Too few parameters for import.\n"); return 1; } Import(argv[i + 1], argv[i + 2]); i += 2; } continue; } // Try to open this TX source and parse it. Compile(argv[i]); } WriteLumps(); CloseData(); return 0; }
int main(int argc, char **argv) { // Look for help for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], "-help")) { ShowUsage(); } if (!strcmp(argv[i], "-svdTest")) { R2Image *image = new R2Image(); image->svdTest(); return 0; } } // Read input and output image filenames if (argc < 3) ShowUsage(); argv++, argc--; // First argument is program name char *input_image_name = *argv; argv++, argc--; char *output_image_name = *argv; argv++, argc--; // Allocate image R2Image *image = new R2Image(); if (!image) { fprintf(stderr, "Unable to allocate image\n"); exit(-1); } // Read input image if (!image->Read(input_image_name)) { fprintf(stderr, "Unable to read image from %s\n", input_image_name); exit(-1); } // Initialize sampling method int sampling_method = R2_IMAGE_POINT_SAMPLING; // Parse arguments and perform operations while (argc > 0) { if (!strcmp(*argv, "-brightness")) { CheckOption(*argv, argc, 2); double factor = atof(argv[1]); argv += 2, argc -=2; image->Brighten(factor); } else if (!strcmp(*argv, "-sobelX")) { argv++, argc--; image->SobelX(); } else if (!strcmp(*argv, "-sobelY")) { argv++, argc--; image->SobelY(); } else if (!strcmp(*argv, "-log")) { argv++, argc--; image->LoG(); } else if (!strcmp(*argv, "-saturation")) { CheckOption(*argv, argc, 2); double factor = atof(argv[1]); argv += 2, argc -= 2; image->ChangeSaturation(factor); } else if (!strcmp(*argv, "-harris")) { CheckOption(*argv, argc, 2); double sigma = atof(argv[1]); argv += 2, argc -= 2; image->Harris(sigma); } else if (!strcmp(*argv, "-blur")) { CheckOption(*argv, argc, 2); double sigma = atof(argv[1]); argv += 2, argc -= 2; image->Blur(sigma); } else if (!strcmp(*argv, "-sharpen")) { argv++, argc--; image->Sharpen(); } else if (!strcmp(*argv, "-matchTranslation")) { CheckOption(*argv, argc, 2); R2Image *other_image = new R2Image(argv[1]); argv += 2, argc -= 2; image->blendOtherImageTranslated(other_image); delete other_image; } else if (!strcmp(*argv, "-matchHomography")) { CheckOption(*argv, argc, 2); R2Image *other_image = new R2Image(argv[1]); argv += 2, argc -= 2; image->blendOtherImageHomography(other_image); delete other_image; } else { // Unrecognized program argument fprintf(stderr, "image: invalid option: %s\n", *argv); ShowUsage(); } } // Write output image if (!image->Write(output_image_name)) { fprintf(stderr, "Unable to read image from %s\n", output_image_name); exit(-1); } // Delete image delete image; // Return success return EXIT_SUCCESS; }
void COptionsDlg::OnNoasynch() { CheckOption(NOASYNCH); }
void COptionsDlg::OnTraceDumpOrigins() { CheckOption(TRACEDUMP_ORIGINS); }
void COptionsDlg::OnNullcalls() { CheckOption(NULLCALLS); }
void COptionsDlg::OnNolink() { CheckOption(NOLINK); }
void COptionsDlg::OnProfPcs() { CheckOption(PROF_PCS); }
void COptionsDlg::OnStats() { CheckOption(STATS); }
void COptionsDlg::OnLoglevel() { CheckOption(LOGLEVEL); }
void COptionsDlg::OnLogmask() { CheckOption(LOGMASK); }
void COptionsDlg::OnCacheTraceMax() { CheckOption(CACHE_TRACE_MAX); }
void COptionsDlg::OnCacheBBMax() { CheckOption(CACHE_BB_MAX); }
/* * Validate options against a white list. Also check the config_file is * inside the config_dir. The white list is defined in validate.c * Returns true on success */ static BOOL ValidateOptions (HANDLE pipe, const WCHAR *workdir, const WCHAR *options) { WCHAR **argv; int argc; WCHAR buf[256]; BOOL ret = FALSE; int i; const WCHAR *msg1 = L"You have specified a config file location (%s relative to %s)" " that requires admin approval. This error may be avoided" " by adding your account to the \"%s\" group"; const WCHAR *msg2 = L"You have specified an option (%s) that may be used" " only with admin approval. This error may be avoided" " by adding your account to the \"%s\" group"; argv = CommandLineToArgvW (options, &argc); if (!argv) { ReturnLastError (pipe, L"CommandLineToArgvW"); ReturnError (pipe, ERROR_STARTUP_DATA, L"Cannot validate options", 1, &exit_event); goto out; } /* Note: argv[0] is the first option */ if (argc < 1) /* no options */ { ret = TRUE; goto out; } /* * If only one argument, it is the config file */ if (argc == 1) { WCHAR *argv_tmp[2] = { L"--config", argv[0] }; if (!CheckOption (workdir, 2, argv_tmp, &settings)) { snwprintf (buf, _countof(buf), msg1, argv[0], workdir, settings.ovpn_admin_group); buf[_countof(buf) - 1] = L'\0'; ReturnError (pipe, ERROR_STARTUP_DATA, buf, 1, &exit_event); } goto out; } for (i = 0; i < argc; ++i) { if (!IsOption(argv[i])) continue; if (!CheckOption (workdir, argc-i, &argv[i], &settings)) { if (wcscmp(L"--config", argv[i]) == 0 && argc-i > 1) { snwprintf (buf, _countof(buf), msg1, argv[i+1], workdir, settings.ovpn_admin_group); buf[_countof(buf) - 1] = L'\0'; ReturnError (pipe, ERROR_STARTUP_DATA, buf, 1, &exit_event); } else { snwprintf (buf, _countof(buf), msg2, argv[i], settings.ovpn_admin_group); buf[_countof(buf) - 1] = L'\0'; ReturnError (pipe, ERROR_STARTUP_DATA, buf, 1, &exit_event); } goto out; } } /* all options passed */ ret = TRUE; out: if (argv) LocalFree (argv); return ret; }
int main(int argc, char **argv) { // Look for help for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], "-help")) { ShowUsage(); } } // Read input and output mesh filenames if (argc < 3) ShowUsage(); argv++, argc--; // First argument is program name char *input_mesh_name = *argv; argv++, argc--; char *output_mesh_name = *argv; argv++, argc--; // Allocate mesh R3Mesh *mesh = new R3Mesh(); if (!mesh) { fprintf(stderr, "Unable to allocate mesh\n"); exit(-1); } // Read input mesh if (!mesh->Read(input_mesh_name)) { fprintf(stderr, "Unable to read mesh from %s\n", input_mesh_name); exit(-1); } // Parse arguments and perform operations while (argc > 0) { if (!strcmp(*argv, "-twist")) { CheckOption(*argv, argc, 2); double angle = atof(argv[1]); argv += 2, argc -= 2; mesh->Twist(angle); } else if (!strcmp(*argv, "-taubin")) { CheckOption(*argv, argc, 4); double lambda = atof(argv[1]); double mu = atof(argv[2]); double iters = atoi(argv[3]); argv += 4, argc -= 4; mesh->Taubin(lambda, mu, iters); } else if (!strcmp(*argv, "-loop")) { CheckOption(*argv, argc, 1); argv += 1, argc -= 1; mesh->Loop(); } else { // Unrecognized program argument fprintf(stderr, "meshpro: invalid option: %s\n", *argv); ShowUsage(); } } // Write output mesh if (!mesh->Write(output_mesh_name)) { fprintf(stderr, "Unable to write mesh to %s\n", output_mesh_name); exit(-1); } // Delete mesh delete mesh; // Return success return EXIT_SUCCESS; }
int main(int argc, char **argv) { // Look for help for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], "-help")) { ShowUsage(); } } // Read input and output filenames if (argc < 3) ShowUsage(); argv++, argc--; // First argument is program name char *input_scene_name = *argv; argv++, argc--; char *output_image_name = *argv; argv++, argc--; // Initialize arguments to default values int width = 256; int height = 256; int max_depth = 0; int num_distributed_rays_per_intersection = 0; int num_primary_rays_per_pixel = 1; bool hard_shadow = false; // Parse arguments while (argc > 0) { if (!strcmp(*argv, "-width")) { CheckOption(*argv, argc, 2); width = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-height")) { CheckOption(*argv, argc, 2); height = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-max_depth")) { CheckOption(*argv, argc, 2); max_depth = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-antialias")) { CheckOption(*argv, argc, 2); num_primary_rays_per_pixel = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-distribute")) { CheckOption(*argv, argc, 2); num_distributed_rays_per_intersection = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-hard_shadow")) { hard_shadow = true; argv += 1, argc -= 1; } else { // Unrecognized program argument fprintf(stderr, "meshpro: invalid option: %s\n", *argv); ShowUsage(); } } // Read scene R3Scene *scene = ReadScene(input_scene_name, width, height); if (!scene) { fprintf(stderr, "Unable to read scene from %s\n", input_scene_name); exit(-1); } // Render image R2Image *image = RenderImage(scene, width, height, max_depth, num_primary_rays_per_pixel, num_distributed_rays_per_intersection, hard_shadow); if (!image) { fprintf(stderr, "Did not render image from scene\n"); exit(-1); } // Transfer the image to sRGB color space: for Windows + Linux and Mac OS X // 10.6+ (for earlier MAC OS X it will look slightly too bright, but not as // much as it would be too dark otherwise. This function also clamps the // image values; however, it does not scale the brightness and also does not // perform any more complicated tone mapping image->TosRGB(); // Write output image if (!image->Write(output_image_name)) { fprintf(stderr, "Did not write image to %s\n", output_image_name); exit(-1); } // Delete everything delete scene; delete image; // Return success return EXIT_SUCCESS; }
void COptionsDlg::OnHotThreshold() { CheckOption(HOT_THRESHOLD); }
int main(int argc, char **argv) { // Look for help for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], "-help")) { ShowUsage(); } } // Read input and output image filenames if (argc < 3) ShowUsage(); argv++, argc--; // First argument is program name char *input_image_name = *argv; argv++, argc--; char *output_image_name = *argv; argv++, argc--; // Allocate image R2Image *image = new R2Image(); if (!image) { fprintf(stderr, "Unable to allocate image\n"); exit(-1); } // Read input image if (!image->Read(input_image_name)) { fprintf(stderr, "Unable to read image from %s\n", input_image_name); exit(-1); } // Initialize sampling method int sampling_method = R2_IMAGE_POINT_SAMPLING; // Parse arguments and perform operations while (argc > 0) { if (!strcmp(*argv, "-bilateral")) { CheckOption(*argv, argc, 3); double sx = atof(argv[1]); double sy = atof(argv[2]); argv += 3, argc -= 3; image->BilateralFilter(sy, sx); } else if (!strcmp(*argv, "-blackandwhite")) { argv++, argc--; image->BlackAndWhite(); } else if (!strcmp(*argv, "-blur")) { CheckOption(*argv, argc, 2); double sigma = atof(argv[1]); argv += 2, argc -= 2; image->Blur(sigma); } else if (!strcmp(*argv, "-brightness")) { CheckOption(*argv, argc, 2); double factor = atof(argv[1]); argv += 2, argc -=2; image->Brighten(factor); } else if (!strcmp(*argv, "-composite")) { CheckOption(*argv, argc, 5); R2Image *top_image = new R2Image(argv[2]); R2Image *bottom_mask = new R2Image(argv[1]); R2Image *top_mask = new R2Image(argv[3]); int operation = atoi(argv[4]); argv += 5, argc -= 5; image->CopyChannel(*bottom_mask, R2_IMAGE_BLUE_CHANNEL, R2_IMAGE_ALPHA_CHANNEL); top_image->CopyChannel(*top_mask, R2_IMAGE_BLUE_CHANNEL, R2_IMAGE_ALPHA_CHANNEL); image->Composite(*top_image, operation); delete top_image; delete bottom_mask; delete top_mask; } else if (!strcmp(*argv, "-contrast")) { CheckOption(*argv, argc, 2); double factor = atof(argv[1]); argv += 2, argc -= 2; image->ChangeContrast(factor); } else if (!strcmp(*argv, "-crop")) { CheckOption(*argv, argc, 5); int x = atoi(argv[1]); int y = atoi(argv[2]); int w = atoi(argv[3]); int h = atoi(argv[4]); argv += 5, argc -= 5; image->Crop(x, y, w, h); } else if (!strcmp(*argv, "-dither")) { CheckOption(*argv, argc, 3); int dither_method = atoi(argv[1]); int nbits = atoi(argv[2]); argv += 3, argc -= 3; if (dither_method == 0) image->RandomDither(nbits); else if (dither_method == 1) image->OrderedDither(nbits); else if (dither_method == 2) image->FloydSteinbergDither(nbits); else { fprintf(stderr, "Invalid dither method: %d\n", dither_method); exit(-1); } } else if (!strcmp(*argv, "-edge")) { argv++, argc--; image->EdgeDetect(); } else if (!strcmp(*argv, "-extract")) { CheckOption(*argv, argc, 2); int channel = atoi(argv[1]); argv += 2, argc -= 2; image->ExtractChannel(channel); } else if (!strcmp(*argv, "-fun")) { image->Fun(sampling_method); argv++, argc--; } else if (!strcmp(*argv, "-gamma")) { CheckOption(*argv, argc, 2); double factor = atof(argv[1]); argv += 2, argc -= 2; image->ApplyGamma(factor); } else if (!strcmp(*argv, "-median")) { CheckOption(*argv, argc, 2); double sigma = atof(argv[1]); argv += 2, argc -= 2; image->MedianFilter(sigma); } else if (!strcmp(*argv, "-motionblur")) { CheckOption(*argv, argc, 1); int amount = atoi(argv[1]); argv += 2, argc -= 2; image->MotionBlur(amount); } else if (!strcmp(*argv, "-morph")) { int nsegments = 0; R2Segment *source_segments = NULL; R2Segment *target_segments = NULL; CheckOption(*argv, argc, 4); R2Image *target_image = new R2Image(argv[1]); ReadCorrespondences(argv[2], source_segments, target_segments, nsegments); double t = atof(argv[3]); argv += 4, argc -= 4; image->Morph(*target_image, source_segments, target_segments, nsegments, t, sampling_method); delete target_image; } else if (!strcmp(*argv, "-noise")) { CheckOption(*argv, argc, 2); double factor = atof(argv[1]); argv += 2, argc -= 2; image->AddNoise(factor); } else if (!strcmp(*argv, "-quantize")) { CheckOption(*argv, argc, 2); int nbits = atoi(argv[1]); argv += 2, argc -= 2; image->Quantize(nbits); } else if (!strcmp(*argv, "-rotate")) { CheckOption(*argv, argc, 2); double angle = atof(argv[1]); argv += 2, argc -= 2; image->Rotate(angle, sampling_method); } else if (!strcmp(*argv, "-sampling")) { CheckOption(*argv, argc, 2); sampling_method = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-saturation")) { CheckOption(*argv, argc, 2); double factor = atof(argv[1]); argv += 2, argc -= 2; image->ChangeSaturation(factor); } else if (!strcmp(*argv, "-scale")) { CheckOption(*argv, argc, 3); double sx = atof(argv[1]); double sy = atof(argv[2]); argv += 3, argc -= 3; image->Scale(sx, sy, sampling_method); } else if (!strcmp(*argv, "-sharpen")) { argv++, argc--; image->Sharpen(); } else { // Unrecognized program argument fprintf(stderr, "image: invalid option: %s\n", *argv); ShowUsage(); } } // Write output image if (!image->Write(output_image_name)) { fprintf(stderr, "Unable to write image to %s\n", output_image_name); exit(-1); } // Delete image delete image; // Return success return EXIT_SUCCESS; }