Esempio n. 1
0
CAnimationItem::CAnimationItem( CAnimationEngine* pAE )
{
	SetDefaults();
	m_pAE = pAE;
}
Esempio n. 2
0
vtEdgeFeature::vtEdgeFeature()
{
	SetDefaults();
}
Esempio n. 3
0
CMapChecker::CMapChecker()
{
	Init();
	SetDefaults();
}
Esempio n. 4
0
bool Options::Load (int argc_, char* argv_[])
{
    FILE* hfOptions = fopen(OSD::MakeFilePath(MFP_SETTINGS, OPTIONS_FILE), "r");
    if (hfOptions)
    {
        char szLine[256];
        while (fgets(szLine, sizeof(szLine), hfOptions))
        {
            char *pszValue = strchr(szLine, '=');
            char *pszName = strtok(szLine, " \t=");

            if (!pszName || !pszValue)
                continue;

            // Skip delimiters up to the value, and take the value up to a <CR> or <LF>
            pszValue++;
            strtok(pszValue += strspn(pszValue, " \t=\r\n"), "\r\n");

            // Look for the option in the list
            for (OPTION* p = aOptions ; p->pcszName ; p++)
            {
                if (!strcasecmp(pszName, p->pcszName))
                {
                    // Remember that a value has been found for this option
                    p->fSpecified = true;

                    // Extract the appropriate value type from the string
                    switch (p->nType)
                    {
                        case OT_BOOL:       *p->pf = *pszValue ? IsTrue(pszValue) : p->fDefault;    break;
                        case OT_INT:        *p->pn = *pszValue ? atoi(pszValue) : p->nDefault;      break;
                        case OT_STRING:     strcpy(p->ppsz, *pszValue ? pszValue : p->pcszDefault); break;
                    }
                }
            }
        }

        // We're done with the file
        fclose(hfOptions);
    }

    // Set the default values for any missing options, or all if the config version has changed
    bool fIncompatible = GetOption(cfgversion) != CFG_VERSION;
    SetDefaults(fIncompatible);

    // Process any commmand-line arguments to look for options
    while (argc_ && --argc_)
    {
        const char* pcszOption = *++argv_;
        if (*pcszOption == '-')
        {
            // Find the option in the list of known options
            OPTION* p = FindOption(pcszOption+1);

            if (p)
            {
                switch (p->nType)
                {
                    case OT_BOOL:   *p->pf = (argv_[1] && *argv_[1] == '-') || (argc_-- && IsTrue(*++argv_)); continue;
                    case OT_INT:    *p->pn = atoi(*++argv_);    break;
                    case OT_STRING: strcpy(p->ppsz, *++argv_);  break;
                }

                argc_--;
            }
            else
                TRACE("Unknown command-line option: %s\n", pcszOption);
        }
        else
        {
            static int nDrive = 1;

            // Bare filenames will be inserted into drive 1 then 2
            switch (nDrive++)
            {
                case 1:
                    SetOption(disk1, pcszOption);
                    SetOption(drive1,drvFloppy);
                    g_nAutoLoad = AUTOLOAD_DISK;
                    break;

                case 2:
                    SetOption(disk2, pcszOption);
                    SetOption(drive2,drvFloppy);
                    break;

                default:
                    TRACE("Unexpected command-line parameter: %s\n", pcszOption);
                    break;
            }
        }
    }

    return true;
}
int ParseArgs(int argc, char *argv[], user_settings *set)
{
	if (argv == NULL || set == NULL)
		return USR_PTR_PASS_FAIL;

	if (argc < 2) {
		DisplayHelp(argv[0]);
		return USR_HELP;
	}

	// Detecting Help Requried
	for (int i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-help") == 0) {
			DisplayHelp(argv[0]);
			return USR_HELP;
		}
		else if (strcmp(argv[i], "-exthelp") == 0) {
			DisplayExtendedHelp(argv[0]);
			return USR_HELP;
		}
	}

	// Allocating Memory for Content Path Ptrs
	set->common.contentPath = calloc(CIA_MAX_CONTENT, sizeof(char*));
	if (set->common.contentPath == NULL) {
		fprintf(stderr, "[SETTING ERROR] Not Enough Memory\n");
		return USR_MEM_ERROR;
	}

	// Initialise Keys
	InitKeys(&set->common.keys);

	// Setting Defaults
	SetDefaults(set);

	// Parsing Arguments
	int set_result;
	for (int i = 1; i < argc; i += set_result) {
		set_result = SetArgument(argc, i, argv, set);
		if (set_result < 1) {
			fprintf(stderr, "[RESULT] Invalid arguments, see '%s -help'\n", argv[0]);
			return set_result;
		}
	}

	// Checking arguments
	if ((set_result = CheckArgumentCombination(set)) != 0)
		return set_result;

	// Setting Keys
	if ((set_result = SetKeys(&set->common.keys)) != 0)
		return set_result;

	// Generating outpath if required
	if (!set->common.outFileName) {
		char *source_path = NULL;
		if (set->ncch.buildNcch0)
			source_path = set->common.rsfPath;
		else if (set->common.workingFileType == infile_ncsd || set->common.workingFileType == infile_cia || set->common.workingFileType == infile_srl)
			source_path = set->common.workingFilePath;
		else
			source_path = set->common.contentPath[0];
		set->common.outFileName_mallocd = true;
		set->common.outFileName = replace_filextention(source_path, GetOutputExtention(set->common.outFormat));
	}
	return 0;
}
Esempio n. 6
0
File: BAM.CPP Progetto: mhjlam1/bam
int
main(int argc, char** argv)
{
   char     mess[100], *string1;
   uint16  	saverResult;
	int		loop1, loop2, framesRun, framesPerSec = 0;
	bool		fWaitToSend;
   BAM_WorldEnderPopup     *pWEPop;
	FILE	*pFile;

//	Nothing		*pNothing1 = new Nothing;
//	NothingMore	*pNothingMore1 = new NothingMore;
//	Dummy			*pDummy1 = new Dummy(0x1234);

//	pNothing1->SetValue(0x1234);
//	pNothingMore1->SetValue(0x5678);
//	pDummy1->SetValue(0x90ab);

// Unit	*pUnit = new Unit(TRUE);
//	Unit	unit1(TRUE);

/*	Jay - here's the code for the test case you said you wanted to try next:

	pFile = fopen("unit1.dat", "wb");
	fwrite(&unit1, 1, sizeof(unit1), pFile);
	fclose(pFile);
*/
	
/*
	pFile = fopen("unit1.dat", "rb");
	fread(&unit1, 1, sizeof(unit1), pFile);
	fclose(pFile);
*/

	time_t	startTime, timeDif, lastTime;
	time(&startTime);
	lastTime = startTime;

	// disable critical error handler
	_harderr(critical_error_handler);

	AInitializePlatform();

	#ifndef NDEBUG
	printf("\n\n&ReportFreeMem==0x%08X\n", (int)ReportFreeMem);
	#endif

#ifdef OS_DOS
	printf("\nBLOOD & MAGIC Copyright (C) 1996 by Tachyon Studios Inc..\n");
	printf("Developed by Tachyon Studios for Interplay Productions.\n");
   printf("BLOOD & MAGIC, FORGOTTEN REALMS and the TSR LOGO are Trademarks\n");
	printf("owned by TSR, Inc and are used under license.\n");
	printf("\nCompiled %s %s\n", __DATE__, __TIME__);
	printf("%dk free after platform initialization\n", AAvailMem() / 1024);

	if(AAvailMem() < MIN_MEM_REQ)
	{
		printf("\nWARNING: Free XMS memory is low (<%dk)!\nBAM may not run reliably\n",
			MIN_MEM_REQ / 1000);
		sleep(4);
	}

#endif

	// short-circuit any command line args
	//	argc = 1;

	if(argc > 1 && (!memcmp(argv[1], "?", 2) || !memcmp(argv[1], "-HELP", 6)))
	{
//		printf("Format: BAM [mapNum] [-NOINTRO] [-NOFOG] [-SIDEx] [-NOWIN] [-NET] [-SHOWOFF]\n");
		return(0);
	}

	// if the seed is the same, the sequence will repeat. cool!
//	ASeedRandom(41);			// for repeatability of bugs
//	ASeedRandom2(41);			// for repeatability of bugs
	ASeedRandom(startTime);	// for genuine randomness
	ASeedRandom2(startTime);	// for genuine randomness

	// If you ever don't want to see unfreed memory, like for demos,
	// then uncomment this.
//	extern bool	fPrintUnfreedPtrs;
//	fPrintUnfreedPtrs = FALSE;

	TRACK_MEM("Mono");			pMono = new Mono;
	// if we really must allocate this on the fly instead of
	// having it global, then we must tell the memmgr not to save it.
	ASetSaveStatus(AGetGrip(pMono), FALSE);
	// also, we don't want this to be purged on a restore.
	ASetPurgeStatus(AGetGrip(pMono), FALSE);

	pMono->SetWindow(0, 7, 79, 12);
	pMono->Clear();
	pMono->Out("Monochrome output initialized\n");

	#ifndef NDBEUG
	pMono->Out("&ReportFreeMem==0x%08X\n", (int)ReportFreeMem);
	sleep(4);
	#endif

	pMono->Out("EventMgr initializing\n");
	TRACK_MEM("EventMgr");		new EventMgr;
	// we are going to update ticks when we want to.
	AAutoUpdateTicks(FALSE);

	pMono->Out("ContextMgr initializing\n");
	TRACK_MEM("ContextMgr");	new ContextMgr;
	pMono->Out("ResMgr initializing\n");
	TRACK_MEM("ResMgr");			new ResourceMgr(TRUE);

	// NOTE - IT IS HIGHLY RECOMMENDED THAT YOU INIT THE SOUND MANAGER
	// BEFORE THE GRAPH MANAGER.  If you don't, streamed sounds will
	// stop and start during restore because of the busy loop in graph
	// manager that happens when the palette fades up.
	pMono->Out("SoundMgr initializing\n");
	TRACK_MEM("SndMgr");	new SoundMgr;
	pSoundMgr->Init();

	// BUGBUG! If we bind w/ DOS4GW/Pro we will crash here!
	//setup smacker sound stuff
	SmackSoundUseSOS3((u16)pSoundMgr->hDigiDriverHandle,0);

	pMono->Out("GraphMgr initializing\n");
	TRACK_MEM("GraphMgr");		pGraphMgr = new GraphicsMgr(MODEX_320X400);

	pMono->Out("%dk free after platform initialization\n", AAvailMem() / 1024);

//	Debugger debug1, debug2;

//	debug1.OpenWindow(0, 0, 79, 10);
//	debug2.OpenWindow(40, 11, 79, 21);
//	for(loop1 = 0; loop1 < 25; loop1++)
//	{
//		pMono->Out("\n%d", loop1);
//	}
//	sleep(2);

	TRACK_MEM("FontMgr");		pFontMgr = new FontMgr;
	// default font
	pFontMgr->SetRes(9050);
	// default font  color
	pFontMgr->ForeColor(TEXT_DEFAULT);
	pFontMgr->colors[FNT_BACK_COLOR] = CI_SKIP;

	#ifdef OS_MAC
//		#include "menubar.hpp"
//		DS9MenuBar*	pMenuBar;
//		TRACK_MEM("menuBar");	pMenuBar = new DS9MenuBar;

		TRACK_MEM("Mouse");	new Mouse;
	#else

		TRACK_MEM("Mouse");	new MouseInt;
	#endif

	if(pMouse->hideCount == 999)
	{
		// init error
		ShutDownSoundMgr();
		APrintUnfreedPtrs(FALSE);
		exit(1);
	}
	pMouse->Init(0,0,SCREEN_WIDTH-1,SCREEN_HEIGHT-1);
	pMouse->SetRes(RES_ANIM, POINTER_RES, 1);
	pMouse->Hide(); //let bamroom show it at room change time.

	// this is our global data saver
	AtSave(GlobalSave);

	// create the application instance
	TRACK_MEM("BAM App");
	pBam = new BAM_Application;
	bGlobal.gBam = pBam->gSelf;
	pBam->msgMask = E_MOUSE_DOWN | E_MOUSE_UP | E_KEY_DOWN;

	// command-line options parsed here
	memcpy(pBam->scenarioName, "9110", 5);	// default scenario
	pBam->fNoIntro = FALSE;
	pBam->fDefaultScenario = FALSE;
	pBam->fUseFog = TRUE;
	pBam->fUseWinLose = TRUE;
	pBam->playerSide = SIDE1;
	pBam->fMapEdit = FALSE;
	pBam->playerTypes[SIDE0] = PLAYER_NONE;
	pBam->playerTypes[SIDE1] = PLAYER_LOCAL;
	pBam->playerTypes[SIDE2] = PLAYER_NONE;
	pBam->playerTypes[SIDE3] = PLAYER_NONE;
	pBam->playerTypes[SIDE4] = PLAYER_NONE;

	{
		FILE	*pPentiumFile;

		pPentiumFile = fopen("PENTIUM.VAN", "rb");
		if(pPentiumFile)
		{
			fclose(pPentiumFile);
			fPentium = TRUE;
		}
	}

	for(loop1 = 1; loop1 < argc; loop1++)
	{
		strcpy(mess, argv[loop1]);
		string1 = mess;
		do
		{
			*string1 = (char) toupper(*string1);
			string1++;
		}	while(*string1);

		if(mess[0] == '-')
		{
//			#ifdef ENABLE_EDITOR
//			if(!memcmp(mess, "-EDIT", 5))				// turn on edit mode
//				pBam->fMapEdit = TRUE;
//			#endif
			
			if(!memcmp(mess, "-NOINTRO", 9))		// turn off opening cinematic
				pBam->fNoIntro = TRUE;
			else if(!memcmp(mess, "-NOWIN", 6))	// turn on win/lose conditions
				pBam->fUseWinLose = FALSE;
			else if(!memcmp(mess, "-NOFOG", 6))		// turn off fog
				pBam->fUseFog = FALSE;
			else if(!memcmp(mess, "-NET", 4))		// network play
			{
				pBam->fNetworkTest = TRUE;
				bGlobal.storyLine = NETGAME;
				ASeedRandom(42);	// need sync'ed RNGs
			}
			else if(!memcmp(mess, "-PENTIUM", 8))
			{
				fPentium = TRUE;
			}
			else if(!memcmp(mess, "-MUSIC", 6))
			{
				bGlobal.altMusicNum = atoi(mess + 6);
			}
			else if(!memcmp(mess, "-AIUNITS", 8))
			{
				bGlobal.aiUnitMultiplier = atoi(mess + 8);
			}
			else if(!memcmp(mess, "-AI", 3))
			{
				bGlobal.aiOveride = atoi(mess + 3);
			}
			else if(!memcmp(mess, "-FRENCH", 7))
			{
				SetLanguage(LANG_FRENCH);
			}
			else if(!memcmp(mess, "-GERMAN", 7))
			{
				SetLanguage(LANG_GERMAN);
			}
			else if(!memcmp(mess, "-ENGLISH", 8))
			{
				SetLanguage(LANG_ENGLISH);
			}
			else if(!memcmp(mess, "-SHOWOFF", 8))	// storefront demo mode
			{
				bGlobal.storyLine = SHOW_OFF;
			}
			else if(!memcmp(mess, "-HACKRES", 8))	// allow single resource replacement
			{
				pResMgr->fSearchStuffsFirst = FALSE;
			}
			else if(!memcmp(mess, "-SIDE", 5))	// set player side (1 or 2)
			{
				switch(mess[5])
				{
					case '0':
						pBam->playerSide = SIDE0;
						pBam->playerTypes[SIDE1] = PLAYER_NONE;
						pBam->playerTypes[SIDE2] = PLAYER_NONE;
						break;

					case '1':
						pBam->playerSide = SIDE1;
						pBam->playerTypes[SIDE1] = PLAYER_LOCAL;
						pBam->playerTypes[SIDE2] = PLAYER_NONE;
						break;

					case '2':
						pBam->playerSide = SIDE2;
						pBam->playerTypes[SIDE1] = PLAYER_NONE;
						pBam->playerTypes[SIDE2] = PLAYER_LOCAL;
						break;

					default:
						pMono->Out("Invalid option to command line arg -SIDEx\n");
						break;
				}
			}
		}
		else if(atoi(argv[loop1]))
		{
			memcpy(pBam->scenarioName, argv[loop1], 8);
			pBam->fDefaultScenario = TRUE;
		}
	}

	#ifdef ENABLE_EDITOR
	if(pBam->fMapEdit)				// if editor mode, then turn off fog
		pBam->fUseFog = FALSE;
		pBam->fShowTileNums = TRUE;
	#endif

	// initialize game start, 
	pBam->Activate(TRUE);

	pContextMgr->msgMask = E_MOUSE_DOWN | E_MOUSE_UP | E_KEY_DOWN;

	#ifdef COUNT_FRAMES
		FrameCounter	fps;
	#endif // COUNT_FRAMES

	TRACK_MEM("TCommMgr");		new TCommMgr;

	if(pBam->fNetworkTest)	// if set up network from command line
	{
//		TNetwork			*pComm;
//		TModem			*pComm;
		TComm::ERROR	errVal;
		int	int1;

//		pMono->Out("New TCommMgr\n");
//		TRACK_MEM("TCommMgr");		pCommMgr = new TCommMgr;	//it isn't an object -no gSelf

		TRACK_MEM("TNetwork");		pComm = new TNetwork;
//		pComm = new TModem;
//		((TModem*) pComm)->SetPort(3);
//		((TModem*) pComm)->SetBaud(19200);

		#ifdef OS_MAC
		int	commInitArg = 0;	// ignored by DOS/TIGRE
			// player 1 is caller, player two is listener
			// at least for now, using command line args to specify direction
			if (pBam->playerTypes[SIDE1] == PLAYER_LOCAL)
			{
				commInitArg = TCommMacintosh::kATalkCaller;
			}
			else
			{
				commInitArg = TCommMacintosh::kATalkListener;
			}
			pCommMgr->Init(pComm, commInitArg);
		#else
			pCommMgr->SetUserAbortFn ((pIntFnInt) CycleConnection);
			pCommMgr->Init(pComm);
		#endif

		pMono->Out("Attempting connection...\n");
		int1 = (int)pCommMgr->Connect();
		errVal = (TComm::ERROR)int1;

		if(errVal != TComm::ALL_OK)
		{
			pMono->Out("Main() - error, commMgr->Connect() failed\n");
			sleep(1);
			pBam->fNetworkTest = FALSE;
		}
		else
		{
			pMono->Out("Main() - connection established\n");
			pBam->playerTypes[(pBam->playerSide == SIDE1)? SIDE2: SIDE1] = pCommMgr->GetUserID();
			pMono->Out("User ID==%d\n", pCommMgr->GetUserID());
//			sleep(2);
		}
	}

	pMono->Out("TIGRE engine initialized\n");
	ReportFreeMem();

	// side1 and side2 MUST have a player setting of some kind
	if(pBam->playerTypes[SIDE1] == PLAYER_NONE)
		pBam->playerTypes[SIDE1] = PLAYER_COMPUTER;
	if(pBam->playerTypes[SIDE2] == PLAYER_NONE)
		pBam->playerTypes[SIDE2] = PLAYER_COMPUTER;

	// initial room
	if(pBam->fDefaultScenario)
	{
		SetDefaults(pBam->scenarioName);
		bGlobal.roomMgr.NewRoom(BR_WORLD);			// skip everything, go to game
	}
	else if(bGlobal.storyLine == SHOW_OFF)
	{
		bGlobal.roomMgr.NewRoom(BR_WORLD);			// skip everything, go to game
	}
	else if(pBam->fNoIntro)
		bGlobal.roomMgr.NewRoom(BR_MENU);			// skip intro, go to story selector
	else bGlobal.roomMgr.NewRoom(BR_CINE);		// skip nothing

	bGlobal.roomMgr.CheckRoomChange();

	#ifdef OS_MAC
		#include "menubar.hpp"
		DS9MenuBar *pMenuBar;
		TRACK_MEM("menuBar");	MenuBar.Init();
	#endif
	
	ticks_t	currTicks = ATicks();
	int		snapShot = 0;

	// anti-piracy stuff 
	pFile = fopen("HMICARDS.386", "rb");
	if(!pFile)
		bGlobal.antiPiracyCrashFlag &= 0xFFFFF0FF;
	else
	{
		for(loop1 = 0; loop1 < 5; loop1++)
		{
			char string1[128];
			unsigned long lineCheck1, lineCheck2;

			fread(string1, 32, 1, pFile);								// camoflage string
			fread(string1, 128, 1, pFile);							// encrypted string
			fread(&lineCheck1, sizeof(lineCheck1), 1, pFile);		// line checksum

			// verify checksum
			for(lineCheck2 = 0, loop2 = 0; loop2 < 128; loop2++)
				lineCheck2 = lineCheck2 + string1[loop2];
			lineCheck2 ^= 0xF61E22C9;
			if(lineCheck1 != lineCheck2)
			{
				// failure - set the delayed crash flag
				fclose(pFile);
				bGlobal.antiPiracyCrashFlag &= 0xFFFFF0FF;
			}
		}
		fclose(pFile);
	}

	//=======================================================================
	//MAIN GAME LOOP
	//=======================================================================

	ReportFreeMem();

	enum timerTags {TIMER_CYC_PER_FRAME = 0, TIMER_UPDATE_TICKS, TIMER_CONTEXT_CYCLE,
		TIMER_ANIMATE, TIMER_SYNC_SEND, TIMER_SYNC_RECV, TIMER_MAX};
	DebugTimer	timers[TIMER_MAX];

	while (!pContextMgr->fQuitting)
	{
		#ifndef NDEBUG
		timers[TIMER_CYC_PER_FRAME].Start();
		#endif

		#ifdef DEBUG_BIG_NET
			pMono->Out("main loop()..");
		#endif

		// our own exceptional ptrs
		pBam = ADerefAs(BAM_Application, bGlobal.gBam);
		if (bGlobal.gWorld)
		{
			pWorld = ADerefAs(World, bGlobal.gWorld);
		}
		else
		{
			pWorld = NULL;
		}

		#ifdef DEBUG_BIG_NET
			pMono->Out("roomMgr.cycle()..");
		#endif
		bGlobal.roomMgr.Cycle();

		//fps.Count();

		#ifdef DEBUG_BIG_NET
			pMono->Out("memMgr.cycle()..");
		#endif
		pMemMgr->Cycle();
		
		#ifndef OLD_MOUSE_INTERRUPT_HANDLER
      //
      // MDB - Modified the mouse interrupt handler.
      //
      MouseHandler( FALSE );
		#endif

		#ifndef NDEBUG
		//mem_check();
		#endif

		#ifdef DEBUG_BIG_NET
			pMono->Out("roomMgr.CheckRoomChange()..");
		#endif
		bGlobal.roomMgr.CheckRoomChange();

		#ifndef OLD_MOUSE_INTERRUPT_HANDLER
      //
      // MDB - Modified the mouse interrupt handler.
      //
      MouseHandler( FALSE );
		#endif

		//if snap is on lets handle tick updates ourself	
		if(bGlobal.gSnap && pSnap->snapOn)
		{
			//if snap just toggled on
			if(!snapShot)
			{
				snapShot++;
				currTicks = ATicks();
			}
			else
			{
				currTicks += 2;
			}
			ASetTicks(currTicks);
		}
		else
		{
			snapShot = 0;	//reset

			#ifdef DEBUG_BIG_NET
				pMono->Out("EventMgr->Publish()..");
			#endif

			// add local actions to actionPool2
			pEventMgr->PublishNext();

			#ifndef OLD_MOUSE_INTERRUPT_HANDLER
	      //
   	   // MDB - Modified the mouse interrupt handler.
      	//
	      MouseHandler( FALSE );
			#endif

			if(pWorld)
			{
				// wait for next tick to occur, because otherwise there's no point.
				// note: UpdateTicks() cannot be trusted to change, in case of Pause()

				currTicks = ATicks();
//				#ifndef NDEBUG
//				BamDebug.Out("main() - update tick counter (curr=%d)\n",
//					currTicks);
//				#endif
				#ifndef NDEBUG	
				timers[TIMER_UPDATE_TICKS].Start();
				#endif
				UpdateTicks();

				// did the tick counter fail to increment?
				if(ATicks() == currTicks)
				{
					// loop on clock() delta, then resume.  A tick will have changed by
					// then or else we're in Pause() mode, so who cares.

					clock_t	currClock = clock();
					while(currClock == clock())
					{
						#ifndef OLD_MOUSE_INTERRUPT_HANDLER
				      MouseHandler( FALSE );
						#endif
					};

					// try again - if it fails again, assume Pause() and don't worry
					UpdateTicks();
				}

				// if we skipped over a tick somehow..
				if(ATicks() > currTicks + 1)
				{					
//					#ifndef NDEBUG
//					BamDebug.Out("main() WARNING: ATicks() advanced by %d! - retarding\n",
//						ATicks() - currTicks);
//					#endif

					// dont allow the tick counter to increment by more than 1
					// tick per frame, or we may get out of sync with the
					// remote machine
					ASetTicks(currTicks + 1);
				}
				#ifndef NDEBUG
				timers[TIMER_UPDATE_TICKS].Stop();
				#endif

//				#ifndef NDEBUG
//				BamDebug.Out("ATicks() == %d\n", ATicks());
//				#endif

				// sync1 - send actionPool2 to remote
				#ifndef NDEBUG
				timers[TIMER_SYNC_SEND].Start();
				#endif

				fWaitToSend = FALSE;
				if(pCommMgr && pCommMgr->totalPacketsWaiting)
					fWaitToSend = TRUE;

				if(!pWorld->SyncSend())
				{
					#ifndef OLD_MOUSE_INTERRUPT_HANDLER
			      MouseHandler( FALSE );
					#endif
					//pWorld->AITakeOver();
					if(!pBam->fWorldEnderPopupExists)
					{
						TRACK_MEM("BAM_WorldEnderPopup");       pWEPop = new BAM_WorldEnderPopup;
						pWEPop->Setup();
						pBam->fWorldEnderPopupExists = TRUE;
					}
				}
				#ifndef NDEBUG
				timers[TIMER_SYNC_SEND].Stop();
				#endif

				// process actionPool1
				pWorld->ProcessActions();
				#ifndef OLD_MOUSE_INTERRUPT_HANDLER
		      MouseHandler( FALSE );
				#endif
			}
			else
			{
				#ifndef NDEBUG
				timers[TIMER_UPDATE_TICKS].Start();
				#endif

				UpdateTicks();
				#ifndef NDEBUG
				timers[TIMER_UPDATE_TICKS].Stop();
				#endif
			}

			if(bGlobal.storyLine == NETGAME && !bGlobal.netDisconnect)
			{
				pCommMgr->EnQueueData();
				#ifndef OLD_MOUSE_INTERRUPT_HANDLER
		      MouseHandler( FALSE );
				#endif
			}
		}

		#ifdef DEBUG_BIG_NET
			pMono->Out("contextMgr.cycle()..");
		#endif
		#ifndef NDEBUG
		timers[TIMER_CONTEXT_CYCLE].Start();
		#endif
		pContextMgr->Cycle();
		#ifndef NDEBUG
		timers[TIMER_CONTEXT_CYCLE].Stop();
		#endif
		#ifndef OLD_MOUSE_INTERRUPT_HANDLER
      MouseHandler( FALSE );
		#endif

		if(bGlobal.storyLine == NETGAME && !bGlobal.netDisconnect)
		{
			pCommMgr->EnQueueData();
			#ifndef OLD_MOUSE_INTERRUPT_HANDLER
	      MouseHandler( FALSE );
			#endif
		}

		#ifdef DEBUG_BIG_NET
		pMono->Out("GraphMgr->Animate()..");
		#endif
		#ifndef NDEBUG
		timers[TIMER_ANIMATE].Start();
		#endif
		pGraphMgr->Animate();
		#ifndef NDEBUG
		timers[TIMER_ANIMATE].Stop();
		#endif

		#ifndef OLD_MOUSE_INTERRUPT_HANDLER
      MouseHandler( FALSE );
		#endif

		if(bGlobal.storyLine == NETGAME && !bGlobal.netDisconnect)
		{
			pCommMgr->EnQueueData();
			#ifndef OLD_MOUSE_INTERRUPT_HANDLER
   	   MouseHandler( FALSE );
			#endif
		}

		#ifdef DEBUG_BIG_NET
			pMono->Out("soundMgr.cycle()..");
		#endif
		pSoundMgr->Cycle();

		// current frame now done

		// gather cmds from remote for next frame, then prepare to run it
		if(pWorld)
		{
			pWorld->currFrame++;

			// sync2 - add remote actions to local actions in actionPool2
			#ifndef NDEBUG
			timers[TIMER_SYNC_RECV].Start();
			#endif
			if(!pWorld->SyncReceive())
			{
				#ifndef OLD_MOUSE_INTERRUPT_HANDLER
   		   MouseHandler( FALSE );
				#endif
				//pWorld->AITakeOver();
				if(!pBam->fWorldEnderPopupExists)
				{
					TRACK_MEM("BAM_WorldEnderPopup");       pWEPop = new BAM_WorldEnderPopup;
					pWEPop->Setup();
					pBam->fWorldEnderPopupExists = TRUE;
				}
			}

			// sync3 - swap action pools
			pWorld->SwapActionPools();
			#ifndef NDEBUG
			timers[TIMER_SYNC_RECV].Stop();
			#endif
		}

		if(bGlobal.gSnap && pSnap->snapOn)
		{
			pSnap->SnapScreen();
		}

		if(netRestoreNum || netSaveNum)
		{
			//this means we're in a netgame save or restore
			//we don't run the eventmgr to keep both sides in sync
			//and we set the restore number here, after the context cycle,
			//to insure the otherside has had time to be notified of this
			if(netRestoreNum)
				restoreNum = netRestoreNum;	//our one net save game

			if(netSaveNum)
			{
				saveNum = netSaveNum;
				netSerialNum = ARandom(99999);
				sprintf(saveMessage,"%d",netSerialNum);
			}
		}

      if (saveNum)
      {
         pMemMgr->Dump((uint16) (100 + saveNum), "Save Dump", TRUE);
         saverResult = saveMgr.Save((uint16) saveNum, bGlobal.versionNum,
				bGlobal.versionSubNum, bGlobal.buildID, saveMessage);
         if (saverResult)
         {
            sprintf(mess, "save failed.  error #%d", saverResult);
            APanic(mess);
         }
			netSaveNum = 0;	//reset this after save
         saveNum = 0;    
      }
      if (restoreNum)
      {
         saverResult = saveMgr.Restore((uint16) restoreNum, bGlobal.versionNum,
				bGlobal.versionSubNum, bGlobal.buildID);
         if (saverResult)
         {
//         	sprintf(mess, "restore failed.  error #%d", saverResult);
				BamDebug.Out("Restore failed!  Error %d\n", saverResult);
//         	APanic(mess);
         }
         pMemMgr->Dump((uint16) (200 + restoreNum), "Restore Dump", TRUE);
			netRestoreNum = 0;	//reset this after restore
         restoreNum = 0; 
			bGlobal.roomMgr.Cycle();

			// frantic temporary debugging measure
			pBam = ADerefAs(BAM_Application, bGlobal.gBam);
			if (bGlobal.gWorld)
			{
				pWorld = ADerefAs(World, bGlobal.gWorld);
				pWorld->Save(AFTER_RESTORE);
			}
			else
			{
				pWorld = NULL;
			}
			bGlobal.roomMgr.Cycle();
			pMemMgr->Cycle();
			pSoundMgr->Cycle();

			if(pWorld)
			{
				pBam->fPauseWorld = TRUE;	//force ResumeTicks() to be called in PauseWorld
				pWorld->Pause(FALSE, TRUE);
				pBam->PauseWorld();
			}
			else bGlobal.roomMgr.curRoom->Pause(FALSE, TRUE);
			#ifndef OLD_MOUSE_INTERRUPT_HANDLER
   	   MouseHandler( FALSE );
			#endif
      }

		if(pWorld)
			if(pBam->fPauseWorld != pWorld->fIsPaused)
				pBam->PauseWorld();

		#ifdef DEBUG_BIG_NET
			pMono->Out("main loop() done\n");
		#endif

		#ifndef NDEBUG
		timers[TIMER_CYC_PER_FRAME].Stop();
		#endif

		#ifndef NDEBUG
		pMono->SaveWindow();
		pMono->Goto(24, 1);
		pMono->Out("CpF%5d UTick%5d CmC%5d GmA%5d Tx%4d:%dp@%4db]%c Rx[%4d]",
			timers[TIMER_CYC_PER_FRAME].duration, timers[TIMER_UPDATE_TICKS].duration,
			timers[TIMER_CONTEXT_CYCLE].duration, timers[TIMER_ANIMATE].duration,
			timers[TIMER_SYNC_SEND].duration, pCommMgr->pComm->totalPacketsSent,
			pCommMgr->pComm->totalBytesSent,
			fWaitToSend? 'W': 'w', timers[TIMER_SYNC_RECV].duration);
		pMono->Goto(25, 1);
		time(&timeDif);
		if(timeDif != lastTime)
		{
			lastTime = timeDif;
			framesPerSec = AMin(framesRun, 99);
			framesRun = 0;
		}
		else framesRun++;
		timeDif -= startTime;

		pMono->Out("%05dkt %05dkl %02d:%02d:%02d %2dFPS", pMemMgr->AvailMem() / 1024,
			pMemMgr->LargestAlloc() / 1024, timeDif / 3600, (timeDif / 60) % 60,
			timeDif % 60, framesPerSec);

		if(pWorld)
		{
			pMono->Goto(25, 32);
			pMono->Out("r%d g%d 0x%08x", pWorld->tileResNum,
				ALoad(RES_TILELIB, pWorld->tileResNum),
				AGetResData(ALoad(RES_TILELIB, pWorld->tileResNum)));
		}

		pCommMgr->pComm->totalBytesSent = 0;
		pCommMgr->pComm->totalPacketsSent = 0;
		pMono->RestoreWindow();
		#endif

		#ifndef OLD_MOUSE_INTERRUPT_HANDLER
      MouseHandler( FALSE );
		#endif
	}

	//===================================
	LoadExitQuote();

	//===================================

	// get rid of our current room
	bGlobal.roomMgr.DeleteCurRoom();

	// shut down communications
	if(pCommMgr)
	{
		pCommMgr->Disconnect();
		pCommMgr->DiscardData();
		delete pCommMgr; //its destructor will delete pComm
		pCommMgr = NULL;
	}

	if(bGlobal.gSnap)
		ADelete(bGlobal.gSnap);
	ADelete(bGlobal.gBam);

	// all actors should be removed from graphmgr, do one more
	// animate to clear lists.
	pGraphMgr->Animate();

	ADelete(pContextMgr->gSelf);

//	TSound	exitSound;
//	exitSound.Play(667);
//	while(exitSound.IsPlaying())
//		pSoundMgr->Cycle();

	// storm the office!  kill all managers!
	ADelete(pGraphMgr->gSelf);
	ADelete(pFontMgr->gSelf);
	ADelete(pSoundMgr->gSelf);
	ADelete(pResMgr->gSelf);
	ADelete(pEventMgr->gSelf);
	ADelete(pMouse->gSelf);

	delete pMono;

//	DESTROY_MGR_CAREFUL(GraphicsMgr, pGraphMgr);
//	DESTROY_MGR_CAREFUL(Mono, pMono);
//	DESTROY_MGR_CAREFUL(FontMgr, pFontMgr);
//	DESTROY_MGR_CAREFUL(SoundMgr, pSoundMgr);
//	DESTROY_MGR(pResMgr);
//	DESTROY_MGR(pContextMgr);
//	DESTROY_MGR_CAREFUL(EventMgr, pEventMgr);

	#ifdef INTERACTIVE_DEMO
	DPMI dpmi;
	char *pScreen = (char *)dpmi.RealToProtected(0xB8000000);

	// kludge - remove "Installer" from data
	for(loop1 = 0; loop1 < 9; loop1++)
		MSG_DEMO_ENGL[86 + loop1 * 2] = ' ';

	memcpy(pScreen, (char *)MSG_DEMO_ENGL, 4000);
	while(!kbhit());
	getch();
	#endif
	system("mode co80");	// yeah, mega-cheesy I know.  It's a bug patch. -Van

	printf("\n%s\n",exitMessage);
	printf("%s\n",exitAuthor);

	return 0;						
}
Esempio n. 7
0
bool Params::SetParams( int argvT, char* argcT[] )
{
    string option, value;
    string::size_type i1, i2;

    string cfgfile = CONFIGFILE;
    bool showconf = false;

    SetDefaults();

    while ( --argvT )
    {
        value = *++argcT;
        i1 = value.find_first_not_of("-");

        //No GNU options
        if ( i1 == 1 )
        {
            option = value.substr(i1, 1);

            if ( option == "c" )
            {
                --argvT;

                if ( argvT == 0 )
                {
                    Usage();
                    return false;
                }
                value = *++argcT;
            }
            else if ( option == "s" ) //
            {
                showconf = true;
            }
            else
            {
                Usage();
                return false;
            }
        }
        //GNU options
        else if ( i1 == 2 )
        {
            if ( (i2 = value.find("=")) != string::npos )
            {
                option = value.substr(i1, i2 - i1);

                if ( value.size() > i2 + 1 )
                {
                    value = value.substr(i2 + 1);
                }
                else
                {
                    Usage();
                    return false;
                }
            }
            else
            {
                option = value.substr(i1);
                value = "";
            }
        }
        else
        {
            Usage();
            return false;
        }

        if ( option == "help" )
        {
            Usage();
            return false;
        }
        else if ( option == "conf-file" || option == "c" )
        {
            if (value == "")
            {
                Usage();
                return false;
            }

            cfgfile = value;
        }
        else
        {
            Usage();
            return false;
        }
    }

    if ( ReadConfig( cfgfile ) == false )
    {
        return false;
    }

    return TestConfig();
}
Esempio n. 8
0
SynfireParameters::SynfireParameters( int argc, char *argv[] ) {
    SetDefaults();

    std::string cmd;
    for (int i = 1; i < argc; ++i) {
        cmd = argv[i];

        if (cmd[0] != '-') continue;
        switch (cmd[1]) {
            case 'L': // Synapses are static
                plasticity = false;
                break;

                //OUTPUT & ANALYSIS FLAGS
            case 'd': // '-d' outputs various statistics after each trial for diagnostic purposes (i.e. spk count, avg volt, etc)
                stats_on = 1;

                //~ PARAMETER FLAGS
            case 'A': // '-A <int>' sets the numbers of trials before termination of the run (default is 200000)
                trials = atoi(argv[++i]);
                break;

            case 'C': // '-C <float>' sets the number of ms per trial (default is 2000)
                trial_duration = atof(argv[++i]);
                break;

            case 'B': // '-B <int>' sets the number of training neurons (default is 10)
                ntrain = atoi(argv[++i]);
                break;

            case 'D': // '-D <int>' sets the max number of supersynapses a neuron may have
                tempNSS = atoi(argv[++i]);
                break;

            case 'c': // '-c <double>' sets the decay rate of the synapses (default is .999996)
                syndec = atof(argv[++i]);
                break;

            case 'f': // '-f <double>' sets the fraction of synapses initially active (default is .1)
                frac = atof(argv[++i]);
                if (frac >= 1 || frac < 0) {
                    std::cerr << "Command line input -f is invalid, must be <1 and >=0" << std::endl;
                    exit(1);
                }
                break;

            case 'g': // '-g <float>' sets GLTP
                eq_syn = atof(argv[++i]);
                break;

            case 'i': // '-i <double>' sets the amplitude of the global inhibition (default is .3)
                global_i = atof(argv[++i]);
                break;

            case 'j': // '-j <float>' sets the inhibition delay
                inh_d = atof(argv[++i]);
                break;

            case 'm': // '-m <double>' sets the excitatory spontaneous frequency (default is 40Hz)
                exfreq = atof(argv[++i]);
                break;

            case 'n':// '-n <double>' sets the inhibitory spontaneous frequency (default is 200Hz)
                infreq = atof(argv[++i]);
                break;

            case 'o':// '-o <double>' sets the amplitude of the spontaneous excitation (default is 1.3)
                examp = atof(argv[++i]);
                break;

            case 'p':// '-p <double>' sets the amplitude of the spontaneous inhibition (default is .1)
                inamp = atof(argv[++i]);
                break;

            case 'q':// '-q <double>' sets the active syn threshold (default is .2)
                act = atof(argv[++i]);
                break;

            case 'r':// '-r <double>' sets the super syn threshold (default is .4)
                sup = atof(argv[++i]);
                break;

            case 's':// '-s <double>' sets the synapse maximum (default is .6)
                cap = atof(argv[++i]);
                break;

            case 'u': // '-u <double>' set maximum inhibitory synaptic strength
                isynmax = atof(argv[++i]);
                break;

            case 'x': // '-x <double>' sets spike rate of training excitation (default is 1500 Hz)
                training_f = atof(argv[++i]) * 0.001;
                //convert to (ms)^(-1)
                break;

            case 'y': // '-y <double>' sets amplitude of training excitation (default is .7)
                training_amp = atof(argv[++i]);
                break;

            case 'z': // '-z <double>' sets the training excitation duration (default is 8 ms)
                training_t = atof(argv[++i]);
                break;

            default:
                std::cout << "Warning: command line flag " << cmd << " is not recognized." << std::endl;
                break;
        }
    }
}
Esempio n. 9
0
/// Node + Model (static or animated)
ModelImporter::ModelImporter(Context* context, Asset *asset) : AssetImporter(context, asset)
{
    SetDefaults();
}
Esempio n. 10
0
//------------------------------------------------------
CRectTracker::CRectTracker( POINT const& Begin, POINT const& End )
{
    SetDefaults();
    CurPos.Begin = Begin;
    CurPos.End = End;
};
Esempio n. 11
0
SynfireParameters::SynfireParameters() {
    SetDefaults();
}
Esempio n. 12
0
//------------------------------------------------------
CRectTracker::CRectTracker()
{
    SetDefaults();
    ZeroMemory(&CurPos.Begin, sizeof(POINT));
    ZeroMemory(&CurPos.End, sizeof(POINT));
};
Esempio n. 13
0
GridFrame::GridFrame()
        : wxFrame( (wxFrame *)NULL, wxID_ANY, _T("wxWidgets grid class demo"),
                   wxDefaultPosition,
                   wxDefaultSize )
{
    wxMenu *fileMenu = new wxMenu;
    fileMenu->Append( ID_VTABLE, _T("&Virtual table test\tCtrl-V"));
    fileMenu->Append( ID_BUGS_TABLE, _T("&Bugs table test\tCtrl-B"));
    fileMenu->Append( ID_SMALL_GRID, _T("&Small Grid test\tCtrl-S"));
    fileMenu->AppendSeparator();
    fileMenu->Append( wxID_EXIT, _T("E&xit\tAlt-X") );

    wxMenu *viewMenu = new wxMenu;
    viewMenu->Append( ID_TOGGLEROWLABELS,  _T("&Row labels"), wxEmptyString, wxITEM_CHECK );
    viewMenu->Append( ID_TOGGLECOLLABELS,  _T("&Col labels"), wxEmptyString, wxITEM_CHECK );
    viewMenu->Append( ID_TOGGLEEDIT,  _T("&Editable"), wxEmptyString, wxITEM_CHECK );
    viewMenu->Append( ID_TOGGLEROWSIZING, _T("Ro&w drag-resize"), wxEmptyString, wxITEM_CHECK );
    viewMenu->Append( ID_TOGGLECOLSIZING, _T("C&ol drag-resize"), wxEmptyString, wxITEM_CHECK );
    viewMenu->Append( ID_TOGGLECOLMOVING, _T("Col drag-&move"), wxEmptyString, wxITEM_CHECK );
    viewMenu->Append( ID_TOGGLEGRIDSIZING, _T("&Grid drag-resize"), wxEmptyString, wxITEM_CHECK );
    viewMenu->Append( ID_TOGGLEGRIDDRAGCELL, _T("&Grid drag-cell"), wxEmptyString, wxITEM_CHECK );
    viewMenu->Append( ID_TOGGLEGRIDLINES, _T("&Grid Lines"), wxEmptyString, wxITEM_CHECK );
    viewMenu->Append( ID_SET_HIGHLIGHT_WIDTH, _T("&Set Cell Highlight Width...") );
    viewMenu->Append( ID_SET_RO_HIGHLIGHT_WIDTH, _T("&Set Cell RO Highlight Width...") );
    viewMenu->Append( ID_AUTOSIZECOLS, _T("&Auto-size cols") );
    viewMenu->Append( ID_CELLOVERFLOW, _T("&Overflow cells"), wxEmptyString, wxITEM_CHECK );
    viewMenu->Append( ID_RESIZECELL, _T("&Resize cell (7,1)"), wxEmptyString, wxITEM_CHECK );

    wxMenu *rowLabelMenu = new wxMenu;

    viewMenu->Append( ID_ROWLABELALIGN, _T("R&ow label alignment"),
                      rowLabelMenu,
                      _T("Change alignment of row labels") );

    rowLabelMenu->Append( ID_ROWLABELHORIZALIGN, _T("&Horizontal") );
    rowLabelMenu->Append( ID_ROWLABELVERTALIGN, _T("&Vertical") );

    wxMenu *colLabelMenu = new wxMenu;

    viewMenu->Append( ID_COLLABELALIGN, _T("Col l&abel alignment"),
                      colLabelMenu,
                      _T("Change alignment of col labels") );

    colLabelMenu->Append( ID_COLLABELHORIZALIGN, _T("&Horizontal") );
    colLabelMenu->Append( ID_COLLABELVERTALIGN, _T("&Vertical") );

    wxMenu *colMenu = new wxMenu;
    colMenu->Append( ID_SETLABELCOLOUR, _T("Set &label colour...") );
    colMenu->Append( ID_SETLABELTEXTCOLOUR, _T("Set label &text colour...") );
    colMenu->Append( ID_SETLABEL_FONT, _T("Set label fo&nt...") );
    colMenu->Append( ID_GRIDLINECOLOUR, _T("&Grid line colour...") );
    colMenu->Append( ID_SET_CELL_FG_COLOUR, _T("Set cell &foreground colour...") );
    colMenu->Append( ID_SET_CELL_BG_COLOUR, _T("Set cell &background colour...") );

    wxMenu *editMenu = new wxMenu;
    editMenu->Append( ID_INSERTROW, _T("Insert &row") );
    editMenu->Append( ID_INSERTCOL, _T("Insert &column") );
    editMenu->Append( ID_DELETEROW, _T("Delete selected ro&ws") );
    editMenu->Append( ID_DELETECOL, _T("Delete selected co&ls") );
    editMenu->Append( ID_CLEARGRID, _T("Cl&ear grid cell contents") );

    wxMenu *selectMenu = new wxMenu;
    selectMenu->Append( ID_SELECT_UNSELECT, _T("Add new cells to the selection"),
                        _T("When off, old selection is deselected before ")
                        _T("selecting the new cells"), wxITEM_CHECK );
    selectMenu->Append( ID_SHOW_SELECTION,
                        _T("&Show current selection\tCtrl-Alt-S"));
    selectMenu->AppendSeparator();
    selectMenu->Append( ID_SELECT_ALL, _T("Select all"));
    selectMenu->Append( ID_SELECT_ROW, _T("Select row 2"));
    selectMenu->Append( ID_SELECT_COL, _T("Select col 2"));
    selectMenu->Append( ID_SELECT_CELL, _T("Select cell (3, 1)"));
    selectMenu->AppendSeparator();
    selectMenu->Append( ID_DESELECT_ALL, _T("Deselect all"));
    selectMenu->Append( ID_DESELECT_ROW, _T("Deselect row 2"));
    selectMenu->Append( ID_DESELECT_COL, _T("Deselect col 2"));
    selectMenu->Append( ID_DESELECT_CELL, _T("Deselect cell (3, 1)"));
    wxMenu *selectionMenu = new wxMenu;
    selectMenu->Append( ID_CHANGESEL, _T("Change &selection mode"),
                      selectionMenu,
                      _T("Change selection mode") );

    selectionMenu->Append( ID_SELCELLS, _T("Select &Cells") );
    selectionMenu->Append( ID_SELROWS, _T("Select &Rows") );
    selectionMenu->Append( ID_SELCOLS, _T("Select C&ols") );


    wxMenu *helpMenu = new wxMenu;
    helpMenu->Append( wxID_ABOUT, _T("&About wxGrid demo") );

    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append( fileMenu, _T("&File") );
    menuBar->Append( viewMenu, _T("&View") );
    menuBar->Append( colMenu,  _T("&Colours") );
    menuBar->Append( editMenu, _T("&Edit") );
    menuBar->Append( selectMenu, _T("&Select") );
    menuBar->Append( helpMenu, _T("&Help") );

    SetMenuBar( menuBar );

    m_addToSel = false;

    grid = new wxGrid( this,
                       wxID_ANY,
                       wxPoint( 0, 0 ),
                       wxSize( 400, 300 ) );

#if wxUSE_LOG
    int gridW = 600, gridH = 300;
    int logW = gridW, logH = 100;

    logWin = new wxTextCtrl( this,
                             wxID_ANY,
                             wxEmptyString,
                             wxPoint( 0, gridH + 20 ),
                             wxSize( logW, logH ),
                             wxTE_MULTILINE );

    logger = new wxLogTextCtrl( logWin );
    m_logOld = wxLog::SetActiveTarget( logger );
    wxLog::SetTimestamp( NULL );
#endif // wxUSE_LOG

    // this will create a grid and, by default, an associated grid
    // table for strings
    grid->CreateGrid( 0, 0 );
    grid->AppendRows(100);
    grid->AppendCols(100);

    int ir = grid->GetNumberRows();
    grid->DeleteRows(0, ir);
    grid->AppendRows(ir);

    grid->SetRowSize( 0, 60 );
    grid->SetCellValue( 0, 0, _T("Ctrl+Home\nwill go to\nthis cell") );

    grid->SetCellValue( 0, 1, _T("A long piece of text to demonstrate wrapping.") );
    grid->SetCellRenderer(0 , 1, new wxGridCellAutoWrapStringRenderer);
    grid->SetCellEditor( 0,  1 , new wxGridCellAutoWrapStringEditor);

    grid->SetCellValue( 0, 2, _T("Blah") );
    grid->SetCellValue( 0, 3, _T("Read only") );
    grid->SetReadOnly( 0, 3 );

    grid->SetCellValue( 0, 4, _T("Can veto edit this cell") );

    grid->SetCellValue( 0, 5, _T("Press\nCtrl+arrow\nto skip over\ncells") );

    grid->SetRowSize( 99, 60 );
    grid->SetCellValue( 99, 99, _T("Ctrl+End\nwill go to\nthis cell") );
    grid->SetCellValue( 1, 0, _T("This default cell will overflow into neighboring cells, but not if you turn overflow off."));

    grid->SetCellTextColour(1, 2, *wxRED);
    grid->SetCellBackgroundColour(1, 2, *wxGREEN);

    grid->SetCellValue( 1, 4, _T("I'm in the middle"));

    grid->SetCellValue(2, 2, _T("red"));

    grid->SetCellTextColour(2, 2, *wxRED);
    grid->SetCellValue(3, 3, _T("green on grey"));
    grid->SetCellTextColour(3, 3, *wxGREEN);
    grid->SetCellBackgroundColour(3, 3, *wxLIGHT_GREY);

    grid->SetCellValue(4, 4, _T("a weird looking cell"));
    grid->SetCellAlignment(4, 4, wxALIGN_CENTRE, wxALIGN_CENTRE);
    grid->SetCellRenderer(4, 4, new MyGridCellRenderer);

    grid->SetCellValue(3, 0, _T("0"));
    grid->SetCellRenderer(3, 0, new wxGridCellBoolRenderer);
    grid->SetCellEditor(3, 0, new wxGridCellBoolEditor);

    wxGridCellAttr *attr;
    attr = new wxGridCellAttr;
    attr->SetTextColour(*wxBLUE);
    grid->SetColAttr(5, attr);
    attr = new wxGridCellAttr;
    attr->SetBackgroundColour(*wxRED);
    grid->SetRowAttr(5, attr);

    grid->SetCellValue(2, 4, _T("a wider column"));
    grid->SetColSize(4, 120);
    grid->SetColMinimalWidth(4, 120);

    grid->SetCellTextColour(5, 8, *wxGREEN);
    grid->SetCellValue(5, 8, _T("Bg from row attr\nText col from cell attr"));
    grid->SetCellValue(5, 5, _T("Bg from row attr Text col from col attr and this text is so long that it covers over many many empty cells but is broken by one that isn't"));

    grid->SetColFormatFloat(6);
    grid->SetCellValue(0, 6, _T("3.1415"));
    grid->SetCellValue(1, 6, _T("1415"));
    grid->SetCellValue(2, 6, _T("12345.67890"));

    grid->SetColFormatFloat(7, 6, 2);
    grid->SetCellValue(0, 7, _T("3.1415"));
    grid->SetCellValue(1, 7, _T("1415"));
    grid->SetCellValue(2, 7, _T("12345.67890"));

    const wxString choices[] =
    {
        _T("Please select a choice"),
        _T("This takes two cells"),
        _T("Another choice"),
    };
    grid->SetCellEditor(4, 0, new wxGridCellChoiceEditor(WXSIZEOF(choices), choices));
    grid->SetCellSize(4, 0, 1, 2);
    grid->SetCellValue(4, 0, choices[0]);
    grid->SetCellOverflow(4, 0, false);

    grid->SetCellSize(7, 1, 3, 4);
    grid->SetCellAlignment(7, 1, wxALIGN_CENTRE, wxALIGN_CENTRE);
    grid->SetCellValue(7, 1, _T("Big box!"));

    wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
    topSizer->Add( grid,
                   1,
                   wxEXPAND );

#if wxUSE_LOG
    topSizer->Add( logWin,
                   0,
                   wxEXPAND );
#endif // wxUSE_LOG

    SetAutoLayout(true);
    SetSizer( topSizer );

    topSizer->Fit( this );

    Centre();
    SetDefaults();
}
Esempio n. 14
0
void ModifierPanelUI::Setup(HINSTANCE hInstance, HWND rollupHWND, const MCHAR *iniFile)
{
	//setup rollup
	mRollupHwnd = rollupHWND;

	

	IRollupWindow *irollup = GetIRollup(rollupHWND);
		
	if (mMod->GetUIManager()->LoadSingle(iniFile,200,mMod->hSelParams,GetDlgItem(mMod->hSelParams,IDC_SELPARAM1_TOOLBAR)) == 0)
		SetDefaults(200,mMod->hSelParams);
	else
		LoadInActions(200);

	if (mMod->GetUIManager()->LoadSingle(iniFile,201,mMod->hSelParams,GetDlgItem(mMod->hSelParams,IDC_SELPARAM2_TOOLBAR)) == 0)
		SetDefaults(201,mMod->hSelParams);
	else
		LoadInActions(201);

	if (mMod->GetUIManager()->LoadSingle(iniFile,202,mMod->hSelParams,GetDlgItem(mMod->hSelParams,IDC_SELPARAM3_TOOLBAR)) == 0)
		SetDefaults(202,mMod->hSelParams);
	else
		LoadInActions(202);

	if (mMod->GetUIManager()->LoadSingle(iniFile,203,mMod->hSelParams,GetDlgItem(mMod->hSelParams,IDC_SELPARAM4_TOOLBAR)) == 0)
		SetDefaults(203,mMod->hSelParams);
	else
		LoadInActions(203);


	if (mMod->GetUIManager()->LoadSingle(iniFile,210,mMod->hEditUVParams,GetDlgItem(mMod->hEditUVParams,IDC_EDITPARAM1_TOOLBAR)) == 0)
		SetDefaults(210,mMod->hEditUVParams);
	else
		LoadInActions(210);

	if (mMod->GetUIManager()->LoadSingle(iniFile,211,mMod->hEditUVParams,GetDlgItem(mMod->hEditUVParams,IDC_EDITPARAM2_TOOLBAR)) == 0)
		SetDefaults(211,mMod->hEditUVParams);
	else
		LoadInActions(211);

	if (mMod->GetUIManager()->LoadSingle(iniFile,212,mMod->hEditUVParams,GetDlgItem(mMod->hEditUVParams,IDC_EDITPARAM3_TOOLBAR)) == 0)
		SetDefaults(212,mMod->hEditUVParams);
	else
		LoadInActions(212);

	if (mMod->GetUIManager()->LoadSingle(iniFile,230,mMod->hPeelParams,GetDlgItem(mMod->hPeelParams,IDC_PEELPARAM1_TOOLBAR)) == 0)
		SetDefaults(230,mMod->hPeelParams);
	else
		LoadInActions(230);

	if (mMod->GetUIManager()->LoadSingle(iniFile,231,mMod->hPeelParams,GetDlgItem(mMod->hPeelParams,IDC_PEELPARAM2_TOOLBAR)) == 0)
		SetDefaults(231,mMod->hPeelParams);
	else
		LoadInActions(231);

	if (mMod->GetUIManager()->LoadSingle(iniFile,240,mMod->hMapParams,GetDlgItem(mMod->hMapParams,IDC_MAPPARAM1_TOOLBAR)) == 0)
		SetDefaults(240,mMod->hMapParams);
	else
		LoadInActions(240);

	if (mMod->GetUIManager()->LoadSingle(iniFile,241,mMod->hMapParams,GetDlgItem(mMod->hMapParams,IDC_MAPPARAM2_TOOLBAR)) == 0)
		SetDefaults(241,mMod->hMapParams);
	else
		LoadInActions(241);

	if (mMod->GetUIManager()->LoadSingle(iniFile,242,mMod->hMapParams,GetDlgItem(mMod->hMapParams,IDC_MAPPARAM3_TOOLBAR)) == 0)
		SetDefaults(242,mMod->hMapParams);
	else
		LoadInActions(242);

	if (mMod->GetUIManager()->LoadSingle(iniFile,250,mMod->hWrapParams,GetDlgItem(mMod->hWrapParams,IDC_WRAPPARAM1_TOOLBAR)) == 0)
		SetDefaults(250,mMod->hWrapParams);
	else
		LoadInActions(250);

	ReleaseIRollup(irollup);

	mMod->GetUIManager()->UpdateCheckButtons();

	//add the toolbars
}
Esempio n. 15
0
Environment::Environment()
{
    SetDefaults();
}
Esempio n. 16
0
void SideBarUI::Setup(HINSTANCE hInstance, HWND rollupHWND, const MCHAR *iniFile)
{
	//setup rollup
	mRollupHwnd = rollupHWND;

	GetCOREInterface()->RegisterDlgWnd ( mRollupHwnd );

	IRollupWindow *irollup = GetIRollup(rollupHWND);
	if(NULL == irollup)
	{
		return;
	}

	irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP1),SideBar1RollupDialogProc, GetString(IDS_QUICKTRANSFORM),(LPARAM)mMod );
	irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP2),SideBar1RollupDialogProc, GetString(IDS_RESHAPEELEMENTS),(LPARAM)mMod );
	irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP3),SideBar1RollupDialogProc, GetString(IDS_STITCH),(LPARAM)mMod );
	irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP4),SideBar1RollupDialogProc, GetString(IDS_EXPLODE),(LPARAM)mMod );
	irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP5),SideBar1RollupDialogProc, GetString(IDS_PEEL),(LPARAM)mMod );
	irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP6),SideBar1RollupDialogProc, GetString(IDS_ARRANGEELEMENTS),(LPARAM)mMod );
	irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP7),SideBar1RollupDialogProc, GetString(IDS_ELEMENTPROPERTIES),(LPARAM)mMod );


	for (int i = 0; i < 7; i++)
		irollup->Show(i);

	UnwrapCustomUI* pUIManager = mMod->GetUIManager();
	if(NULL == pUIManager)
	{
		return;
	}

	bool bResult = pUIManager->GetIniFileCache().InitCacheFromIniFile(TSTR(iniFile));

	//quick transform
	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,100,irollup->GetPanelDlg(0),GetDlgItem(irollup->GetPanelDlg(0),IDC_S1_1_TOOLBAR)) > 0)
		LoadInActions(100);
	else
		SetDefaults(100,irollup->GetPanelDlg(0));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,101,irollup->GetPanelDlg(0),GetDlgItem(irollup->GetPanelDlg(0),IDC_S1_2_TOOLBAR)) > 0)
		LoadInActions(101);
	else
		SetDefaults(101,irollup->GetPanelDlg(0));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,102,irollup->GetPanelDlg(0),GetDlgItem(irollup->GetPanelDlg(0),IDC_S1_3_TOOLBAR)) > 0)
		LoadInActions(102);
	else
		SetDefaults(102,irollup->GetPanelDlg(0));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,103,irollup->GetPanelDlg(0),GetDlgItem(irollup->GetPanelDlg(0),IDC_S1_4_TOOLBAR)) > 0)
		LoadInActions(103);
	else
		SetDefaults(103,irollup->GetPanelDlg(0));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,104,irollup->GetPanelDlg(0),GetDlgItem(irollup->GetPanelDlg(0),IDC_S1_5_TOOLBAR)) > 0)
		LoadInActions(104);
	else
		SetDefaults(104,irollup->GetPanelDlg(0));


	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,110,irollup->GetPanelDlg(1),GetDlgItem(irollup->GetPanelDlg(1),IDC_S2_1_TOOLBAR)) > 0)
		LoadInActions(110);
	else
		SetDefaults(110,irollup->GetPanelDlg(1));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,120,irollup->GetPanelDlg(2),GetDlgItem(irollup->GetPanelDlg(2),IDC_S3_1_TOOLBAR)) > 0)
		LoadInActions(120);
	else
		SetDefaults(120,irollup->GetPanelDlg(2));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,130,irollup->GetPanelDlg(3),GetDlgItem(irollup->GetPanelDlg(3),IDC_S4_1_TOOLBAR)) > 0)
		LoadInActions(130);
	else
		SetDefaults(130,irollup->GetPanelDlg(3));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,131,irollup->GetPanelDlg(3),GetDlgItem(irollup->GetPanelDlg(3),IDC_S4_2_TOOLBAR)) > 0)
		LoadInActions(131);
	else
		SetDefaults(131,irollup->GetPanelDlg(3));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,132,irollup->GetPanelDlg(3),GetDlgItem(irollup->GetPanelDlg(3),IDC_S4_3_TOOLBAR)) > 0)
		LoadInActions(132);
	else
		SetDefaults(132,irollup->GetPanelDlg(3));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,140,irollup->GetPanelDlg(4),GetDlgItem(irollup->GetPanelDlg(4),IDC_S5_1_TOOLBAR)) > 0)
		LoadInActions(140);
	else
		SetDefaults(140,irollup->GetPanelDlg(4));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,141,irollup->GetPanelDlg(4),GetDlgItem(irollup->GetPanelDlg(4),IDC_S5_2_TOOLBAR)) > 0)
		LoadInActions(141);
	else
		SetDefaults(141,irollup->GetPanelDlg(4));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,142,irollup->GetPanelDlg(4),GetDlgItem(irollup->GetPanelDlg(4),IDC_S5_0_TOOLBAR)) > 0)
		LoadInActions(142);
	else
		SetDefaults(142,irollup->GetPanelDlg(4));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,150,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_1_TOOLBAR)) > 0)
		LoadInActions(150);
	else
		SetDefaults(150,irollup->GetPanelDlg(5));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,151,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_2_TOOLBAR)) > 0)
		LoadInActions(151);
	else
		SetDefaults(151,irollup->GetPanelDlg(5));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,152,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_3_TOOLBAR)) > 0)
		LoadInActions(152);
	else
		SetDefaults(152,irollup->GetPanelDlg(5));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,153,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_4_TOOLBAR)) > 0)
		LoadInActions(153);
	else
		SetDefaults(153,irollup->GetPanelDlg(5));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,154,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_5_TOOLBAR)) > 0)
		LoadInActions(154);
	else
		SetDefaults(154,irollup->GetPanelDlg(5));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,155,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_6_TOOLBAR)) > 0)
		LoadInActions(155);
	else
		SetDefaults(155,irollup->GetPanelDlg(5));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,156,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_7_TOOLBAR)) > 0)
		LoadInActions(156);
	else
		SetDefaults(156,irollup->GetPanelDlg(5));


	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,160,irollup->GetPanelDlg(6),GetDlgItem(irollup->GetPanelDlg(6),IDC_S7_1_TOOLBAR)) > 0)
		LoadInActions(160);
	else
		SetDefaults(160,irollup->GetPanelDlg(6));

	if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,161,irollup->GetPanelDlg(6),GetDlgItem(irollup->GetPanelDlg(6),IDC_S7_2_TOOLBAR)) > 0)
		LoadInActions(161);
	else
		SetDefaults(161,irollup->GetPanelDlg(6));
		

	ReleaseIRollup(irollup);

	//add the toolbars
}
Esempio n. 17
0
Environment::Environment(const Args & args)
{
    SetDefaults();
    LoadFromFile(args.optfile);
    ApplyArgs(args);
}
Esempio n. 18
0
/*
 * Create a new device
 */
SPIDevice::SPIDevice(SPIPlugin *owner,
                     Preferences *prefs,
                     PluginAdaptor *plugin_adaptor,
                     const string &spi_device,
                     ola::rdm::UIDAllocator *uid_allocator)
    : Device(owner, SPI_DEVICE_NAME),
      m_preferences(prefs),
      m_plugin_adaptor(plugin_adaptor),
      m_spi_device_name(spi_device) {
  size_t pos = spi_device.find_last_of("/");
  if (pos != string::npos)
    m_spi_device_name = spi_device.substr(pos + 1);

  SetDefaults();
  unsigned int port_count = 0;

  string backend_type = m_preferences->GetValue(SPIBackendKey());
  SPIWriter::Options writer_options;
  PopulateWriterOptions(&writer_options);
  m_writer.reset(new SPIWriter(spi_device, writer_options,
                               plugin_adaptor->GetExportMap()));


  if (backend_type == HARDWARE_BACKEND) {
    HardwareBackend::Options options;
    PopulateHardwareBackendOptions(&options);
    m_backend.reset(
        new HardwareBackend(options, m_writer.get(),
                            plugin_adaptor->GetExportMap()));
    port_count = 1 << options.gpio_pins.size();
    OLA_INFO << m_spi_device_name << ", Hardware backend, " << port_count
             << " ports";
  } else {
    if (backend_type != SOFTWARE_BACKEND) {
      OLA_WARN << "Unknown backend_type '" << backend_type
               << "' for SPI device " << m_spi_device_name;
    }

    SoftwareBackend::Options options;
    PopulateSoftwareBackendOptions(&options);
    m_backend.reset(
        new SoftwareBackend(options, m_writer.get(),
                            plugin_adaptor->GetExportMap()));
    port_count = options.outputs;
    OLA_INFO << m_spi_device_name << ", Software backend, " << port_count
             << " ports";
  }

  for (uint8_t i = 0; i < port_count; i++) {
    SPIOutput::Options spi_output_options(i);

    uint8_t pixel_count;
    if (StringToInt(m_preferences->GetValue(PixelCountKey(i)), &pixel_count)) {
      spi_output_options.pixel_count = pixel_count;
    }

    auto_ptr<UID> uid(uid_allocator->AllocateNext());
    if (!uid.get()) {
      OLA_WARN << "Insufficient UIDs remaining to allocate a UID for SPI port "
               << static_cast<int>(i);
      continue;
    }

    m_spi_ports.push_back(
        new SPIOutputPort(this, m_backend.get(), *uid.get(),
                          spi_output_options));
  }
}
Esempio n. 19
0
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    Data data;
	mxArray *Im;
	int nof_dim;
    const int *elem_per_dim;
    int nargout;
    int i;
	
    
    // set default values
    SetDefaults(&data);
    
	// check number of input arguments
	if( (nrhs % 2 == 0) || (nrhs < 3 ) )
	{
		ErrorMessage(ERR_NARGIN);
        ClearMemory(&data);
		return;
	}
    
	// initialize that part of the data depending only on input image
    {
        if( !mxIsDouble(prhs[0]) ) // check if image is given as double
        {
            ErrorMessage(ERR_DOUBLE);
            ClearMemory(&data);
            return;
        }
        
        // get image dimensions
        nof_dim = mxGetNumberOfDimensions(prhs[0]);
        elem_per_dim = mxGetDimensions(prhs[0]);
        
        if( nof_dim > 3 )
        {
            ErrorMessage(ERR_DIM);
            ClearMemory(&data);
            return;
        }
        
        plhs[0] = mxDuplicateArray(prhs[0]); // output image
        Im = mxDuplicateArray(prhs[0]);      // smoothed image

        data.rows = elem_per_dim[0];
        data.cols = elem_per_dim[1];
        data.size = data.rows * data.cols;
        data.channels = 1;
        if( nof_dim == 3 )
            data.channels = elem_per_dim[2];
        
        data.Image = mxGetPr(plhs[0]);
        data.MImage = mxGetPr(Im); 
        
        data.Ihelp = (double *)AllocMem(sizeof(double) * data.channels);
        data.Tfield = (hItem *) AllocMem(sizeof(hItem) * data.size);
        data.Domain = (double *) AllocMem(sizeof(double) * data.size);
        data.MDomain = (double *) AllocMem(sizeof(double) * data.size);
        data.heap = (hItem **) AllocMem(sizeof(hItem *) * data.size);
        data.ordered_points = (double *) AllocMem(sizeof(double) * data.size *3);
        
        // number of output arguments
        if( nlhs <= 2 )
            nargout = nlhs;
        else
            nargout = 2;
    }
     
    
    // get and check arguments
    {
        char guidance_done = 0;
        char order_done = 0;
        char argname[100];
        int  len;
        int  err;
        
        for( i = 1 ; i < nrhs ; i = i+2 )
        {
            if( !mxIsChar( prhs[i] ) )
            {
                ErrorMessage(ERR_STRING);
                ClearMemory(&data);
                return;
            }
            else
            {
                len = mxGetN( prhs[i] );
                mxGetString( prhs[i], argname, len+1);
                
                //mexPrintf(" %s \n", argname);
                
                switch( argname[0] )
                {
                    case 'o': // orderD , orderT
                        {
                            if( !order_done )
                            {
                                if( !mxIsEmpty(prhs[i+1]) )
                                {
                                    if( argname[len-1] == 'D' )
                                    {
                                        err = GetMask( prhs[i+1], &data);
                                        data.ordergiven = 0;
                                    }
                                    else if( argname[len-1] == 'T' )
                                    {
                                        err = GetOrder( prhs[i+1], &data);
                                        data.ordergiven =1;
                                    }
                                    else
                                        err = ERR_UNKNOWN_ID;
                                }
                                else
                                    err = ERR_ARG_MISSING; 

                                order_done = 1;
                            }
                            break;
                        }
                                            
                    case 'g': // guidanceN , guidanceC , guidanceD
                        {
                            if( !guidance_done )
                            {
                                if( !mxIsEmpty(prhs[i+1]) )
                                {
                                    if( argname[len-1] == 'N' )
                                    {
                                        err = GetParam( prhs[i+1], &data, TYPE_N);
                                        data.guidance = 0;
                                    }
                                    else if( argname[len-1] == 'C' )
                                    {
                                        err = GetParam( prhs[i+1], &data, TYPE_C);
                                        data.guidance = 1;
                                    }
                                    else if( argname[len-1] == 'D' )
                                    {
                                        err = GetParam( prhs[i+1], &data, TYPE_D);
                                        data.guidance = 2;
                                    }
                                    else
                                        err = ERR_UNKNOWN_ID;
                                }
                                else
                                    err = ERR_ARG_MISSING;
                                
                                // guidance_done = 1;
                                if(data.GivenGuidanceT != NULL)
                                    data.guidance = 2;
                            }
                            break;
                        }
                        
                    default:
                        err = ERR_UNKNOWN_ID;
                        break;
                }
                    
                if( err )
                {
                    ErrorMessage(err);
                    ClearMemory(&data);
                    return;
                }
            }
        }
        
        if( !order_done ) // at least mask must be specified
        {
            ErrorMessage(ERR_NO_MASK_ORDER);
            ClearMemory(&data);
            return;
        }
    }
	
    
    if( data.guidance == 1)
        SetKernels(&data);
    
	InpaintImage(&data); 
    
    if(data.inpaint_undefined == 1)
    {
        mexPrintf("\n\n");
        mexPrintf("Error:\n");
        mexPrintf("Some inpainted image values are undefined !\n");
        mexPrintf("This happens if the order is not well-defined. \n");
        mexPrintf("You can find out the undefined pixels by: > ind = find( isnan(result) ) \n\n\n");
    }
        
        
    if( nargout == 2 )
    {
        double *p;
        int size;
        
        size = 3 * data.nof_points2inpaint;
        plhs[1] = mxCreateDoubleMatrix(3, data.nof_points2inpaint , mxREAL);
        p = mxGetPr(plhs[1]);
        
        for( i=0 ; i < size ; i++ )
            if( (i+1) % 3 != 0 )
                p[i] = data.ordered_points[i] + 1;
            else
                p[i] = data.ordered_points[i];
    }
    
    //CopyMask(&data);
    //CopyParam( &data );
    //CopyDirfield( &data );
    //CopyMImage( &data );
    //CopyTfield(&data);
    
    ClearMemory(&data);
	return;
}
Esempio n. 20
0
csShapePropertiesDialog::csShapePropertiesDialog(wxWindow* parent, const wxString& title,
        wxPanel* attributeDialog, const wxString& attributeDialogName):
    wxDialog(parent, wxID_ANY, title, wxPoint(0, 0), wxSize(SHAPE_PROPERTY_DIALOG_WIDTH, SHAPE_PROPERTY_DIALOG_HEIGHT))
{
    m_attributeDialog = attributeDialog;
    m_alternativeAttributeDialog = NULL;
    m_generalPropertiesDialog = NULL;

    m_notebook = new wxNotebook(this, ID_SHAPE_PROPERTY_NOTEBOOK,
                                wxPoint(2, 2), wxSize(SHAPE_PROPERTY_DIALOG_WIDTH - 4, SHAPE_PROPERTY_DIALOG_HEIGHT - 4));

    m_generalPropertiesDialog = new csGeneralShapePropertiesDialog;
#ifdef  __WXDEBUG__
    bool success =
#endif
        wxLoadFromResource(m_generalPropertiesDialog, m_notebook, _T("general_shape_properties_dialog"));
    wxASSERT_MSG( (success), _T("Could not load general properties panel."));
    m_notebook->AddPage(m_generalPropertiesDialog, _T("General"));

    if (!wxLoadFromResource(m_attributeDialog, m_notebook, attributeDialogName))
    {
        wxMessageBox(_T("Could not load the attribute dialog for this shape."), _T("Studio"), wxICON_EXCLAMATION);
        delete m_attributeDialog;
        m_attributeDialog = NULL;
    }
    else
    {
        m_notebook->AddPage(m_attributeDialog, _T("Attributes"));
    }

    // Try the alternative dialog (test code)
    wxString str(attributeDialogName);
    str += _T("1");
    m_alternativeAttributeDialog = new wxPanel;
    if (wxLoadFromResource(m_alternativeAttributeDialog, m_notebook, str))
    {
        m_notebook->AddPage(m_alternativeAttributeDialog, _T("Attributes (alternative)"));
    }
    else
    {
        delete m_alternativeAttributeDialog;
        m_alternativeAttributeDialog = NULL;
    }

    int largeButtonWidth = 70;
    int largeButtonHeight = 22;

    wxButton* okButton = new wxButton(this, wxID_OK, _T("OK"), wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
    wxButton* cancelButton = new wxButton(this, wxID_CANCEL, _T("Cancel"), wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
    wxButton* helpButton = new wxButton(this, wxID_HELP, _T("Help"), wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));

    // Constraints for the notebook
    wxLayoutConstraints *c = new wxLayoutConstraints;
    c->top.SameAs     (this, wxTop, 5);
    c->left.SameAs    (this, wxLeft, 5);
    c->right.SameAs   (this, wxRight, 5);
    c->bottom.SameAs  (helpButton, wxTop, 5);
    m_notebook->SetConstraints(c);

    // Constraints for the Help button
    c = new wxLayoutConstraints;
    c->width.AsIs();
    c->height.AsIs();
    c->right.SameAs    (this, wxRight, 5);
    c->bottom.SameAs   (this, wxBottom, 5);
    helpButton->SetConstraints(c);

    // Constraints for the Cancel button
    c = new wxLayoutConstraints;
    c->width.AsIs();
    c->height.AsIs();
    c->right.SameAs    (helpButton, wxLeft, 5);
    c->bottom.SameAs   (this, wxBottom, 5);
    cancelButton->SetConstraints(c);

    // Constraints for the OK button
    c = new wxLayoutConstraints;
    c->width.AsIs();
    c->height.AsIs();
    c->right.SameAs    (cancelButton, wxLeft, 5);
    c->bottom.SameAs   (this, wxBottom, 5);
    okButton->SetConstraints(c);

    okButton->SetDefault();
    okButton->SetFocus();

    SetDefaults();

    Layout();
    Centre(wxBOTH);
}
CBlastNucleotideOptionsHandle::CBlastNucleotideOptionsHandle(EAPILocality locality)
    : CBlastOptionsHandle(locality)
{
    SetDefaults();
}
Esempio n. 22
0
/**
 *  \brief
 */
bool Settings::Load()
{
    SetDefaults();

    CPath cfgFile;
    INpp::Get().GetPluginsConfDir(cfgFile);
    cfgFile += cPluginCfgFileName;

    if (!cfgFile.FileExists())
        return false;

    FILE* fp;
    _tfopen_s(&fp, cfgFile.C_str(), _T("rt"));
    if (fp == NULL)
        return false;

    bool success = true;

    TCHAR line[8192];
    while (_fgetts(line, _countof(line), fp))
    {
        // Comment or empty line
        if (line[0] == _T('#') || line[0] == _T('\n'))
            continue;

        // Strip newline from the end of the line
        line[_tcslen(line) - 1] = 0;

        if (!_tcsncmp(line, cUseDefDbKey, _countof(cUseDefDbKey) - 1))
        {
            const unsigned pos = _countof(cUseDefDbKey) - 1;
            if (!_tcsncmp(&line[pos], _T("yes"), _countof(_T("yes")) - 1))
                _useDefDb = true;
            else
                _useDefDb = false;
        }
        else if (!_tcsncmp(line, cDefDbPathKey, _countof(cDefDbPathKey) - 1))
        {
            const unsigned pos = _countof(cDefDbPathKey) - 1;
            _defDbPath = &line[pos];
            _defDbPath.AsFolder();
            if (!_defDbPath.Exists())
                _defDbPath.Clear();
        }
        else if (!_tcsncmp(line, cREOptionKey, _countof(cREOptionKey) - 1))
        {
            const unsigned pos = _countof(cREOptionKey) - 1;
            if (!_tcsncmp(&line[pos], _T("yes"), _countof(_T("yes")) - 1))
                _re = true;
            else
                _re = false;
        }
        else if (!_tcsncmp(line, cICOptionKey, _countof(cICOptionKey) - 1))
        {
            const unsigned pos = _countof(cICOptionKey) - 1;
            if (!_tcsncmp(&line[pos], _T("yes"), _countof(_T("yes")) - 1))
                _ic = true;
            else
                _ic = false;
        }
        else if (!_genericDbCfg.ReadOption(line))
        {
            success = false;
            SetDefaults();
            break;
        }
    }

    fclose(fp);

    return success;
}
Esempio n. 23
0
BufferConfig::BufferConfig()
{
	SetDefaults();
}
Esempio n. 24
0
/**
 *  \brief
 */
DbConfig::DbConfig()
{
    SetDefaults();
}
VideoTheoraPlayer::VideoTheoraPlayer(BaseGame *inGame) : BaseClass(inGame) {
    SetDefaults();
}
Esempio n. 26
0
WinClass::WinClass (char const * className, HINSTANCE hInst, WNDPROC wndProc)
    : WinSimpleClass (className, hInst)
{
    _class.lpfnWndProc = wndProc;
	SetDefaults ();
}
Esempio n. 27
0
_Settings::_Settings()
{
	SetDefaults();
}
Esempio n. 28
0
WinClass::WinClass (int resId, HINSTANCE hInst, WNDPROC wndProc)
    : WinSimpleClass (resId, hInst)
{
    _class.lpfnWndProc = wndProc;
	SetDefaults ();
}
Esempio n. 29
0
void CMixereView::OnSetDefaults() 
{
	SetDefaults();
}
Esempio n. 30
0
CAnimationItem::CAnimationItem()
{
	SetDefaults();
	m_pAE = NULL;
}