Ejemplo n.º 1
0
/*===========================================================================
 *
 *  Name	 :  	DetermineAllDirectories
 *
 *  Purpose	 :		Finds all the subdirectories under the root path.
 *
 *
 *  Return value :  TRUE - browse completed
 *					FALSE- either not valid root path or >1 root path
 *
 *  Special notes:  
 *
 *  Implicit Input :
    				    				
 *  Implicit Input/Output:
 *  Implicit Output:
 *
 *  date    /	author	revision
 *  -----------------	--------
 *	18-Nov-1998 SFK		Created
 *	06-Jul-1999  SFK Version 2.04 - changed check for FILE_ATTRIBUTE_DIRECTORY to check
 *							`		if that bit is set rather than having the patterns match exactly
 *
===========================================================================*/
BOOL DetermineAllDirectories(char *pDlgPath, CGFmtStr *pAllPaths, unsigned int *puiNumPaths)
{
	char szTemp[PATH_LEN+1];
	
	unsigned int uiNumFound;
	unsigned int ui;
	int iLen;
	int iDum, iDum1;
	int status;
	long lAttributes;
	CGFmtStr szMsg;
	int iTemp;
	GUI_ACTION response;
	HCURSOR OldCur = ::SetCursor(LoadCursor(NULL, IDC_WAIT));

	// Determine how many valid paths are in the pDlgPath entry.
	status = CountPathsAndFiles(pDlgPath, "*.*", (int *)puiNumPaths, &iDum, &iDum1); 
	::SetCursor(OldCur);
	if (status != TRUE) return(FALSE);
	if (*puiNumPaths != 1) return(FALSE);	// only allow one path for the browse

	OldCur = ::SetCursor(LoadCursor(NULL, IDC_WAIT));
	CGStrPtrDynaArray *pResult = BrowseDirectory("*.", pDlgPath, TRUE);
	::SetCursor(OldCur);

	OldCur = ::SetCursor(LoadCursor(NULL, IDC_WAIT));
	uiNumFound = pResult->size();
	pAllPaths->Printf("%s;", pDlgPath);		// always include the root
	*puiNumPaths = 1;
	for (ui=0; ui<uiNumFound; ui++) {
		MyStrnCpy(szTemp, (*pResult)[ui]->Get_sz(), PATH_LEN);	// char * to work with
		iLen = strlen(szTemp);
		lAttributes = GetFileAttributes(szTemp); // address of the name of a file or directory 
		if ((lAttributes &FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {	// only examine the subdirectories
			if ((szTemp[iLen-1] != '.') && // skip all . and .. paths
				(strstr((strupr(szTemp)), "ARCHIVE") == NULL)) {	// skip folders named archive
				if ((strlen(pAllPaths->Get_sz()) + strlen(szTemp)) >= PATHS) {
					szMsg.Printf("The subfolder list generated with the root path of %s contains %d ", pDlgPath, uiNumFound);
					iTemp = PATHS;
					szMsg.PrintfAppend("files and is too long.  Do you want to proceed using only the first %d characters?", iTemp); 
					response = GUI_MsgBox(szMsg, GUI_ICON_QUESTION, GUI_NOYES);
					if (response == GUI_YES) break;
					*puiNumPaths = 0;
					::SetCursor(OldCur);
					return(FALSE);
				}
				pAllPaths->PrintfAppend("%s;", szTemp);
				(*puiNumPaths)++;
			}
		}
	}
	::SetCursor(OldCur);

	BrowseCleanup(pResult);
	return(TRUE);
}
Ejemplo n.º 2
0
// Handle Alt-LeftArrow?, Alt-RightArrow?, n, N, p and P.
// These are special keys in addition to those in GUI-PlotPane?
LRESULT CPlotPane::PlotLibEventPreFilter(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
	LRESULT RetValue = 0;	// Always allow plot library to handle messages.

	switch (iMsg) {
		case WM_SYSKEYDOWN:		// Intercept Alt-key combinations.
			switch (wParam) {
				case VK_LEFT:
					if (!PrevHiliteRegion()) {
						GUI_MsgBox("There are no earlier events\nin the current view period.");
					}
					break;
				case VK_RIGHT: 
					if (!NextHiliteRegion()) {
						GUI_MsgBox("There are no later events\nin the current view period.");
					}
					break;
			}
			break;
		case WM_CHAR:
			switch (wParam) {
				case 'n':
				case 'N':
					if (mpPlotDlg) mpPlotDlg->NextView();
					break;
				case 'p':
				case 'P':
					if (mpPlotDlg) mpPlotDlg->PrevView();
					break;
				default:
					break;
			}
			break;
		default:
			break;
	}	

	// Call base class function.
	RetValue = CGUI_PlotPane::PlotLibEventPreFilter(hWnd, iMsg, wParam, lParam);
	return(RetValue);
}
Ejemplo n.º 3
0
//================================================================
  int TED_init (int typ, long dbi, long dli) {
//================================================================
// main-entrypoint

  int   irc, i1, form, lNr;
  long  l1;
  char  cbuf[160];


  printf("TED_init %d %ld %ld\n",typ,dbi,dli);


  if(AP_stat.texture == 0) {
    GUI_MsgBox ("***** opengl-binding cannot handle textures on this hardware *****");
    return -1;
  }

  // exit if TED is already active
  if(TED_mode >= 0) {
    MSG_pri_0 ("PEDe1"); // ERROR: PED is already active ..");
    return 0;
  }



  // get actObj from DB -------------------------------------
  form = typ;
  irc = UTO_get_DB (&actObj, &i1, &form, dbi);
  if(irc < 0) return irc;
    // printf(" form=%d\n",form);
    // UT3D_stru_dump (form, actObj, "actObj: ");


  actDli = dli;
  actDbi = dbi;
  actTyp = form;



  // lock some application-functions...
  UI_func_stat_set__ (-APF_TB_CAD,
                      -APF_MEN_FIL,
                      -APF_MEN_SM,
                      -APF_MEN_MDF,
                      -APF_MEN_APP,
                      -APF_HIDE,
                      -APF_VWCADMAN,
                      -APF_BUT_GSE,
                      -APF_PLUGINS,
                      -APF_UNDO,
                      0);
  
  AP_UserKeyIn_get     (TED_key_CB);         // attach keystrokes
  AP_UserSelection_get (TED_sel_CB);         // attach grafic selections
  AP_UserMousemove_get (TED_mousemove_CB);   // attach mousemovements


  DL_pick__ (0);               // make all objects unpickable
  DL_pick_typ (Typ_SUR, 1);    // make all surfaces pickable
  GR_set_dispTra (1);          // inhibit display-transformations


  // set surfacDbNr & dliNr
  Tex_setSurfInd (actDbi, actDli);


  // load texture ../xa/xa_tex.c TexBasAct
  irc = GA_Tex__ (actDli, 2, typ, actDbi);
    printf("ex GA_Tex__ %d\n",irc);

  // display red frame (roter Rahmen)
  if(irc >= 0) {
    TED_frm__ (ON);
    TED_mode = 1;

  } else {
    TED_mode = 0;
  }

  TX_Print(
    "- modify texture-position activated - use shift and/or ctrl-key and move mouse"
    );


  // init TED-toolbar
  if(GUI_OBJ_IS_VALID(&TEDtb)) {
    GUI_set_show (&TEDtb, 1);
    // TED_win__ (NULL, (void*)UI_FuncUCB1);
  } else {
    TED_win__ (&UIw_Box_TB, (void*)UI_FuncInit);
  }



  return 0;

}
Ejemplo n.º 4
0
//  27-Aug-2004 SFK		Created
void CopyLogsMenuOption()
{                                 

    static char szDfltRootPath[PATH_LEN+1] = "";
    static char szDfltCurrentDbPath[PATH_LEN+1] = "";                   
    static BOOL bFirst = TRUE;
    
	char szCurrentDbPath[PATH_LEN+1] = "";    
	char szMainCurrentDbPath[PATH_LEN+1] = "";    
    char szRootBackupPath[PATH_LEN+1] = "";
	char szMainBackupPath[PATH_LEN+1] = "";
    unsigned long ulDirSize, ulDiskSize, ulDiskAvailable;
    BOOL bRoom;     
    int status;
    char *pStr;

    
    GUI_ACTION DlgReturn;         
    CGFmtStr msg;

	SetCurrentDrive();    
    GetDbName(szCurrentDbPath);
    
   /* ------------------------------------------------------------------
    *	First time or when change databases, get the default values
    *	from the .ini file else use the last successful values.
    * ------------------------------------------------------------------*/
    if ((bFirst == TRUE) || (!SameDb(szDfltCurrentDbPath))) {
    	pStr = pRAD_Init->Get_LogCopy_To_Path(); 
		MyStrnCpy(szDfltRootPath, pStr, PATH_LEN); 
   		bFirst = FALSE;
    	strcpy(szDfltCurrentDbPath, szCurrentDbPath);
	}
	
	strcpy(szRootBackupPath, szDfltRootPath);

   /* ------------------------------------------------------------------
    *	Define the buttons and actions in the dialog box
    * ----------------------------------------------------------------*/
    CGUI_Dlg BackupDbDlg(IDD_FILE_COPY_LOGS, NULL, DLG_POSN_NO_SAVE);
    if (BackupDbDlg.IsValid()) {
		BackupDbDlg.DefinePushBtn(IDCANCEL, GUI_CANCEL);
		BackupDbDlg.DefinePushBtn(IDOK, GUI_OK);
		BackupDbDlg.DefinePushBtn(IDUPDATE, GUI_NONE, UpdateINI_Parms);              
			                                               
		BackupDbDlg.DefineFldTxt(IDC_CLOG_EDIT_NEW_PATH, szRootBackupPath, PATH_LEN);
			
		BackupDbDlg.SetFocus(IDOK);
		
	    DlgReturn = BackupDbDlg.Go();
		    
	    if (DlgReturn == GUI_OK) {  
		    	
	    	BackupDbDlg.RetrieveAllControlValues();

		   /* ------------------------------------------------------------------
		    *	Remove spaces, check length
		    * ----------------------------------------------------------------*/
	    	if (PathCopy(szMainBackupPath, szRootBackupPath) != TRUE) return;
	    	strcat(szMainBackupPath, "logs\\rad\\");

	    	if (PathCopy(szMainCurrentDbPath, szCurrentDbPath) != TRUE) return;
	    	strcat(szMainCurrentDbPath, "logs\\rad\\");

		   /* ------------------------------------------------------------------
		    *	See if the new path exists, if not make it.  If can't make it give
		    *	reason why.
		    * ----------------------------------------------------------------*/
		    status = PathExists(szMainBackupPath); // returns TRUE, uiPATH_TOO_LONG_ERR, uiDRIVE_DOES_NOT_EXIST_ERR oruiPATH_DOES_NOT_EXIST_ERR
		    if ( status == uiPATH_DOES_NOT_EXIST_ERR) {
		    	status = AskAndMakePath(szMainBackupPath);
		    	if (status != TRUE) return;
		    }	
		    if ( status != TRUE) {
		    	RadReviewMsg(status, (const char *)szMainBackupPath);
				return;
			}	

		   /* ------------------------------------------------------------------
		    *	See if a log file exists at the location specified.  If yes,
		    *	see if they want to overwrite it.
		    * ----------------------------------------------------------------*/
		    if (FileExists(szMainBackupPath, "RadReviewLog.txt") == TRUE) {
		    	status = AskOverwriteQuestion(szMainBackupPath);
		    	if (status == FALSE) return;
		    }	
		    
		   /* ------------------------------------------------------------------
		    *	Figure out how many bytes will need to be copied and if there
		    *	is room on the destination drive.  (Destination drive must have
		    *	directory size + 10000 to allow for directory entries, etc.)
		    * ----------------------------------------------------------------*/
		    if (GetDirSize(szMainCurrentDbPath, "*.*", &ulDirSize) != TRUE) return;	/* check number of bytes filled in szCurrentDbPath */
			
			// Customize for COMs, if don't write to this log directory

		    if (GetDriveSize(szMainBackupPath, &ulDiskSize, &ulDiskAvailable) != TRUE) return;	/* check number of bytes available on drive */
			
			bRoom = TRUE;
			if ((ulDirSize + 10000) > ulDiskAvailable) bRoom = FALSE;	    
		    	    
		    if (bRoom == FALSE) {
		    	if (AskNotEnoughRoomQuestion(ulDirSize, ulDiskAvailable, szMainBackupPath) == FALSE) return;
		    }
		    
		   /* ------------------------------------------------------------------
		    *	Close the current database in case are trying to copy it.
		    *	Copy the data and show progress. Inform of the results of the copy.	
		    * ----------------------------------------------------------------*/
		    GetDbName(szCurrentDbPath);
			_flushall();
			    
		    status = CopyDirectory(szMainCurrentDbPath, szMainBackupPath);

			// Customize for COMs, if don't write to this log directory

		    if (status != TRUE) { 
		    	RadReviewMsg(uiCOPY_DB_ERR, (const char *)szCurrentDbPath, (const char *)szRootBackupPath);
		    }
		    else {	
		    	MyStrnCpy(szDfltRootPath,szRootBackupPath, PATH_LEN);	// remember the default for next time
				msg.Printf("Logs copied to %s.", szRootBackupPath);	
			    GUI_MsgBox(msg, GUI_ICON_INFO);
		    }	

	    }	
	}    
}   		                                 
Ejemplo n.º 5
0
///////////////////////////////////////////////////////////////////////////////////////////////
//	This displays only the dialog box part of this menu option
////////////////////////////////////////////////////////////////////////////////////////////////
static int OnlyDialogBox(BOOL bAutomated)
{                                 
//	static char szOldDbName[DRIVE_LEN+PATH_LEN+1] = {""};;
 	static BOOL bFirst = TRUE;
	static int sFacNum;
	static double dDbExactIntervalLastTime = 0;

    CGFmtStr szInterval;
	CGStr DumStr;
	char szFirstDate[DT_LEN+1], szLastDate[DT_LEN+1];
	unsigned long ulDbIntervalInDays, ulTotalPts;
	GUI_ACTION DlgReturn;                                     
	CGFmtStr msg;   
	int iStatus;
	double dDbExactInterval;
	DATE dDum;
	char szFacName[DB_NAME_LEN+1];
	unsigned int uiPicklistChoice;
	
	SetCurrentDrive();

	// verify the facility is defined
	if (!pglFacCfg->IsFacilityDefined(glsFacNum)) return(FALSE);
	// 3.0.3.16 Dec 1, 2004  Check that there are some stations in the currently defined facility
	if (!pglFacCfg->DoesFacilityHaveAnyData(glsFacNum)) return(FALSE);

	pglFacCfg->GetFacilityLongName(glsFacNum, szFacName, DB_NAME_LEN);

	// always get the current range of data in the db for display
	iStatus = GetDatabaseIntervalParameters(szFirstDate, szLastDate, &ulDbIntervalInDays, &dDbExactInterval);
	if (iStatus != TRUE) return(FALSE);
	if (dDbExactInterval <= 0.0) {
		RadReviewMsg(uiDB_EMPTY_STATUS);
		return(FALSE);
	}

	// only the first time or when something changes, read the default parameters
	// and get new search intervals (possibly from .ini)
    if ((bFirst == TRUE) || 
		(!SameDb(glszOldDbName)) || 
		(dDbExactInterval != dDbExactIntervalLastTime) ||
		(sFacNum != glsFacNum)) {

		ReadDefaultDbParameters();

		// Get the period the user wants to review
		GetReviewPeriodParameters(&glldReviewPeriodStart, &glldReviewPeriodEnd, &gllulInterval);
		glliUserUnits = 0;

		// remember the current conditions for future entries to this option
		sFacNum = glsFacNum;
	    GetDbName(glszOldDbName);								
		dDbExactIntervalLastTime = dDbExactInterval;
		bFirst = FALSE;
	}
	 
    CGUI_Dlg IntegrityDlg(IDD_TOOLS_INTEGRITY, NULL, DLG_POSN_NO_SAVE);
	if (IntegrityDlg.IsValid()) {	
	   /* ------------------------------------------------------------------
	    *	Define the buttons and actions in the dialog box
	    * ----------------------------------------------------------------*/
		IntegrityDlg.DefinePushBtn(IDCANCEL, GUI_CANCEL);
		IntegrityDlg.DefinePushBtn(IDOK, GUI_OK);
		IntegrityDlg.DefinePushBtn(IDUPDATE, GUI_NONE, UpdateDbParms);  		  
		//This push button was silly, change based on Picklist choices HN 3-26-08
//		IntegrityDlg.DefinePushBtn(IDUPDATECONDITIONS, GUI_NONE, ValidateStation);  		  
	
		// Fill in Facility portion of dialog
		IntegrityDlg.DefineFldStaticTxt(IDC_INTEGRITY_FACILITY);
		IntegrityDlg.FldStaticTxtSetValue(IDC_INTEGRITY_FACILITY, szFacName);

		// Fill in Station portion of dialog
		int iMaxLen;		// longest name in list -- not used
		if (!pglFacCfg->CreateStationPicklist(glsFacNum, TRUE, &aszStaList, &iMaxLen)) return (FALSE);	// list with All Stations as member
		short sTemp;
		pglFacCfg->GetPicklistChoiceForStationID(gllStaID, &sTemp);
		uiPicklistChoice = sTemp;
		IntegrityDlg.DefinePickList(IDC_INTEGRITY_STATION, aszStaList, &uiPicklistChoice);
		//HN 3-26-08  Set choices based on what is chosen.
		IntegrityDlg.SetCtrlNotifyFn(IDC_INTEGRITY_STATION,ValidateStation);

	   /* ------------------------------------------------------------------
	    * 	Display current starting ending database dates and interval
	    * ----------------------------------------------------------------*/
		IntegrityDlg.DefineFldStaticTxt(IDC_INTEGRITY_CURR_DB_START);
		IntegrityDlg.FldStaticTxtSetValue(IDC_INTEGRITY_CURR_DB_START, szFirstDate);
					
		IntegrityDlg.DefineFldStaticTxt(IDC_INTEGRITY_CURR_DB_END);
		IntegrityDlg.FldStaticTxtSetValue(IDC_INTEGRITY_CURR_DB_END, szLastDate);
		
		szInterval.Printf("%ld days", ulDbIntervalInDays);  			
		IntegrityDlg.DefineFldStaticTxt(IDC_INTEGRITY_CURR_DB_INTERVAL);
		IntegrityDlg.FldStaticTxtSetValue(IDC_INTEGRITY_CURR_DB_INTERVAL, szInterval);
		
	   /* ------------------------------------------------------------------
	    *	Fill in default values for search start date and time plus interval
	    * ----------------------------------------------------------------*/
		//Date.DATETimestampToGenStructs(glldReviewPeriodStart, &gllGenDate, &gllGenTime);
		glMyDateTime.DATETimestampToGenStructs(glldReviewPeriodStart, &gllGenDate, &gllGenTime);
		IntegrityDlg.DefineFldDate(IDC_INTEGRITY_SRCH_STRTDATE, &gllGenDate);
		IntegrityDlg.DefineFldTime(IDC_INTEGRITY_SRCH_STRTTIME, &gllGenTime);
			                                                          
		IntegrityDlg.DefineFldNum(IDC_INTEGRITY_SRCH_INTERVAL, &gllulInterval, 1, 10000,"%ld");
		IntegrityDlg.DefinePickList(IDC_INTEGRITY_INTRVL_UNITS_PL, glnaszIntervalUnitsPicklist, &glliUserUnits);

		IntegrityDlg.DefineFldNum(IDC_INTEGRITY_TOLERANCE, &gllsTolerance, 0, 100,"%d");
			
	   /* ------------------------------------------------------------------
	    *	Define all checkboxes
	    * ----------------------------------------------------------------*/
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_AC_POWER, &gllFlags.bACPower);		
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_BATTERY_LOW, &gllFlags.bBatteryLow);		
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_COLDSTART, &gllFlags.bColdStart);		
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_AUTHENTICATION, &gllFlags.bAuthentication);
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_ORDER, &gllFlags.bOutOfOrder);		
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_GAP, &gllFlags.bGaps);		
		SetCheckboxes(&IntegrityDlg, &gllStaID);

		IntegrityDlg.SetFocus(IDC_INTEGRITY_SRCH_INTERVAL);
		if (bAutomated) IntegrityDlg.SetFocus(IDOK);
			
tryagain:	    DlgReturn = IntegrityDlg.Go();
			    
	    if (DlgReturn == GUI_OK) {  
			    	
	    	IntegrityDlg.RetrieveAllControlValues();                                          
	    //	gllsStaChoice = uiTemp;		// do I need this
	    	
		    // Get the station number first, we exit if they pick EOSS HN 3-26-08
			// get the station number associated with the station choice
			if (!pglFacCfg->GetStationIDForPicklistChoice(uiPicklistChoice, &gllStaID)) return(FALSE);

			if (gllStaID.sStaType == EOSS_TYPE)
			{
				GUI_MsgBox ("EOSS instruments cannot be analyzed for data integrity.\nChoose another instrument for analysis.",GUI_ICON_INFO, GUI_OK);
				goto abort;
			}
			
			/* ------------------------------------------------------------------
		    *	Check that at least one condition is checked
		    * ----------------------------------------------------------------*/    
		    if ((gllFlags.bACPower == FALSE ) && (gllFlags.bBatteryLow == FALSE) &&
		    	(gllFlags.bColdStart == FALSE ) && (gllFlags.bAuthentication == FALSE) &&
		    	(gllFlags.bOutOfOrder == FALSE ) && (gllFlags.bGaps == FALSE)) 
			{ 
				GUI_MsgBox("No conditions selected for integrity check.\nTry again.", GUI_ICON_INFO, GUI_OK);
				goto tryagain;
		    }	
			// get the station number associated with the station choice
			if (gllStaID.sStaType == BINARY_TYPE) 
			{
				if (gllFlags.bOutOfOrder == FALSE)
				{
					GUI_MsgBox("Binary data can only be checked for Out of Order condition.\nIntegrity check will abort now.", GUI_ICON_INFO, GUI_OK);
					goto abort;
				}
			}
			// if running in automated mode, then record the parameters
		    if (bAutomated) {
		    	WriteDefaultDbParameters(&IntegrityDlg, IDD_TOOLS_INTEGRITY);
			}	
		   /* ------------------------------------------------------------------
			*	Check to see that there is data for station(s) in the interval selected.
			* ----------------------------------------------------------------*/   
			iStatus = ConvertStructsToSearchIntervalParameters(&gllGenDate, &gllGenTime, glliUserUnits, gllulInterval, &glldReviewPeriodStart, &glldReviewPeriodEnd);
			if (gllStaID.sStaID == -1) {
				if (iStatus != TRUE) {	// no data for any station in the interval
					RadReviewMsg(uiNO_DATA_IN_INTERVAL_WARN, glldReviewPeriodStart, glldReviewPeriodEnd, "any station");
					goto abort;
				}
			}
			else {
				iStatus = GetDataStatistics(gllStaID, true, glldReviewPeriodStart, glldReviewPeriodEnd, &dDum, &dDum, &ulTotalPts);
				if ((iStatus != TRUE) || (ulTotalPts == 0)) {
					RadReviewMsg(uiNO_DATA_IN_INTERVAL_WARN, glldReviewPeriodStart, glldReviewPeriodEnd, (const char*)aszStaList[gllsStaChoice]);
					goto abort;
				}
			}
			
			pglFacCfg->DestroyPicklist(aszStaList);
			aszStaList = NULL;
			return(TRUE);
		}
	}
	return(FALSE);

abort:
	pglFacCfg->DestroyPicklist(aszStaList);
	aszStaList = NULL;
    return(FALSE);
}