void LEList_c::RecalculateLEStatistics(long* numDispersed,long* numFloating,long* numRemoved,long* numOffMaps) { // code goes here, might want to calculate percent dissolved here long i; if (LEHandle) { for (i = 0 ; i < this->numOfLEs ; i++) { // code goes here, Alan occasionally seeing budget table floating < 0, maybe not released has z>0 or dispersed Le is getting beached? if( ((INDEXH(LEHandle, i).dispersionStatus == HAVE_DISPERSED || INDEXH(LEHandle, i).dispersionStatus == HAVE_DISPERSED_NAT) || INDEXH(LEHandle,i).z > 0) && !(INDEXH(LEHandle, i).statusCode==OILSTAT_EVAPORATED) && !(INDEXH(LEHandle, i).statusCode==OILSTAT_OFFMAPS) && !(INDEXH(LEHandle, i).statusCode==OILSTAT_NOTRELEASED) && !(INDEXH(LEHandle, i).statusCode==OILSTAT_ONLAND)) //if( ((INDEXH(LEHandle, i).dispersionStatus == HAVE_DISPERSED || INDEXH(LEHandle, i).dispersionStatus == HAVE_DISPERSED_NAT) || INDEXH(LEHandle,i).z > 0) && INDEXH(LEHandle, i).statusCode==OILSTAT_INWATER ) { (*numDispersed)++; (*numFloating)--; if ((*numFloating) < 0) { //printNote("Num floating < 0 in RecalculateLEStatistics"); } } if( (INDEXH(LEHandle, i).dispersionStatus == HAVE_REMOVED) && (INDEXH(LEHandle, i).statusCode==OILSTAT_OFFMAPS) ) { (*numRemoved)++; (*numOffMaps)--; if ((*numOffMaps) < 0) { printNote("Num off maps < 0 in RecalculateLEStatistics"); } } } } }
void CmdHelper::aided() { if(isSet("HelpHidden")) printNote(tr("Some help was hidden. To show full help use --help+ or -h+")); print(""); }
static void updatePortPixbuf(struct viewport *pp) { int mypage_i; /* no valid target size? */ if (pp->width <= 0 || pp->height <= 0) return; /* decide which page to render - if any */ mypage_i = pagenumForPort(pp); if (mypage_i < 0 || mypage_i >= doc_n_pages) { /* This port does not show anything right now, so clear its * content and quit. */ gtk_image_clear(GTK_IMAGE(pp->image)); return; } /* if note-control is active, print current page number if on * "main" frame. (don't do this on the beamer because it could be * locked.) * this allows you to attach any kind of other program or script * which can show notes for a specific slide. simply pipe the * output of pdfpres to your other tool. */ if (pp->offset == 0 && !pp->isBeamer) { printNote(doc_page + 1); if (runpref.do_notectrl) { printf("%d\n", doc_page + 1); fflush(stdout); } } /* get a pixbuf for this viewport. caching is behind * getRenderedPixbuf(). */ pp->pixbuf = getRenderedPixbuf(pp, mypage_i); /* display the current page. */ if (pp->pixbuf != NULL) gtk_image_set_from_pixbuf(GTK_IMAGE(pp->image), pp->pixbuf); else fprintf(stderr, "[Cache] Returned empty pixbuf." " You're doing something wrong.\n"); }
void cOutputCreatorTest::testDatabaseResults() throw() { printNote( "DATABASE RESULTS TESTS" ); try { unsigned long long ulSummaryId = m_poOC->uploadActionSummary(); QSqlQuery obSummaryQuery( QString( "SELECT nbPatients, nbMovements, cellName FROM cyclerconfigs WHERE cyclerconfigId=%1" ).arg( ulSummaryId ) ); testCase( "Number of cyclerconfigs records created", 1, obSummaryQuery.size() ); obSummaryQuery.first(); testCase( "Value of nbPatients column of the new record", 80, obSummaryQuery.value( 0 ).toInt() ); testCase( "Value of nbMovements column of the new record", 52, obSummaryQuery.value( 1 ).toInt() ); testCase( "Value of the cellName column of the new record", "LARA_TEST_CELL", obSummaryQuery.value( 2 ).toString().toStdString() ); m_poOC->uploadActionList(); QSqlQuery obListQuery( QString( "SELECT occurrencePattern FROM occurrences WHERE cyclerconfigId=%1" ).arg( ulSummaryId ) ); testCase( "Number of occurrences records created", 4, obListQuery.size() ); if( obListQuery.first() ) testCase( "Value of occurrencePattern column of occurrence record 1", "LARA_TEST_OK_ALWAYS", obListQuery.value( 0 ).toString().toStdString() ); if( obListQuery.next() ) testCase( "Value of occurrencePattern column of occurrence record 2", "LARA_TEST_OK_OK", obListQuery.value( 0 ).toString().toStdString() ); if( obListQuery.next() ) testCase( "Value of occurrencePattern column of occurrence record 3", "", obListQuery.value( 0 ).toString().toStdString() ); if( obListQuery.next() ) testCase( "Value of occurrencePattern column of occurrence record 4", "LARA_TEST_FAILED_FAILED", obListQuery.value( 0 ).toString().toStdString() ); } catch( cSevException &e ) { g_obLogger << e; m_uiFailedNum++; } }
static void showNotesFromFile(gchar *notefile) { gchar *msg = NULL; if (savedAsFilename != NULL) g_free(savedAsFilename); savedAsFilename = notefile; if (readNotes(notefile)) { msg = g_strdup_printf("Notes read from '%s'.", notefile); setStatusText_strdup(msg); g_free(msg); isSaved = TRUE; gtk_widget_set_sensitive(GTK_WIDGET(saveButton), FALSE); printNote(doc_page + 1); } }
void convertKernNoteToDM(HumdrumFile& infile, int line, int spine, int track) { const char* element = infile[line][spine]; double duration; Array<int> notes; if (strcmp(element, ".") == 0) { return; } if (infile[line].getExInterpNum(spine) != E_KERN_EXINT) { return; } if (infile[line].getBeat() == 1.0) { bar++; cout << "\n (bar " << bar << ") "; } duration = Convert::kernToDuration(infile[line][spine]); if (strchr(element, 'r') != NULL) { cout << " "; printRest(duration); return; } getNoteArray(notes, infile, line, spine); int notecount = notes.getSize(); cout << " ("; for (int i=0; i<notecount; i++) { printNote(notes[i]); if (i < notecount - 1) { cout << " "; } } cout << " "; printCMNDuration(duration); if (strchr(infile[line][spine], '[') != NULL) { cout << " begin-tie"; } else if (strchr(infile[line][spine], ']') != NULL) { cout << " end-tie"; } else if (strchr(infile[line][spine], '_') != NULL) { } cout << ")"; }
void cOutputCreatorTest::testCombilogResults() throw() { printNote( "COMBILOG RESULTS TESTS" ); try { QStringList slExpectedCombilogContent; m_poOC->addCombilogEntry( 3, "CombiLog Line 3", "#0000AA" ); slExpectedCombilogContent << "<div><pre class=\"combilogline\" style=\"background: #0000AA\">CombiLog Line 3</pre></div>"; m_poOC->addCombilogEntry( 1, "CombiLog Line 1", "#000088" ); slExpectedCombilogContent << "<div><pre class=\"combilogline\" style=\"background: #000088\">CombiLog Line 1</pre></div>"; m_poOC->addCombilogEntry( 2, "CombiLog Line 2", "#000099" ); slExpectedCombilogContent << "<div><pre class=\"combilogline\" style=\"background: #000099\">CombiLog Line 2</pre></div>"; m_poOC->addCombilogEntry( 5, "CombiLog Line 5", "#0000CC" ); slExpectedCombilogContent << "<div><pre class=\"combilogline\" style=\"background: #0000CC\">CombiLog Line 5</pre></div>"; m_poOC->addCombilogEntry( 6, "CombiLog Line 6", "#0000DD" ); slExpectedCombilogContent << "<div><pre class=\"combilogline\" style=\"background: #0000DD\">CombiLog Line 6</pre></div>"; m_poOC->addCombilogEntry( 4, "CombiLog Line 4", "#0000BB" ); slExpectedCombilogContent << "<div><pre class=\"combilogline\" style=\"background: #0000BB\">CombiLog Line 4</pre></div>"; QString qsCombilogFileName = g_poPrefs->outputDir() + "/" + "combilog.html"; QFile::remove( qsCombilogFileName ); m_poOC->generateCombilog(); checkFileContents( qsCombilogFileName.toStdString(), slExpectedCombilogContent ); } catch( cSevException &e ) { g_obLogger << e; m_uiFailedNum++; } }
OSErr GetScaleFactorFromUser(char *msg, double *scaleFactor) { long itemHit; char defaultAns[256]; char ans[256]; OSErr err = 0; sprintf(defaultAns,lfFix("%.1lf"),1.0); while(1) { // ask for a scale factor itemHit = REQUEST(msg,defaultAns,ans); if (itemHit == 2) // user cancelled { err = -1; break; } short numScanned = sscanf(ans,lfFix("%lf"),scaleFactor); if(! numScanned == 1) { printError("Error reading scale factor. Invalid entry."); err = -1; } if(*scaleFactor > 0 /*&& *scaleFactor <= maxScaleFactor*/) // valid entry, go on break; else // go back to dialog { //if (*scaleFactor > maxScaleFactor) sprintf(msg,lfFix("Maximum scale factor is %.1lf"),maxScaleFactor); if (*scaleFactor <= 0) sprintf(msg,"Scale factor must be positive"); printNote(msg); } } return err; }
short M28bClick (DialogPtr dialog, short itemNum, long lParam, VOIDPTR data) // old random diffusion dialog { char name [kMaxNameLen]; double uncertaintyFactor,vertStep; double U=0,W=0,botKZ=0; short typeOfInput; long menuID_menuItem; switch (itemNum) { case M28bOK: { PtCurMap *map = GetPtCurMap(); //PtCurMap *map = (PtCurMap*) (sharedRMover3D -> GetMoverMap()); // uncertaintyFactor enforce >= 1.0 uncertaintyFactor = EditText2Float(dialog, M28bUFACTOR); if(uncertaintyFactor <1.0) { printError("The uncertainty factor must be >= 1.0"); MySelectDialogItemText (dialog, M28bUFACTOR, 0, 255); break; } mygetitext(dialog, M28bNAME, name, kMaxNameLen - 1); // get the mover's nameStr sharedRMover3D -> SetClassName (name); sharedRMover3D -> SetActive (GetButton(dialog, M28bACTIVE)); sharedRMover3D -> bUseDepthDependentDiffusion = GetButton(dialog, M28bDEPTHDEPENDENT); typeOfInput = GetPopSelection(dialog, M28bINPUTTYPE); if (sharedRMover3D -> bUseDepthDependentDiffusion) { typeOfInput = 2; // why?? /*botKZ = EditText2Float(dialog,M28bBOTKZ); if (botKZ == 0) { printError("You must enter a value for the vertical diffusion coefficient on the bottom"); MySelectDialogItemText(dialog, M28bBOTKZ,0,255); break; }*/ //sharedRMover3D -> fVerticalBottomDiffusionCoefficient = EditText2Float(dialog, M28bBOTKZ); } sharedRMover3D -> fVerticalBottomDiffusionCoefficient = EditText2Float(dialog, M28bBOTKZ); if (typeOfInput==1) { //sharedRMover3D -> fDiffusionCoefficient = EditText2Float(dialog, M28DIFFUSION); sharedRMover3D -> fHorizontalDiffusionCoefficient = EditText2Float(dialog, M28bDIFFUSION); sharedRMover3D -> fUncertaintyFactor = uncertaintyFactor; sharedRMover3D -> fVerticalDiffusionCoefficient = EditText2Float(dialog, M28bVERTDIFFUSION); //sharedRMover3D -> fVerticalUncertaintyFactor = uncertaintyFactor; } else if (typeOfInput==2) { //sharedRMover3D -> fDiffusionCoefficient = EditText2Float(dialog, M28DIFFUSION); sharedRMover3D -> fHorizontalDiffusionCoefficient = EditText2Float(dialog, M28bDIFFUSION); sharedRMover3D -> fUncertaintyFactor = uncertaintyFactor; sharedRMover3D -> fVerticalDiffusionCoefficient = sharedRMover3D -> fHorizontalDiffusionCoefficient/6.88; //sharedRMover3D -> fVerticalUncertaintyFactor = uncertaintyFactor; } else if (typeOfInput==3) { U = EditText2Float(dialog,M28bCURRENTSPEED); if (U == 0) { printError("You must enter a value for the current velocity"); MySelectDialogItemText(dialog, M28bCURRENTSPEED,0,255); break; } W = EditText2Float(dialog,M28bWINDSPEED); if (W == 0) { printError("You must enter a value for the wind velocity"); MySelectDialogItemText(dialog, M28bWINDSPEED,0,255); break; } sharedRMover3D -> fHorizontalDiffusionCoefficient = (272.8*U + 21.1*W); //cm^2/s - Note the conversion from m^2/s is done by leaving out a 10^-4 factor sharedRMover3D -> fVerticalDiffusionCoefficient = (39.7*U + 3.1*W); //cm^2/s } vertStep = sqrt(6*(sharedRMover3D -> fVerticalDiffusionCoefficient/10000)*model->GetTimeStep()); // in meters // compare to mixed layer depth and warn if within a certain percentage - if (map && vertStep > map->fMixedLayerDepth) printNote("The combination of large vertical diffusion coefficient and choice of timestep will likely result in particles moving vertically on the order of the size of the mixed layer depth. They will be randomly placed in the mixed layer if reflection fails."); return M28bOK; } case M28bCANCEL: return M28bCANCEL; case M28bACTIVE: ToggleButton(dialog, M28bACTIVE); break; case M28bDEPTHDEPENDENT: ToggleButton(dialog, M28bDEPTHDEPENDENT); sharedRMover3D -> bUseDepthDependentDiffusion = GetButton(dialog,M28bDEPTHDEPENDENT); ShowHideRandomDialogItems(dialog); break; case M28bDIFFUSION: CheckNumberTextItem(dialog, itemNum, false); // don't allow decimals break; case M28bWINDSPEED: case M28bCURRENTSPEED: case M28bBOTKZ: CheckNumberTextItem(dialog, itemNum, true); // allow decimals break; case M28bUFACTOR: CheckNumberTextItem(dialog, itemNum, true); // allow decimals break; case M28bVERTDIFFUSION: CheckNumberTextItem(dialog, itemNum, true); // allow decimals break; case M28bVERTUFACTOR: CheckNumberTextItem(dialog, itemNum, true); // allow decimals break; case M28bINPUTTYPE: PopClick(dialog, itemNum, &menuID_menuItem); ShowHideRandomDialogItems(dialog); if (GetPopSelection(dialog, M28bINPUTTYPE)==3) MySelectDialogItemText(dialog, M28bCURRENTSPEED,0,255); else MySelectDialogItemText(dialog, M28bDIFFUSION,0,255); break; } return 0; }
void cActionDefTest::testPatterns() throw() { printNote( "PATTERN TESTS" ); try { cPattern *poPattern; poPattern = new cPattern(); testCase( "Pattern empty constructor Name", "", poPattern->name().toStdString() ); testCase( "Pattern empty constructor Pattern", "", poPattern->pattern().toStdString() ); testCase( "Pattern empty constructor Captures List empty", true, poPattern->captures().empty() ); delete poPattern; poPattern = new cPattern( NULL ); testCase( "Pattern NULL DOM Element Name", "", poPattern->name().toStdString() ); testCase( "Pattern NULL DOM Element Pattern", "", poPattern->pattern().toStdString() ); testCase( "Pattern NULL DOM Element Captures List empty", true, poPattern->captures().empty() ); delete poPattern; QDomDocument obDomDoc( "ActionTest" ); QDomElement obDomElem = obDomDoc.createElement( "pattern" ); obDomElem.setAttribute( "name", "GRENADE_INSTRUCTIONS" ); obDomElem.setAttribute( "regexp", "([\\d]*)[\\D]*([\\d]*)[\\D]*([\\d]*)" ); QDomElement obCap1 = obDomDoc.createElement( "captured_attrib" ); obCap1.setAttribute( "name", "NOT_COUNT" ); QDomElement obCap2 = obDomDoc.createElement( "captured_attrib" ); obCap2.setAttribute( "name", "NEITHER_COUNT" ); QDomElement obCap3 = obDomDoc.createElement( "captured_attrib" ); obCap3.setAttribute( "name", "EXCEPT_COUNT" ); obDomElem.appendChild( obCap1 ); obDomElem.appendChild( obCap2 ); obDomElem.appendChild( obCap3 ); poPattern = new cPattern( &obDomElem ); testCase( "Pattern Correct DOM Element Name", "GRENADE_INSTRUCTIONS", poPattern->name().toStdString() ); testCase( "Pattern Correct DOM Element Pattern", "([\\d]*)[\\D]*([\\d]*)[\\D]*([\\d]*)", poPattern->pattern().toStdString() ); testCase( "Pattern Correct DOM Element Captures List size", 3, poPattern->captures().size() ); QStringList slNumbers = poPattern->capturedTexts( "4 shalt thou not count, neither count thou 2, excepting that thou then proceed to 3." ); testCase( "Pattern Correct DOM Element Captured Text List size", 4, slNumbers.size() ); testCase( "Pattern Correct DOM Element Captured Attrib 1 Name", "NOT_COUNT", poPattern->captures().at( 0 ).toStdString() ); testCase( "Pattern Correct DOM Element Captured Attrib 1 Text", "4", slNumbers.at( 1 ).toStdString() ); testCase( "Pattern Correct DOM Element Captured Attrib 2 Name", "NEITHER_COUNT", poPattern->captures().at( 1 ).toStdString() ); testCase( "Pattern Correct DOM Element Captured Attrib 2 Text", "2", slNumbers.at( 2 ).toStdString() ); testCase( "Pattern Correct DOM Element Captured Attrib 3 Name", "EXCEPT_COUNT", poPattern->captures().at( 2 ).toStdString() ); testCase( "Pattern Correct DOM Element Captured Attrib 3 Text", "3", slNumbers.at( 3 ).toStdString() ); delete poPattern; } catch( cSevException &e ) { g_obLogger << e; m_uiFailedNum++; } }
void cOutputCreatorTest::testTextFileResults() throw() { printNote( "TEXT FILE RESULTS TESTS" ); try { m_poOC->fileId( "test_input.log.1" ); m_poOC->fileId( "test_input.log.2" ); QStringList slExpectedActionListContent; QStringList slExpectedActionSummaryContent; cAction::tsTimeStamp suTimeStamp; suTimeStamp.uiYear = 2000; suTimeStamp.uiMonth = 1; suTimeStamp.uiDay = 12; suTimeStamp.uiHour = 13; suTimeStamp.uiMinute = 42; suTimeStamp.uiSecond = 20; suTimeStamp.uiMSecond = 476; cAction *poAction = new cAction( "TEST_ACTION_1", "2000-01-12 13:42:20.476", &suTimeStamp, 0, 38, cActionResult::OK, cActionUpload::ALWAYS ); poAction->addAttribute( "occurrencePattern", "LARA_TEST_OK_ALWAYS" ); m_poOC->addAction( poAction ); slExpectedActionListContent << "2000-01-12 13:42:20.476 TEST_ACTION_1 OK occurrencePattern=\"LARA_TEST_OK_ALWAYS\" test_input.log.1:38"; delete poAction; suTimeStamp.uiHour = 14; poAction = new cAction( "TEST_ACTION_2", "2000-01-12 14:42:20.476", &suTimeStamp, 0, 39, cActionResult::OK, cActionUpload::OK ); poAction->addAttribute( "occurrencePattern", "LARA_TEST_OK_OK" ); m_poOC->addAction( poAction ); slExpectedActionListContent << "2000-01-12 14:42:20.476 TEST_ACTION_2 OK occurrencePattern=\"LARA_TEST_OK_OK\" test_input.log.1:39"; delete poAction; suTimeStamp.uiHour = 15; poAction = new cAction( "TEST_ACTION_3", "2000-01-12 15:42:20.476", &suTimeStamp, 0, 40, cActionResult::OK, cActionUpload::FAILED ); poAction->addAttribute( "occurrencePattern", "LARA_TEST_OK_FAILED" ); m_poOC->addAction( poAction ); slExpectedActionListContent << "2000-01-12 15:42:20.476 TEST_ACTION_3 OK occurrencePattern=\"LARA_TEST_OK_FAILED\" test_input.log.1:40"; delete poAction; suTimeStamp.uiHour = 16; poAction = new cAction( "TEST_ACTION_4", "2000-01-12 16:42:20.476", &suTimeStamp, 0, 41, cActionResult::OK, cActionUpload::NEVER ); m_poOC->addAction( poAction ); slExpectedActionListContent << "2000-01-12 16:42:20.476 TEST_ACTION_4 OK test_input.log.1:41"; delete poAction; suTimeStamp.uiHour = 17; poAction = new cAction( "TEST_ACTION_5", "2000-01-12 17:42:20.476", &suTimeStamp, 1, 38, cActionResult::FAILED, cActionUpload::ALWAYS ); m_poOC->addAction( poAction ); slExpectedActionListContent << "2000-01-12 17:42:20.476 TEST_ACTION_5 FAILED test_input.log.2:38"; delete poAction; suTimeStamp.uiHour = 18; poAction = new cAction( "TEST_ACTION_6", "2000-01-12 18:42:20.476", &suTimeStamp, 1, 39, cActionResult::FAILED, cActionUpload::OK ); poAction->addAttribute( "occurrencePattern", "LARA_TEST_FAILED_OK" ); m_poOC->addAction( poAction ); slExpectedActionListContent << "2000-01-12 18:42:20.476 TEST_ACTION_6 FAILED occurrencePattern=\"LARA_TEST_FAILED_OK\" test_input.log.2:39"; delete poAction; suTimeStamp.uiHour = 19; poAction = new cAction( "TEST_ACTION_7", "2000-01-12 19:42:20.476", &suTimeStamp, 1, 40, cActionResult::FAILED, cActionUpload::FAILED ); poAction->addAttribute( "occurrencePattern", "LARA_TEST_FAILED_FAILED" ); m_poOC->addAction( poAction ); slExpectedActionListContent << "2000-01-12 19:42:20.476 TEST_ACTION_7 FAILED occurrencePattern=\"LARA_TEST_FAILED_FAILED\" test_input.log.2:40"; delete poAction; suTimeStamp.uiHour = 20; poAction = new cAction( "TEST_ACTION_8", "2000-01-12 20:42:20.476", &suTimeStamp, 1, 41, cActionResult::FAILED, cActionUpload::NEVER ); m_poOC->addAction( poAction ); slExpectedActionListContent << "2000-01-12 20:42:20.476 TEST_ACTION_8 FAILED test_input.log.2:41"; delete poAction; m_poOC->addCountAction( "nbPatients", 42, 38 ); slExpectedActionSummaryContent << "nbPatients OK: 42 FAILED: 38 TOTAL: 80"; m_poOC->addCountAction( "nbMovements", 14, 8 ); m_poOC->addCountAction( "nbMovements", 10, 20 ); slExpectedActionSummaryContent << "nbMovements OK: 24 FAILED: 28 TOTAL: 52"; m_poOC->addAttribute( "cellName", "LARA_TEST_CELL" ); slExpectedActionSummaryContent << "cellName: LARA_TEST_CELL"; QString qsActionListFileName = g_poPrefs->outputDir() + "/" + "actionlist.txt"; QString qsActionSummaryFileName = g_poPrefs->outputDir() + "/" + "actionsummary.txt"; QFile::remove( qsActionListFileName ); QFile::remove( qsActionSummaryFileName ); m_poOC->generateActionList(); m_poOC->generateActionSummary(); checkFileContents( qsActionListFileName.toStdString(), slExpectedActionListContent ); checkFileContents( qsActionSummaryFileName.toStdString(), slExpectedActionSummaryContent ); } catch( cSevException &e ) { g_obLogger << e; m_uiFailedNum++; } }
OSErr AddMapsDialog2() { char path[256], nameStr [256], shortFileName[256], tempStr[256]; OSErr err = noErr; long n; Point where = CenteredDialogUpLeft(M38b); TVectorMap *vMap; TOSSMMap *oMap; Map3D *gMap; GridMap_c *gridMap = 0; OSType typeList[] = { 'NULL', 'NULL', 'NULL', 'NULL' }; MySFReply reply; WorldRect theRect = emptyWorldRect; short gridType; Boolean isESI = false; float arrowDepth = 0; #if TARGET_API_MAC_CARBON mysfpgetfile(&where, "", -1, typeList, (MyDlgHookUPP)0, &reply, M38b, MakeModalFilterUPP(STDFilter)); if (!reply.good) return USERCANCEL; strcpy(path, reply.fullPath); strcpy(tempStr,path); SplitPathFile(tempStr,shortFileName); #else sfpgetfile(&where, "", (FileFilterUPP)0, -1, typeList, (DlgHookUPP)0, &reply, M38b, (ModalFilterUPP)MakeUPP((ProcPtr)STDFilter, uppModalFilterProcInfo)); if (!reply.good) return USERCANCEL; my_p2cstr(reply.fName); #ifdef MAC GetFullPath(reply.vRefNum, 0, (char *)reply.fName, path); strcpy(shortFileName,(char*) reply.fName); #else strcpy(path, reply.fName); strcpy(tempStr,path); SplitPathFile(tempStr,shortFileName); #endif #endif if (IsVectorMap (path, &isESI)) { if (isESI) {printNote("File is ESI segments not map polygons");err=-1; return err;} strcpy (nameStr, "Vector Map: "); strcat (nameStr, shortFileName); vMap = (TVectorMap*) new TVectorMap (nameStr, theRect); if (!vMap) { TechError("AddMapsDialog()", "new TVectorMap()", 0); return -1; } if (err = vMap -> InitMap(path)) { delete vMap; return err; } if (err = model->AddMap(vMap, 0)) { vMap -> Dispose (); delete vMap; err = -1; } } else if (IsGridMap (path)) { strcpy (nameStr, "Grid Map: "); strcat (nameStr, shortFileName); oMap = new TOSSMMap(nameStr, voidWorldRect); if (!oMap) { TechError("AddMapsDialog()", "new TOSSMMap()", 0); return -1; } if (err = ((TOSSMMap*) oMap) -> InitMap(path)) { delete oMap; return err; } if (err = model->AddMap(oMap, 0)) { oMap -> Dispose (); delete oMap; err = -1; } } else if (IsPtCurFile (path)) { TMap *newMap = 0; TCurrentMover *newMover = CreateAndInitCurrentsMover (model->uMap,false,path,"ptcurfile",&newMap); // already have path if (newMover) { PtCurMover *ptCurMover = dynamic_cast<PtCurMover*>(newMover); err = ptCurMover -> SettingsDialog(); if(err) { newMover->Dispose(); delete newMover; newMover = 0; if (newMap) {newMap->Dispose(); delete newMap; newMap = 0;} } if(newMover && !err) { Boolean timeFileChanged = false; if (!newMap) { err = AddMoverToMap (model->uMap, timeFileChanged, newMover); } else { err = model -> AddMap(newMap, 0); if (!err) err = AddMoverToMap(newMap, timeFileChanged, newMover); //if(!err) err = ((PtCurMap*)newMap)->MakeBitmaps(); if (!err) newMover->SetMoverMap(newMap); if (model->ThereIsA3DMover(&arrowDepth)) InitAnalysisMenu(); // want to have it come and go? else { newMap->Dispose(); delete newMap; newMap =0; newMover->Dispose(); delete newMover; newMover = 0; return -1; } } } } } else if (IsNetCDFFile (path, &gridType)) { TMap *newMap = 0; char s[256],fileName[256], outPath[256]; WorldRect bounds = theWorld; strcpy(s,path); SplitPathFile (s, fileName); strcat (nameStr, fileName); gMap = CreateAndInitMap3D (path,bounds); // need to fix bounds afterwards if (gMap && gridType!=REGULAR && gridType!=REGULAR_SWAFS) { FLOATH depthPtsH = 0; WORLDPOINTFH vertexPtsH=0; long numRows=0, numCols=0, numNodes=0, numTri=0, numBoundaryPts=0; char errmsg[256]; gridMap = new GridMap_c(); #if TARGET_API_MAC_CARBON err = ConvertTraditionalPathToUnixPath((const char *) path, outPath, kMaxNameLen) ; //if (!err) strcpy(path,outPath); #else strcpy(outPath,path); #endif if (gridType == CURVILINEAR) { DOUBLEH maskH = 0; //err = gMap->GetPointsAndMask(path,&maskH,&vertexPtsH,&depthPtsH,&numRows, &numCols); //Text read //if (!err) err = gMap->SetUpCurvilinearGrid(maskH,numRows,numCols,vertexPtsH,depthPtsH,errmsg); //Reorder points err = gridMap->GetPointsAndMask(outPath,&maskH,&vertexPtsH,&depthPtsH,&numRows, &numCols); //Text read if (!err) err = gridMap->SetUpCurvilinearGrid(maskH,numRows,numCols,vertexPtsH,depthPtsH,errmsg); //Reorder points if(maskH) {DisposeHandle((Handle)maskH); maskH = 0;} } else if (gridType == TRIANGULAR) { // check if topology is included LONGPTR bndry_indices=0, bndry_nums=0, bndry_type=0, tri_verts=0, tri_neighbors=0; //err = gMap->GetPointsAndBoundary(path,&vertexPtsH,&depthPtsH, &numNodes, &bndry_indices, &bndry_nums, &bndry_type, &numBoundaryPts, &tri_verts, &tri_neighbors, &numTri); //Text read err = gridMap->GetPointsAndBoundary(outPath,&vertexPtsH,&depthPtsH, &numNodes, &bndry_indices, &bndry_nums, &bndry_type, &numBoundaryPts, &tri_verts, &tri_neighbors, &numTri); //Text read if (!err) { // separate points and boundary if (numTri == 0) //err = gMap->SetUpTriangleGrid(numNodes,numTri,vertexPtsH,depthPtsH, bndry_indices, bndry_nums, bndry_type, numBoundaryPts); //Reorder points err = gridMap->SetUpTriangleGrid(numNodes,numTri,vertexPtsH,depthPtsH, bndry_indices, bndry_nums, bndry_type, numBoundaryPts); //Reorder points else //err = gMap->SetUpTriangleGrid2(numNodes,numTri,vertexPtsH,depthPtsH, bndry_indices, bndry_nums, bndry_type, numBoundaryPts,tri_verts, tri_neighbors); //Reorder points err = gridMap->SetUpTriangleGrid2(numNodes,numTri,vertexPtsH,depthPtsH, bndry_indices, bndry_nums, bndry_type, numBoundaryPts,tri_verts, tri_neighbors); //Reorder points } if (bndry_indices) delete [] bndry_indices; if (bndry_nums) delete [] bndry_nums; if (bndry_type) delete [] bndry_type; if (tri_verts) delete [] tri_verts; if (tri_neighbors) delete [] tri_neighbors; } if(vertexPtsH) {DisposeHandle((Handle)vertexPtsH); vertexPtsH = 0;} if(depthPtsH) {DisposeHandle((Handle)depthPtsH); depthPtsH = 0;} if( !err) { gMap->SetBoundarySegs(gridMap->GetBoundarySegs()); gMap->SetWaterBoundaries(gridMap->GetWaterBoundaries()); gMap->SetBoundaryPoints(gridMap->GetBoundaryPoints()); gMap->SetGrid(gridMap->GetGrid()); gMap->SetMapBounds(gridMap->GetMapBounds()); err = gMap->MakeBitmaps(); } if (!err) err = model->AddMap(gMap, 0); if (err) { gMap -> Dispose (); delete gMap; err = -1; } } else { err = true; sprintf(tempStr,"File %s is a current file and should be input as a universal mover.",shortFileName); printNote(tempStr); } } else if (IsTriCurFile (path)) { TMap *newMap = 0; TCurrentMover *newMover = CreateAndInitCurrentsMover (model->uMap,false,path,"TriCurFile",&newMap); // already have path if (newMover) { TriCurMover *triCurMover = dynamic_cast<TriCurMover *>(newMover); err = triCurMover -> SettingsDialog(); if(err) { newMover->Dispose(); delete newMover; newMover = 0; if (newMap) {newMap->Dispose(); delete newMap; newMap = 0;} } if(newMover && !err) { Boolean timeFileChanged = false; if (!newMap) { err = AddMoverToMap (model->uMap, timeFileChanged, newMover); } else { err = model -> AddMap(newMap, 0); if (err) { newMap->Dispose(); delete newMap; newMap =0; newMover->Dispose(); delete newMover; newMover = 0; return -1; } err = AddMoverToMap(newMap, timeFileChanged, newMover); if(err) { newMap->Dispose(); delete newMap; newMap =0; newMover->Dispose(); delete newMover; newMover = 0; return -1; } /*err = ((PtCurMap*)newMap)->MakeBitmaps(); if(err) { newMap->Dispose(); delete newMap; newMap = 0; newMover->Dispose(); delete newMover; newMover = 0; return -1; }*/ newMover->SetMoverMap(newMap); if (model->ThereIsA3DMover(&arrowDepth)) InitAnalysisMenu(); // want to have it come and go? } } } else { err = true; sprintf(tempStr,"File %s is a current file and should be input as a universal mover.",shortFileName); printNote(tempStr); } } else if (IsCATS3DFile (path)) // for any CATS? { char s[256],fileName[256]; WorldRect bounds = theWorld; strcpy(s,path); SplitPathFile (s, fileName); strcat (nameStr, fileName); gMap = CreateAndInitMap3D (path,bounds); // need to fix bounds afterwards if (gMap) { gridMap = new GridMap_c(); if (!gridMap) {err = gMap->ReadCATSMap(path);/*err = -1;*/} else //err = gMap->ReadCATSMap(path); err = gridMap->ReadCATSMap(path); if(!err) { if (gridMap) { gMap->SetBoundarySegs(gridMap->GetBoundarySegs()); gMap->SetWaterBoundaries(gridMap->GetWaterBoundaries()); gMap->SetBoundaryPoints(gridMap->GetBoundaryPoints()); gMap->SetGrid(gridMap->GetGrid()); gMap->SetMapBounds(gridMap->GetMapBounds()); } err = gMap->MakeBitmaps(); } if (err = model->AddMap(gMap, 0)) { gMap -> Dispose (); delete gMap; err = -1; } } } else { WorldRect bounds = theWorld; gMap = CreateAndInitMap3D (path,bounds); // need to fix bounds afterwards if (gMap) { gridMap = new GridMap_c(); if (!gridMap) {err = gMap -> ReadTopology(path);/*err = -1;*/} else //err = gMap -> ReadTopology(path); err = gridMap -> ReadTopology(path); if(!err) { if (gridMap) { gMap->SetBoundarySegs(gridMap->GetBoundarySegs()); gMap->SetWaterBoundaries(gridMap->GetWaterBoundaries()); gMap->SetBoundaryPoints(gridMap->GetBoundaryPoints()); gMap->SetGrid(gridMap->GetGrid()); gMap->SetMapBounds(gridMap->GetMapBounds()); } err = gMap->MakeBitmaps(); } if (err = model->AddMap(gMap, 0)) { gMap -> Dispose (); delete gMap; err = -1; } } //err = true; if (err) {sprintf(tempStr,"File %s is not a recognizable map file.",shortFileName); printError(tempStr);} } if (!err) { model->NewDirtNotification(); } return err; }
static gboolean onCanvasDraw(GtkWidget *widget, cairo_t *cr, struct viewport *pp) { (void)widget; int mypage_i, myfitmode = -1; gdouble w = 0, h = 0; gchar *title = NULL; gdouble popwidth, popheight; gdouble tx, ty; gdouble screen_ratio, page_ratio, scale; PopplerPage *page = NULL; /* no valid target size? */ if (pp->width <= 0 || pp->height <= 0) return TRUE; /* decide which page to render - if any */ mypage_i = pagenumForPort(pp); if (mypage_i < 0 || mypage_i >= doc_n_pages) { /* We don't do any drawing and set the frame's title to "X". * Thus, we'll end up with an "empty" frame. */ if (pp->frame != NULL) gtk_frame_set_label(GTK_FRAME(pp->frame), "X"); return TRUE; } else { /* update frame title */ if (pp->frame != NULL) { title = g_strdup_printf("Slide %d / %d", mypage_i + 1, doc_n_pages); gtk_frame_set_label(GTK_FRAME(pp->frame), title); g_free(title); } } /* if note-control is active, print current page number if on * "main" frame. (don't do this on the beamer because it could be * locked.) * this allows you to attach any kind of other program or script * which can show notes for a specific slide. simply pipe the * output of pdfpres to your other tool. */ if (pp->offset == 0 && !pp->isBeamer) { printNote(doc_page + 1); if (runpref.do_notectrl) { printf("%d\n", doc_page + 1); fflush(stdout); } } /* Get the page and it's size from the document. */ page = poppler_document_get_page(doc, mypage_i); poppler_page_get_size(page, &popwidth, &popheight); /* Set page number */ if (pp->isBeamer) { gtk_label_set_text(GTK_LABEL(curPageLabel), g_strdup_printf("%s/%d", poppler_page_get_label(page), doc_last_page)); } /* Select fit mode. */ page_ratio = popwidth / popheight; screen_ratio = (double)pp->width / (double)pp->height; if (runpref.fit_mode == FIT_PAGE) { /* That's it: Compare screen and page ratio. This * will cover all 4 cases that could happen. */ if (screen_ratio > page_ratio) myfitmode = FIT_HEIGHT; else myfitmode = FIT_WIDTH; } else myfitmode = runpref.fit_mode; switch (myfitmode) { case FIT_HEIGHT: /* Fit size. */ h = pp->height; w = h * page_ratio; scale = h / popheight; /* Center page. */ tx = (pp->width - popwidth * scale) * 0.5; ty = 0; break; case FIT_WIDTH: w = pp->width; h = w / page_ratio; scale = w / popwidth; tx = 0; ty = (pp->height - popheight * scale) * 0.5; break; } /* A black background on beamer frame. Push and pop cairo contexts, so we have a * clean state afterwards. */ if (pp->isBeamer) { cairo_save(cr); cairo_set_source_rgb(cr, 0, 0, 0); cairo_rectangle(cr, 0, 0, pp->width, pp->height); cairo_fill(cr); cairo_restore(cr); /* center page on beamer */ cairo_translate(cr, tx, ty); } else { cairo_translate(cr, tx, 0); } /* Render the page */ cairo_scale(cr, scale, scale); poppler_page_render(page, cr); /* We no longer need that page. */ g_object_unref(G_OBJECT(page)); /* Nobody else draws to this widget. */ return TRUE; }
void cActionDefTest::testActionDefList() throw() { printNote( "ACTION DEFINITION LIST TESTS" ); try { cActionDefList obActionDefList( "test/test_actions.xml", "data/lara_actions.xsd" ); unsigned int uiPatternCount = 0; for( cActionDefList::tiPatternList itPattern = obActionDefList.patternBegin(); itPattern != obActionDefList.patternEnd(); itPattern++ ) { switch( ++uiPatternCount ) { case 1: testCase( "ActionDefList Pattern 1 Name", "PAT_HUNT_NAME", itPattern->name().toStdString() ); break; case 2: testCase( "ActionDefList Pattern 2 Name", "PAT_HOLY_HAND_GRENADE", itPattern->name().toStdString() ); break; case 3: testCase( "ActionDefList Pattern 3 Name", "PAT_WASTED_GRENADE", itPattern->name().toStdString() ); break; case 4: testCase( "ActionDefList Pattern 4 Name", "PAT_TARGET_SPOTTED", itPattern->name().toStdString() ); break; } } testCase( "ActionDefList Pattern count", 4, uiPatternCount ); unsigned int uiSingleLinerCount = 0; for( cActionDefList::tiSingleLinerList itSingleLiner = obActionDefList.singleLinerBegin(); itSingleLiner != obActionDefList.singleLinerEnd(); itSingleLiner++ ) { switch( ++uiSingleLinerCount ) { case 1: testCase( "ActionDefList SingleLiner 1 Name", "HOLY_HAND_GRENADE", itSingleLiner->name().toStdString() ); break; case 2: testCase( "ActionDefList SingleLiner 2 Name", "WASTED_GRENADE", itSingleLiner->name().toStdString() ); break; case 3: testCase( "ActionDefList SingleLiner 3 Name", "NEW_TARGET", itSingleLiner->name().toStdString() ); break; } } testCase( "ActionDefList SingleLiner count", 3, uiSingleLinerCount ); unsigned int uiCountActionCount = 0; for( cActionDefList::tiCountActionList itCountAction = obActionDefList.countActionBegin(); itCountAction != obActionDefList.countActionEnd(); itCountAction++ ) { switch( ++uiCountActionCount ) { case 1: testCase( "ActionDefList CountAction 1 Name", "nbManeuvers", itCountAction->name().toStdString() ); break; case 2: testCase( "ActionDefList CountAction 2 Name", "nbGrenades", itCountAction->name().toStdString() ); break; } } testCase( "ActionDefList Count Action count", 2, uiCountActionCount ); testCase( "ActionDefList Timestamp Regexp", "(\\d*)-(\\d*)-(\\d*) (\\d*):(\\d*):(\\d*)\\.(\\d*)", obActionDefList.timeStampRegExp().pattern().toStdString() ); testCase( "ActionDefList Valid TimestampPart", cTimeStampPart::DAY, obActionDefList.timeStampPart( 2 ) ); testCase( "ActionDefList Invalid Timestamp Part", cTimeStampPart::MIN, obActionDefList.timeStampPart( 42 ) ); cActionDefList obBadActionDefList( "test/bad_actions.xml", "data/lara_actions.xsd" ); testCase( "Bad ActionDefList Timestamp Regexp (XML validation ERROR above is EXPECTED)", "", obBadActionDefList.timeStampRegExp().pattern().toStdString() ); } catch( cSevException &e ) { g_obLogger << e; m_uiFailedNum++; } }
OSErr AddMapsDialog() { char path[256], nameStr [256], shortFileName[256], tempStr[256]; OSErr err = noErr; long n; Point where = CenteredDialogUpLeft(M38b); TVectorMap *vMap; TOSSMMap *oMap; OSType typeList[] = { 'NULL', 'NULL', 'NULL', 'NULL' }; MySFReply reply; WorldRect theRect = emptyWorldRect; short gridType; Boolean isESI = false; float arrowDepth = 0; #if TARGET_API_MAC_CARBON mysfpgetfile(&where, "", -1, typeList, (MyDlgHookUPP)0, &reply, M38b, MakeModalFilterUPP(STDFilter)); if (!reply.good) return USERCANCEL; strcpy(path, reply.fullPath); strcpy(tempStr,path); SplitPathFile(tempStr,shortFileName); #else sfpgetfile(&where, "", (FileFilterUPP)0, -1, typeList, (DlgHookUPP)0, &reply, M38b, (ModalFilterUPP)MakeUPP((ProcPtr)STDFilter, uppModalFilterProcInfo)); if (!reply.good) return USERCANCEL; my_p2cstr(reply.fName); #ifdef MAC GetFullPath(reply.vRefNum, 0, (char *)reply.fName, path); strcpy(shortFileName,(char*) reply.fName); #else strcpy(path, reply.fName); strcpy(tempStr,path); SplitPathFile(tempStr,shortFileName); #endif #endif if (IsVectorMap (path, &isESI)) { if (isESI) {printNote("File is ESI segments not map polygons");err=-1; return err;} strcpy (nameStr, "Vector Map: "); strcat (nameStr, shortFileName); vMap = (TVectorMap*) new TVectorMap (nameStr, theRect); if (!vMap) { TechError("AddMapsDialog()", "new TVectorMap()", 0); return -1; } if (err = vMap -> InitMap(path)) { delete vMap; return err; } if (err = model->AddMap(vMap, 0)) { vMap -> Dispose (); delete vMap; err = -1; } } else if (IsGridMap (path)) { strcpy (nameStr, "Grid Map: "); strcat (nameStr, shortFileName); oMap = new TOSSMMap(nameStr, voidWorldRect); if (!oMap) { TechError("AddMapsDialog()", "new TOSSMMap()", 0); return -1; } if (err = ((TOSSMMap*) oMap) -> InitMap(path)) { delete oMap; return err; } if (err = model->AddMap(oMap, 0)) { oMap -> Dispose (); delete oMap; err = -1; } } else if (IsPtCurFile (path)) { TMap *newMap = 0; TCurrentMover *newMover = CreateAndInitCurrentsMover (model->uMap,false,path,"ptcurfile",&newMap); // already have path if (newMover) { PtCurMover *ptCurMover = dynamic_cast<PtCurMover*>(newMover); err = ptCurMover -> SettingsDialog(); if(err) { newMover->Dispose(); delete newMover; newMover = 0; if (newMap) {newMap->Dispose(); delete newMap; newMap = 0;} } if(newMover && !err) { Boolean timeFileChanged = false; if (!newMap) { err = AddMoverToMap (model->uMap, timeFileChanged, newMover); } else { err = model -> AddMap(newMap, 0); if (!err) err = AddMoverToMap(newMap, timeFileChanged, newMover); //if(!err) err = ((PtCurMap*)newMap)->MakeBitmaps(); if (!err) newMover->SetMoverMap(newMap); if (model->ThereIsA3DMover(&arrowDepth)) InitAnalysisMenu(); // want to have it come and go? else { newMap->Dispose(); delete newMap; newMap =0; newMover->Dispose(); delete newMover; newMover = 0; return -1; } } } } } else if (IsNetCDFFile (path, &gridType)) { TMap *newMap = 0; TCurrentMover *newMover = CreateAndInitCurrentsMover (model->uMap,false,path,"NetCDFfile",&newMap); // already have path if (newMover && gridType!=REGULAR && gridType!=REGULAR_SWAFS) // should probably get rid of the SWAFS grid type and generalize a regular navy { NetCDFMover *netCDFMover = dynamic_cast<NetCDFMover *>(newMover); err = netCDFMover -> SettingsDialog(); if(err) { newMover->Dispose(); delete newMover; newMover = 0; if (newMap) {newMap->Dispose(); delete newMap; newMap = 0;} } if(newMover && !err) { Boolean timeFileChanged = false; if (!newMap) { err = AddMoverToMap (model->uMap, timeFileChanged, newMover); } else { err = model -> AddMap(newMap, 0); if (!err) err = AddMoverToMap(newMap, timeFileChanged, newMover); // if (!err) err = ((PtCurMap*)newMap)->MakeBitmaps(); if (!err) newMover->SetMoverMap(newMap); if (model->ThereIsA3DMover(&arrowDepth)) InitAnalysisMenu(); // want to have it come and go? else { newMap->Dispose(); delete newMap; newMap =0; newMover->Dispose(); delete newMover; newMover = 0; return -1; } } } } else { err = true; sprintf(tempStr,"File %s is a current file and should be input as a universal mover.",shortFileName); printNote(tempStr); } } else if (IsTriCurFile (path)) { TMap *newMap = 0; TCurrentMover *newMover = CreateAndInitCurrentsMover (model->uMap,false,path,"TriCurFile",&newMap); // already have path if (newMover) { TriCurMover *triCurMover = dynamic_cast<TriCurMover *>(newMover); err = triCurMover -> SettingsDialog(); if(err) { newMover->Dispose(); delete newMover; newMover = 0; if (newMap) {newMap->Dispose(); delete newMap; newMap = 0;} } if(newMover && !err) { Boolean timeFileChanged = false; if (!newMap) { err = AddMoverToMap (model->uMap, timeFileChanged, newMover); } else { err = model -> AddMap(newMap, 0); if (err) { newMap->Dispose(); delete newMap; newMap =0; newMover->Dispose(); delete newMover; newMover = 0; return -1; } err = AddMoverToMap(newMap, timeFileChanged, newMover); if(err) { newMap->Dispose(); delete newMap; newMap =0; newMover->Dispose(); delete newMover; newMover = 0; return -1; } /*err = ((PtCurMap*)newMap)->MakeBitmaps(); if(err) { newMap->Dispose(); delete newMap; newMap = 0; newMover->Dispose(); delete newMover; newMover = 0; return -1; }*/ newMover->SetMoverMap(newMap); if (model->ThereIsA3DMover(&arrowDepth)) InitAnalysisMenu(); // want to have it come and go? } } } else { err = true; sprintf(tempStr,"File %s is a current file and should be input as a universal mover.",shortFileName); printNote(tempStr); } } else if (IsCATS3DFile (path)) { TMap *newMap = 0; char s[256],fileName[256]; TCurrentMover *newMover = 0; Boolean timeFileChanged = false; strcpy(s,path); SplitPathFile (s, fileName); strcat (nameStr, fileName); newMover = CreateAndInitCurrentsMover (model->uMap,false,path,fileName,&newMap); // already have path if (newMover) { TCATSMover3D *catsMover3D = dynamic_cast<TCATSMover3D *>(newMover); err = CATSSettingsDialog (dynamic_cast<TCATSMover *>(newMover), model->uMap, &timeFileChanged); if(err) { newMover->Dispose(); delete newMover; newMover = 0; if (newMap) {newMap->Dispose(); delete newMap; newMap = 0;} } if(newMover && !err) { Boolean timeFileChanged = false; if (!newMap) { err = AddMoverToMap (model->uMap, timeFileChanged, newMover); } else { err = model -> AddMap(newMap, 0); if (err) { newMap->Dispose(); delete newMap; newMap =0; newMover->Dispose(); delete newMover; newMover = 0; return -1; } err = AddMoverToMap(newMap, timeFileChanged, newMover); if(err) { newMap->Dispose(); delete newMap; newMap =0; newMover->Dispose(); delete newMover; newMover = 0; return -1; } /*err = ((PtCurMap*)newMap)->MakeBitmaps(); if(err) { newMap->Dispose(); delete newMap; newMap = 0; newMover->Dispose(); delete newMover; newMover = 0; return -1; }*/ newMover->SetMoverMap(newMap); if (model->ThereIsA3DMover(&arrowDepth)) InitAnalysisMenu(); // want to have it come and go? } } } } else { err = true; sprintf(tempStr,"File %s is not a recognizable map file.",shortFileName); printError(tempStr); } if (!err) { model->NewDirtNotification(); } return err; }
OSErr NetCDFWindMoverCurv::TextRead(char *path, TMap **newMap, char *topFilePath) // don't want a map { // this code is for curvilinear grids OSErr err = 0; long i,j, numScanned, indexOfStart = 0; int status, ncid, latIndexid, lonIndexid, latid, lonid, recid, timeid, numdims; size_t latLength, lonLength, recs, t_len, t_len2; float timeVal; char recname[NC_MAX_NAME], *timeUnits=0, month[10]; char dimname[NC_MAX_NAME], s[256], topPath[256]; WORLDPOINTFH vertexPtsH=0; float *lat_vals=0,*lon_vals=0,yearShift=0.; static size_t timeIndex,ptIndex[2]={0,0}; static size_t pt_count[2]; Seconds startTime, startTime2; double timeConversion = 1.; char errmsg[256] = "",className[256]=""; char fileName[64],*modelTypeStr=0; Point where; OSType typeList[] = { 'NULL', 'NULL', 'NULL', 'NULL' }; MySFReply reply; Boolean bTopFile = false, fIsNavy = false; // for now keep code around but probably don't need Navy curvilinear wind //VelocityFH velocityH = 0; char outPath[256]; if (!path || !path[0]) return 0; strcpy(fPathName,path); strcpy(s,path); SplitPathFile (s, fileName); strcpy(fFileName, fileName); // maybe use a name from the file status = nc_open(path, NC_NOWRITE, &ncid); //if (status != NC_NOERR) {err = -1; goto done;} if (status != NC_NOERR) { #if TARGET_API_MAC_CARBON err = ConvertTraditionalPathToUnixPath((const char *) path, outPath, kMaxNameLen) ; status = nc_open(outPath, NC_NOWRITE, &ncid); #endif if (status != NC_NOERR) {err = -1; goto done;} } // check number of dimensions - 2D or 3D status = nc_inq_ndims(ncid, &numdims); if (status != NC_NOERR) {err = -1; goto done;} status = nc_inq_attlen(ncid,NC_GLOBAL,"generating_model",&t_len2); if (status != NC_NOERR) {fIsNavy = false; /*goto done;*/} else { fIsNavy = true; // may only need to see keyword is there, since already checked grid type modelTypeStr = new char[t_len2+1]; status = nc_get_att_text(ncid, NC_GLOBAL, "generating_model", modelTypeStr); if (status != NC_NOERR) {fIsNavy = false; goto done;} modelTypeStr[t_len2] = '\0'; strcpy(fFileName, modelTypeStr); } GetClassName(className); if (!strcmp("NetCDF Wind",className)) SetClassName(fFileName); //first check that name is now the default and not set by command file ("NetCDF Wind") //if (fIsNavy) { status = nc_inq_dimid(ncid, "time", &recid); //Navy //if (status != NC_NOERR) {err = -1; goto done;} if (status != NC_NOERR) { status = nc_inq_unlimdim(ncid, &recid); // issue of time not being unlimited dimension if (status != NC_NOERR) {err = -1; goto done;} } } /*else { status = nc_inq_unlimdim(ncid, &recid); // issue of time not being unlimited dimension if (status != NC_NOERR) {err = -1; goto done;} }*/ //if (fIsNavy) status = nc_inq_varid(ncid, "time", &timeid); if (status != NC_NOERR) { status = nc_inq_varid(ncid, "ProjectionHr", &timeid); if (status != NC_NOERR) {err = -1; goto done;} } // if (status != NC_NOERR) {/*err = -1; goto done;*/timeid=recid;} //if (!fIsNavy) //status = nc_inq_attlen(ncid, recid, "units", &t_len); // recid is the dimension id not the variable id //else // LAS has them in order, and time is unlimited, but variable/dimension names keep changing so leave this way for now status = nc_inq_attlen(ncid, timeid, "units", &t_len); if (status != NC_NOERR) { timeUnits = 0; // files should always have this info timeConversion = 3600.; // default is hours startTime2 = model->GetStartTime(); // default to model start time //err = -1; goto done; } else { DateTimeRec time; char unitStr[24], junk[10]; timeUnits = new char[t_len+1]; //if (!fIsNavy) //status = nc_get_att_text(ncid, recid, "units", timeUnits); // recid is the dimension id not the variable id //else status = nc_get_att_text(ncid, timeid, "units", timeUnits); if (status != NC_NOERR) {err = -1; goto done;} timeUnits[t_len] = '\0'; // moved this statement before StringSubstitute, JLM 5/2/10 StringSubstitute(timeUnits, ':', ' '); StringSubstitute(timeUnits, '-', ' '); StringSubstitute(timeUnits, 'T', ' '); StringSubstitute(timeUnits, 'Z', ' '); numScanned=sscanf(timeUnits, "%s %s %hd %hd %hd %hd %hd %hd", unitStr, junk, &time.year, &time.month, &time.day, &time.hour, &time.minute, &time.second) ; if (numScanned==5) {time.hour = 0; time.minute = 0; time.second = 0; } else if (numScanned==7) // has two extra time entries ?? time.second = 0; else if (numScanned<8) //else if (numScanned!=8) { //timeUnits = 0; // files should always have this info //timeConversion = 3600.; // default is hours //startTime2 = model->GetStartTime(); // default to model start time err = -1; TechError("NetCDFWindMoverCurv::TextRead()", "sscanf() == 8", 0); goto done; } else { // code goes here, trouble with the DAYS since 1900 format, since converts to seconds since 1904 if (time.year ==1900) {time.year += 40; time.day += 1; /*for the 1900 non-leap yr issue*/ yearShift = 40.;} DateToSeconds (&time, &startTime2); // code goes here, which start Time to use ?? if (!strcmpnocase(unitStr,"HOURS") || !strcmpnocase(unitStr,"HOUR")) timeConversion = 3600.; else if (!strcmpnocase(unitStr,"MINUTES") || !strcmpnocase(unitStr,"MINUTE")) timeConversion = 60.; else if (!strcmpnocase(unitStr,"SECONDS") || !strcmpnocase(unitStr,"SECOND")) timeConversion = 1.; else if (!strcmpnocase(unitStr,"DAYS") || !strcmpnocase(unitStr,"DAY")) timeConversion = 24.*3600.; } } if (fIsNavy) { status = nc_inq_dimid(ncid, "gridy", &latIndexid); //Navy if (status != NC_NOERR) {err = -1; goto done;} status = nc_inq_dimlen(ncid, latIndexid, &latLength); if (status != NC_NOERR) {err = -1; goto done;} status = nc_inq_dimid(ncid, "gridx", &lonIndexid); //Navy if (status != NC_NOERR) {err = -1; goto done;} status = nc_inq_dimlen(ncid, lonIndexid, &lonLength); if (status != NC_NOERR) {err = -1; goto done;} // option to use index values? status = nc_inq_varid(ncid, "grid_lat", &latid); if (status != NC_NOERR) {err = -1; goto done;} status = nc_inq_varid(ncid, "grid_lon", &lonid); if (status != NC_NOERR) {err = -1; goto done;} } else { for (i=0;i<numdims;i++) { if (i == recid) continue; status = nc_inq_dimname(ncid,i,dimname); if (status != NC_NOERR) {err = -1; goto done;} if (!strncmpnocase(dimname,"X",1) || !strncmpnocase(dimname,"LON",3) || !strncmpnocase(dimname,"nx",2)) { lonIndexid = i; } if (!strncmpnocase(dimname,"Y",1) || !strncmpnocase(dimname,"LAT",3) || !strncmpnocase(dimname,"ny",2)) { latIndexid = i; } } status = nc_inq_dimlen(ncid, latIndexid, &latLength); if (status != NC_NOERR) {err = -1; goto done;} status = nc_inq_dimlen(ncid, lonIndexid, &lonLength); if (status != NC_NOERR) {err = -1; goto done;} status = nc_inq_varid(ncid, "LATITUDE", &latid); if (status != NC_NOERR) { status = nc_inq_varid(ncid, "lat", &latid); if (status != NC_NOERR) { status = nc_inq_varid(ncid, "latitude", &latid); if (status != NC_NOERR) {err = -1; goto done;} } } status = nc_inq_varid(ncid, "LONGITUDE", &lonid); if (status != NC_NOERR) { status = nc_inq_varid(ncid, "lon", &lonid); if (status != NC_NOERR) { status = nc_inq_varid(ncid, "longitude", &lonid); if (status != NC_NOERR) {err = -1; goto done;} } } } pt_count[0] = latLength; pt_count[1] = lonLength; vertexPtsH = (WorldPointF**)_NewHandleClear(latLength*lonLength*sizeof(WorldPointF)); if (!vertexPtsH) {err = memFullErr; goto done;} lat_vals = new float[latLength*lonLength]; lon_vals = new float[latLength*lonLength]; if (!lat_vals || !lon_vals) {err = memFullErr; goto done;} status = nc_get_vara_float(ncid, latid, ptIndex, pt_count, lat_vals); if (status != NC_NOERR) {err = -1; goto done;} status = nc_get_vara_float(ncid, lonid, ptIndex, pt_count, lon_vals); if (status != NC_NOERR) {err = -1; goto done;} for (i=0;i<latLength;i++) { for (j=0;j<lonLength;j++) { //if (lat_vals[(latLength-i-1)*lonLength+j]==fill_value) // this would be an error //lat_vals[(latLength-i-1)*lonLength+j]=0.; //if (lon_vals[(latLength-i-1)*lonLength+j]==fill_value) //lon_vals[(latLength-i-1)*lonLength+j]=0.; INDEXH(vertexPtsH,i*lonLength+j).pLat = lat_vals[(latLength-i-1)*lonLength+j]; INDEXH(vertexPtsH,i*lonLength+j).pLong = lon_vals[(latLength-i-1)*lonLength+j]; } } fVertexPtsH = vertexPtsH; status = nc_inq_dim(ncid, recid, recname, &recs); if (status != NC_NOERR) {err = -1; goto done;} if (recs<=0) {strcpy(errmsg,"No times in file. Error opening NetCDF wind file"); err = -1; goto done;} fTimeHdl = (Seconds**)_NewHandleClear(recs*sizeof(Seconds)); if (!fTimeHdl) {err = memFullErr; goto done;} for (i=0;i<recs;i++) { Seconds newTime; // possible units are, HOURS, MINUTES, SECONDS,... timeIndex = i; //if (!fIsNavy) //status = nc_get_var1_float(ncid, recid, &timeIndex, &timeVal); // recid is the dimension id not the variable id //else status = nc_get_var1_float(ncid, timeid, &timeIndex, &timeVal); if (status != NC_NOERR) {err = -1; goto done;} newTime = RoundDateSeconds(round(startTime2+timeVal*timeConversion)); //INDEXH(fTimeHdl,i) = startTime2+(long)(timeVal*timeConversion -yearShift*3600.*24.*365.25); // which start time where? //if (i==0) startTime = startTime2+(long)(timeVal*timeConversion -yearShift*3600.*24.*365.25); INDEXH(fTimeHdl,i) = newTime-yearShift*3600.*24.*365.25; // which start time where? if (i==0) startTime = newTime-yearShift*3600.*24.*365.25; } if (model->GetStartTime() != startTime || model->GetModelTime()!=model->GetStartTime()) { if (true) // maybe use NOAA.ver here? { short buttonSelected; //buttonSelected = MULTICHOICEALERT(1688,"Do you want to reset the model start time to the first time in the file?",FALSE); if(!gCommandFileRun) // also may want to skip for location files... buttonSelected = MULTICHOICEALERT(1688,"Do you want to reset the model start time to the first time in the file?",FALSE); else buttonSelected = 1; // TAP user doesn't want to see any dialogs, always reset (or maybe never reset? or send message to errorlog?) switch(buttonSelected){ case 1: // reset model start time //bTopFile = true; model->SetModelTime(startTime); model->SetStartTime(startTime); model->NewDirtNotification(DIRTY_RUNBAR); // must reset the runbar break; case 3: // don't reset model start time //bTopFile = false; break; case 4: // cancel err=-1;// user cancel goto done; } } //model->SetModelTime(startTime); //model->SetStartTime(startTime); //model->NewDirtNotification(DIRTY_RUNBAR); // must reset the runbar } fNumRows = latLength; fNumCols = lonLength; status = nc_close(ncid); if (status != NC_NOERR) {err = -1; goto done;} //err = this -> SetInterval(errmsg); //if(err) goto done; // look for topology in the file // for now ask for an ascii file, output from Topology save option // need dialog to ask for file //if (fIsNavy) // for now don't allow for wind files {if (topFilePath[0]) {err = ReadTopology(topFilePath,newMap); goto done;}} if (!gCommandFileRun) { short buttonSelected; buttonSelected = MULTICHOICEALERT(1688,"Do you have an extended topology file to load?",FALSE); switch(buttonSelected){ case 1: // there is an extended top file bTopFile = true; break; case 3: // no extended top file bTopFile = false; break; case 4: // cancel err=-1;// stay at this dialog goto done; } } if(bTopFile) { #if TARGET_API_MAC_CARBON mysfpgetfile(&where, "", -1, typeList, (MyDlgHookUPP)0, &reply, M38c, MakeModalFilterUPP(STDFilter)); if (!reply.good)/* return USERCANCEL;*/ { /*if (recs>0) err = this -> ReadTimeData(indexOfStart,&velocityH,errmsg); else {strcpy(errmsg,"No times in file. Error opening NetCDF file"); err = -1;} if(err) goto done;*/ err = dynamic_cast<NetCDFWindMoverCurv *>(this)->ReorderPoints(newMap,errmsg); //err = ReorderPoints(fStartData.dataHdl,newMap,errmsg); // if u, v input separately only do this once? goto done; } else strcpy(topPath, reply.fullPath); #else where = CenteredDialogUpLeft(M38c); sfpgetfile(&where, "", (FileFilterUPP)0, -1, typeList, (DlgHookUPP)0, &reply, M38c, (ModalFilterUPP)MakeUPP((ProcPtr)STDFilter, uppModalFilterProcInfo)); if (!reply.good) { /*if (recs>0) err = this -> ReadTimeData(indexOfStart,&velocityH,errmsg); else {strcpy(errmsg,"No times in file. Error opening NetCDF file"); err = -1;} if(err) goto done;*/ err = dynamic_cast<NetCDFWindMoverCurv *>(this)->ReorderPoints(newMap,errmsg); //err = ReorderPoints(fStartData.dataHdl,newMap,errmsg); /*if (err)*/ goto done; } my_p2cstr(reply.fName); #ifdef MAC GetFullPath(reply.vRefNum, 0, (char *)reply.fName, topPath); #else strcpy(topPath, reply.fName); #endif #endif strcpy (s, topPath); err = ReadTopology(topPath,newMap); goto done; } /*if (recs>0) err = this -> ReadTimeData(indexOfStart,&velocityH,errmsg); else {strcpy(errmsg,"No times in file. Error opening NetCDF wind file"); err = -1;} if(err) goto done;*/ err = dynamic_cast<NetCDFWindMoverCurv *>(this)->ReorderPoints(newMap,errmsg); //err = ReorderPoints(fStartData.dataHdl,newMap,errmsg); done: if (err) { printNote("Error opening NetCDF wind file"); if(fGrid) { fGrid ->Dispose(); delete fGrid; fGrid = 0; } if(vertexPtsH) {DisposeHandle((Handle)vertexPtsH); vertexPtsH = 0; fVertexPtsH = 0;} } if (timeUnits) delete [] timeUnits; if (lat_vals) delete [] lat_vals; if (lon_vals) delete [] lon_vals; if (modelTypeStr) delete [] modelTypeStr; //if (velocityH) {DisposeHandle((Handle)velocityH); velocityH = 0;} return err; }
short GridCurrentMoverSettingsClick(DialogPtr dialog, short itemNum, long lParam, VOIDPTR data) { long menuID_menuItem; switch (itemNum) { case M33OK: { char errmsg[256]; short timeZone = GetPopSelection(dialog, M33TIMEZONEPOPUP); Seconds timeShift = sGridCurrentDialogMover->timeGrid->fTimeShift; float arrowDepth = EditText2Float(dialog, M33ARROWDEPTH), maxDepth=0; float maxDepthForExtrapolation = EditText2Float(dialog, M33EXTRAPOLATETOVALUE); double tempAlong, tempCross, tempDuration, tempStart; long timeShiftInHrs; Boolean extrapolateVertically = GetButton(dialog, M33EXTRAPOLATEVERTCHECKBOX); //Boolean extrapolateVertically = false; Boolean showBottomVel = GetButton(dialog, M33VELOCITYATBOTTOMCHECKBOX); TMap *map = sGridCurrentDialogMover -> GetMoverMap(); if (showBottomVel) arrowDepth = -2; //check maxDepth>0 if (map) { maxDepth = map -> GetMaxDepth2(); // 2D vs 3D ? //arrowDepth = EditText2Float(dialog, M33ARROWDEPTH); if (arrowDepth > maxDepth) { char errStr[64]; sprintf(errStr,"The maximum depth of the region is %g meters.",maxDepth); printError(errStr); break; } } else { // only need this if doing something 3D maxDepth = ((TimeGridVelRect*) (sGridCurrentDialogMover -> timeGrid)) -> GetMaxDepth(); //maxDepth = 1000; if (arrowDepth > maxDepth) { char errStr[64]; sprintf(errStr,"The maximum depth of the region is %g meters.",maxDepth); printError(errStr); break; } } strcpy(errmsg,""); tempAlong = EditText2Float(dialog, M33ALONG); tempCross = EditText2Float(dialog, M33CROSS); tempDuration = EditText2Float(dialog, M33DURATION); tempStart = EditText2Float(dialog, M33STARTTIME); if(tempAlong <= 0 || tempCross <= 0) strcpy(errmsg,"The uncertainty must be greater than zero."); else if(tempAlong > 100 || tempCross > 100) strcpy(errmsg,"The uncertainty cannot exceed 100%."); if(errmsg[0]) { printError(errmsg); if (tempAlong <= 0 || (tempAlong > 100 && tempCross > 0)) MySelectDialogItemText(dialog, M33ALONG,0,100); else MySelectDialogItemText(dialog, M33CROSS,0,100); break; } if(tempDuration < 1) strcpy(errmsg,"The uncertainty duration must be at least 1 hour."); // maximum? if(errmsg[0]) { printError(errmsg); MySelectDialogItemText(dialog, M33DURATION,0,100); break; } timeShiftInHrs = EditText2Long(dialog, M33TIMESHIFT); if (timeShiftInHrs < -12 || timeShiftInHrs > 14) // what should limits be? { printError("Time offsets must be in the range -12 : 14"); MySelectDialogItemText(dialog, M33TIMESHIFT,0,100); break; } if (extrapolateVertically) { if (maxDepthForExtrapolation==0) { if (maxDepth>0) sprintf(errmsg,"Either set a max depth for extrapolation or turn off option. The maximum depth of the region is %g meters.",maxDepth); else sprintf(errmsg,"Either set a max depth for extrapolation or turn off option"); printNote(errmsg); break; } if (maxDepth>0 && maxDepthForExtrapolation>maxDepth) { sprintf(errmsg,"The maximum depth of the region is %g meters.",maxDepth); printNote(errmsg); break; } } mygetitext(dialog, M33NAME, sGridCurrentDialogMover->timeGrid->fVar.userName, kPtCurUserNameLen-1); sGridCurrentDialogMover->bActive = GetButton(dialog, M33ACTIVE); sGridCurrentDialogMover->fVar.bShowArrows = GetButton(dialog, M33SHOWARROWS); sGridCurrentDialogMover->fVar.arrowScale = EditText2Float(dialog, M33ARROWSCALE); sGridCurrentDialogMover->fVar.arrowDepth = arrowDepth; //sGridCurrentDialogMover->timeGrid->fVar.fileScaleFactor = EditText2Float(dialog, M33SCALE); sGridCurrentDialogMover->fVar.curScale = EditText2Float(dialog, M33SCALE); if (sGridCurrentDialogMover->fVar.alongCurUncertainty != tempAlong || sGridCurrentDialogMover->fVar.crossCurUncertainty != tempCross || sGridCurrentDialogMover->fVar.startTimeInHrs != tempStart || sGridCurrentDialogMover->fVar.durationInHrs != tempDuration) sDialogUncertaintyChanged2 = true; sGridCurrentDialogMover->fVar.alongCurUncertainty = EditText2Float(dialog, M33ALONG)/100; sGridCurrentDialogMover->fVar.crossCurUncertainty = EditText2Float(dialog, M33CROSS)/100; //sNetCDFDialogMover->fVar.uncertMinimumInMPS = EditText2Float(dialog, M33MINCURRENT); sGridCurrentDialogMover->fVar.startTimeInHrs = EditText2Float(dialog, M33STARTTIME); sGridCurrentDialogMover->fVar.durationInHrs = EditText2Float(dialog, M33DURATION); sGridCurrentDialogMover->fDownCurUncertainty = -sGridCurrentDialogMover->fVar.alongCurUncertainty; sGridCurrentDialogMover->fUpCurUncertainty = sGridCurrentDialogMover->fVar.alongCurUncertainty; sGridCurrentDialogMover->fRightCurUncertainty = sGridCurrentDialogMover->fVar.crossCurUncertainty; sGridCurrentDialogMover->fLeftCurUncertainty = -sGridCurrentDialogMover->fVar.crossCurUncertainty; sGridCurrentDialogMover->fDuration = sGridCurrentDialogMover->fVar.durationInHrs * 3600.; sGridCurrentDialogMover->fUncertainStartTime = (long) (sGridCurrentDialogMover->fVar.startTimeInHrs * 3600.); //if (timeZone>1) sNetCDFDialogMover->fTimeShift = EditText2Long(dialog, M33TIMESHIFT)*3600*-1; if (timeZone>1) sGridCurrentDialogMover->timeGrid->fTimeShift =(long)( EditText2Float(dialog, M33TIMESHIFT)*3600); else sGridCurrentDialogMover->timeGrid->fTimeShift = 0; // file is in local time //if (model->GetStartTime() != startTime || model->GetModelTime()!=model->GetStartTime()) // code goes here, should also check if start time has been shifted correctly already (if there is another current) //if (timeShift != sNetCDFDialogMover->fTimeShift || sNetCDFDialogMover->GetTimeValue(0) != model->GetStartTime()) // GetTImeValue adds in the time shift // What if time zone hasn't changed but start time has from loading in a different file?? if ((timeShift != sGridCurrentDialogMover->timeGrid->fTimeShift && sGridCurrentDialogMover->timeGrid->GetTimeValue(0) != model->GetStartTime())) { //model->SetModelTime(model->GetModelTime() - (sNetCDFDialogMover->fTimeShift-timeShift)); if (model->GetStartTime() + sGridCurrentDialogMover->timeGrid->fTimeShift - timeShift == sGridCurrentDialogMover->timeGrid->GetTimeValue(0)) model->SetStartTime(model->GetStartTime() + (sGridCurrentDialogMover->timeGrid->fTimeShift-timeShift)); //model->SetStartTime(sNetCDFDialogMover->GetTimeValue(0)); // just in case a different file has been loaded in the meantime, but what if user doesn't want start time to change??? //sNetCDFDialogMover->SetInterval(errmsg); model->NewDirtNotification(DIRTY_RUNBAR); // must reset the runbar } sGridCurrentDialogMover->timeGrid->fAllowExtrapolationInTime = GetButton(dialog, M33EXTRAPOLATECHECKBOX); ((TimeGridVelRect*) (sGridCurrentDialogMover->timeGrid))->fAllowVerticalExtrapolationOfCurrents = GetButton(dialog, M33EXTRAPOLATEVERTCHECKBOX); // code goes here, add box to dialog to input desired depth to extrapolate to if (((TimeGridVelRect*) (sGridCurrentDialogMover->timeGrid))-> fAllowVerticalExtrapolationOfCurrents) ((TimeGridVelRect*) (sGridCurrentDialogMover->timeGrid))->fMaxDepthForExtrapolation = EditText2Float(dialog, M33EXTRAPOLATETOVALUE); else ((TimeGridVelRect*) (sGridCurrentDialogMover->timeGrid))->fMaxDepthForExtrapolation = 0.; return M33OK; } case M33CANCEL: return M33CANCEL; case M33ACTIVE: case M33SHOWARROWS: case M33EXTRAPOLATECHECKBOX: ToggleButton(dialog, itemNum); break; case M33VELOCITYATBOTTOMCHECKBOX: // code goes here, showhide the M33ARROWDEPTH, M33ARROWDEPTHUNITS ToggleButton(dialog, itemNum); ShowHideVerticalExtrapolationDialogItems2(dialog); if (!GetButton(dialog,M33VELOCITYATBOTTOMCHECKBOX)) Float2EditText(dialog, M33ARROWDEPTH, 0, 6); break; case M33EXTRAPOLATEVERTCHECKBOX: ToggleButton(dialog, itemNum); ShowHideVerticalExtrapolationDialogItems2(dialog); break; case M33ARROWSCALE: case M33ARROWDEPTH: //case M33SCALE: case M33ALONG: case M33CROSS: //case M33MINCURRENT: case M33STARTTIME: case M33DURATION: //case M33TIMESHIFT: case M33EXTRAPOLATETOVALUE: CheckNumberTextItem(dialog, itemNum, TRUE); break; case M33SCALE: case M33TIMESHIFT: CheckNumberTextItemAllowingNegative(dialog, itemNum, TRUE); // decide whether to allow half hours break; case M33TIMEZONEPOPUP: PopClick(dialog, itemNum, &menuID_menuItem); ShowGridCurrentMoverDialogItems(dialog); if (GetPopSelection(dialog, M33TIMEZONEPOPUP) == 2) MySelectDialogItemText(dialog, M33TIMESHIFT, 0, 100); break; case M33GMTOFFSETS: { char gmtStr[512], gmtStr2[512]; strcpy(gmtStr,"Standard time offsets from GMT\n\nHawaiian Standard -10 hrs\nAlaska Standard -9 hrs\n"); strcat(gmtStr,"Pacific Standard -8 hrs\nMountain Standard -7 hrs\nCentral Standard -6 hrs\nEastern Standard -5 hrs\nAtlantic Standard -4 hrs\n"); strcpy(gmtStr2,"Daylight time offsets from GMT\n\nHawaii always in standard time\nAlaska Daylight -8 hrs\n"); strcat(gmtStr2,"Pacific Daylight -7 hrs\nMountain Daylight -6 hrs\nCentral Daylight -5 hrs\nEastern Daylight -4 hrs\nAtlantic Daylight -3 hrs"); //printNote(gmtStr); short buttonSelected = MULTICHOICEALERT2(1691,gmtStr,gmtStr2,TRUE); switch(buttonSelected){ case 1:// ok //return -1;// break; case 3: // cancel //return -1;// break; } break; } case M33REPLACEMOVER: { //sGridCurrentDialogMover->ReplaceMover(); //mysetitext(dialog, M33NAME, sGridCurrentDialogMover->fVar.userName); // use short file name for now } } return 0; }
void cActionDefTest::testSingleLinerDef() throw() { printNote( "SINGLE LINER TESTS" ); try { cActionDefSingleLiner *poSingleLiner; poSingleLiner = new cActionDefSingleLiner; testCase( "SingleLiner empty constructor Name", "", poSingleLiner->name().toStdString() ); testCase( "SingleLiner empty constructor Upload", cActionUpload::MIN, poSingleLiner->upload() ); testCase( "SingleLiner empty constructor Pattern", "", poSingleLiner->pattern().toStdString() ); testCase( "SingleLiner empty constructor Result", cActionResult::MIN, poSingleLiner->result() ); delete poSingleLiner; poSingleLiner = new cActionDefSingleLiner( NULL ); testCase( "SingleLiner NULL Dom Element Name", "", poSingleLiner->name().toStdString() ); testCase( "SingleLiner NULL Dom Element Upload", cActionUpload::MIN, poSingleLiner->upload() ); testCase( "SingleLiner NULL Dom Element Pattern", "", poSingleLiner->pattern().toStdString() ); testCase( "SingleLiner NULL Dom Element Result", cActionResult::MIN, poSingleLiner->result() ); delete poSingleLiner; QDomDocument obDomDoc( "ActionTest" ); QDomElement obDomElem = obDomDoc.createElement( "single_liner" ); obDomElem.setAttribute( "name", "TestSingleLiner" ); obDomElem.setAttribute( "pattern", "Test Pattern" ); obDomElem.setAttribute( "result", "OK" ); obDomElem.setAttribute( "upload", "ALWAYS" ); poSingleLiner = new cActionDefSingleLiner( &obDomElem ); testCase( "SingleLiner Correct DOM Element Name", "TestSingleLiner", poSingleLiner->name().toStdString() ); testCase( "SingleLiner Correct DOM Element Upload", cActionUpload::ALWAYS, poSingleLiner->upload() ); testCase( "SingleLiner Correct DOM Element Pattern", "Test Pattern", poSingleLiner->pattern().toStdString() ); testCase( "SingleLiner Correct DOM Element Result", cActionResult::OK, poSingleLiner->result() ); delete poSingleLiner; obDomElem.removeAttribute( "pattern" ); poSingleLiner = new cActionDefSingleLiner( &obDomElem ); testCase( "SingleLiner Missing Attribute Name", "TestSingleLiner", poSingleLiner->name().toStdString() ); testCase( "SingleLiner Missing Attribute Pattern", "", poSingleLiner->pattern().toStdString() ); delete poSingleLiner; } catch( cSevException &e ) { g_obLogger << e; m_uiFailedNum++; } }
void cActionDefTest::testCountActions() throw() { printNote( "COUNT ACTION TESTS" ); try { cCountAction *poCountAction; poCountAction = new cCountAction; testCase( "CountAction empty constructor Name", "", poCountAction->name().toStdString() ); testCase( "CountAction empty constructor Action Container empty", true, poCountAction->actionsToCountBegin() == poCountAction->actionsToCountEnd() ); delete poCountAction; poCountAction = new cCountAction( NULL ); testCase( "CountAction NULL DOM Element Name", "", poCountAction->name().toStdString() ); testCase( "CountAction NULL DOM Element Action Container empty", true, poCountAction->actionsToCountBegin() == poCountAction->actionsToCountEnd() ); delete poCountAction; QDomDocument obDomDoc( "ActionTest" ); QDomElement obDomElem = obDomDoc.createElement( "count_action" ); obDomElem.setAttribute( "name", "CountSpam" ); QDomElement obAction1 = obDomDoc.createElement( "action" ); obAction1.setAttribute( "name", "SPAM" ); QDomElement obAction2 = obDomDoc.createElement( "action" ); obAction2.setAttribute( "name", "SPAM_A_LOT" ); obAction2.setAttribute( "attrib", "PIECES_OF_SPAM" ); QDomElement obAction3 = obDomDoc.createElement( "action" ); obAction3.setAttribute( "name", "SPAM_A_LOT_SPAM" ); obDomElem.appendChild( obAction1 ); obDomElem.appendChild( obAction2 ); obDomElem.appendChild( obAction3 ); poCountAction = new cCountAction( &obDomElem ); testCase( "CountAction Correct DOM Element Name", "CountSpam", poCountAction->name().toStdString() ); unsigned int uiActionCount = 0; for( cCountAction::tiActionsToCount itAction = poCountAction->actionsToCountBegin(); itAction != poCountAction->actionsToCountEnd(); itAction++ ) { switch( ++uiActionCount ) { case 1: testCase( "CountAction Correct DOM Element Action 1 Name", "SPAM", itAction->qsName.toStdString() ); break; case 2: testCase( "CountAction Correct DOM Element Action 2 Name", "SPAM_A_LOT", itAction->qsName.toStdString() ); testCase( "CountAction Correct DOM Element Action 2 Attrib", "PIECES_OF_SPAM", itAction->qsAttrib.toStdString() ); break; case 3: testCase( "CountAction Correct DOM Element Action 3 Name", "SPAM_A_LOT_SPAM", itAction->qsName.toStdString() ); break; } } testCase( "CountAction Correct DOM Element Action count", 3, uiActionCount ); delete poCountAction; } catch( cSevException &e ) { g_obLogger << e; m_uiFailedNum++; } }
void NMainMenuBar::setupFileMenu() { QFont f = global.getGuiFont(QFont()); this->setFont(f); fileMenu = this->addMenu(tr("&File")); fileMenu->setFont(f); emailAction = new QAction(tr("Email Note"), this); emailAction->setToolTip(tr("Email a copy of this note")); connect(emailAction, SIGNAL(triggered()), parent, SLOT(emailNote())); setupShortcut(emailAction, QString("File_Email")); fileMenu->addAction(emailAction); printPreviewAction = new QAction(tr("Print Preview Note"), this); printPreviewAction->setToolTip(tr("Print preview of this note")); connect(printPreviewAction, SIGNAL(triggered()), parent, SLOT(printPreviewNote())); setupShortcut(printPreviewAction, QString("File_Print_Preview")); fileMenu->addAction(printPreviewAction); //printPreviewAction->setVisible(false); // for some reason images don't show up in print preview, so this is useless. Check again in Qt5 printAction = new QAction(tr("&Print Note"), this); printAction->setToolTip(tr("Print this note")); connect(printAction, SIGNAL(triggered()), parent, SLOT(printNote())); setupShortcut(printAction, QString("File_Print")); fileMenu->addAction(printAction); fileMenu->addSeparator(); backupDatabaseAction = new QAction(tr("&Backup Database"), this); backupDatabaseAction->setToolTip(tr("Backup database to a file")); connect(backupDatabaseAction, SIGNAL(triggered()), parent, SLOT(databaseBackup())); setupShortcut(backupDatabaseAction, QString("File_Backup_Database")); fileMenu->addAction(backupDatabaseAction); restoreDatabaseAction = new QAction(tr("&Restore Database"), this); restoreDatabaseAction->setToolTip(tr("Restore from a backup")); connect(restoreDatabaseAction, SIGNAL(triggered()), parent, SLOT(databaseRestore())); setupShortcut(restoreDatabaseAction, QString("File_Restore_Database")); fileMenu->addAction(restoreDatabaseAction); fileMenu->addSeparator(); exportNoteAction = new QAction(tr("&Export to NixNote Export"), this); exportNoteAction->setToolTip(tr("Export selected notes to a NNEX file")); connect(exportNoteAction, SIGNAL(triggered()), parent, SLOT(noteExport())); setupShortcut(exportNoteAction, QString("File_Note_Export")); fileMenu->addAction(exportNoteAction); exportAsPdfAction = new QAction(tr("&Export notes as PDF"), this); exportAsPdfAction->setToolTip(tr("Export selected notes to a PDF file")); connect(exportAsPdfAction, SIGNAL(triggered()), parent, SLOT(onExportAsPdf())); setupShortcut(exportAsPdfAction, QString("File_Note_Export_Pdf")); fileMenu->addAction(exportAsPdfAction); importNoteAction = new QAction(tr("&Import notes"), this); importNoteAction->setToolTip(tr("Import notes from an export file")); connect(importNoteAction, SIGNAL(triggered()), parent, SLOT(noteImport())); setupShortcut(importNoteAction, QString("File_Note_Import")); fileMenu->addAction(importNoteAction); fileMenu->addSeparator(); QList<QString> names = global.accountsManager->nameList(); QList<int> ids = global.accountsManager->idList(); QList<QPair<int, QString>> pairList; for (int i = 0; i < ids.size(); i++) { pairList.append(QPair<int, QString>(ids[i], names[i])); } qSort(pairList.begin(), pairList.end(), QPairFirstComparer()); for (int i = 0; i < ids.size(); i++) { QAction *accountAction = new QAction(pairList[i].second + " - (" + QString::number(pairList[i].first) + ")", this); accountAction->setData(pairList[i].first); accountAction->setCheckable(true); if (global.accountsManager->currentId == pairList[i].first) accountAction->setChecked(true); else { accountAction->setText( tr("Switch to ") + pairList[i].second + " - (" + QString::number(pairList[i].first) + ")"); } fileMenu->addAction(accountAction); connect(accountAction, SIGNAL(triggered()), parent, SLOT(switchUser())); userAccountActions.append(accountAction); } addUserAction = new QAction(tr("&Add Another User..."), this); fileMenu->addAction(addUserAction); connect(addUserAction, SIGNAL(triggered()), parent, SLOT(addAnotherUser())); userMaintenanceAction = new QAction(tr("&User Account Maintenance"), this); fileMenu->addAction(userMaintenanceAction); connect(userMaintenanceAction, SIGNAL(triggered()), parent, SLOT(userMaintenance())); fileMenu->addSeparator(); openCloseAction = new QAction(tr("&Open/Close Notebooks"), this); openCloseAction->setToolTip(tr("Open/Close Notebooks")); connect(openCloseAction, SIGNAL(triggered()), parent, SLOT(openCloseNotebooks())); setupShortcut(quitAction, QString("File_Notebook_OpenClose")); fileMenu->addAction(openCloseAction); fileMenu->addSeparator(); quitAction = new QAction(tr("Quit"), this); quitAction->setToolTip(tr("Quit the program")); connect(quitAction, SIGNAL(triggered()), parent, SLOT(quitNixNote())); quitAction->setShortcut(QKeySequence::Close); quitAction->setIcon(QIcon::fromTheme("exit")); setupShortcut(quitAction, QString("File_Exit")); fileMenu->addAction(quitAction); QString menuCss = global.getThemeCss("menuCss"); if (menuCss != "") this->setStyleSheet(menuCss); }