Пример #1
0
void clientTask::Run(void)
{
    if (BenchmarkCompleted) return;

    // Skip some samples at start-up.
    if (NumberOfSamplesSkipped++ <= confNumberOfSamplesToSkip) return;

	// Placeholders to send and receive time information.
	mtsDouble currentTic, previousTic;

	// Keep the current relative time.
	currentTic.Data = TimeServer->GetRelativeTime();

	// Execute the qualified read command across a network.
	QualifiedReadFunction(currentTic, previousTic);

    // Obtain the elapsed time and keep it.
	const double elapsedTime = TimeServer->GetRelativeTime() - previousTic;
    Results.Element(NumberOfSamplesCollected++) = elapsedTime;

	if (NumberOfSamplesCollected == confNumberOfSamples) {        
        ShowResults();
        BenchmarkCompleted = true;
    } else {
        if (NumberOfSamplesCollected % (confNumberOfSamples / 20) == 0) {
            std::cout << ".";
        }
    }
}
Пример #2
0
CNextStageScene::CNextStageScene(void)
{
	InitPlayer();
	InitMenuButtons();
	InitUpgradeButtons();
	ShowResults();
	
}
Пример #3
0
/** Count the lines on all project's files and display the results.
 *  @param languages Languages definitions
 *  @param nb_languages Number of languages defined in the 'languages' array
 */
int CodeStatExecDlg::Execute(LanguageDef languages[NB_FILETYPES_MAX], int numLanguages)
{
    m_choice->Clear();
    m_choice->Append(_T("Entire workspace"));

    ProjectsArray* projects = Manager::Get()->GetProjectManager()->GetProjects();
    for (size_t i = 0, length = projects->GetCount(); i < length; ++i)
    {
        m_choice->Append(projects->Item(i)->GetTitle());
    }
    m_cache.clear();
    m_cache.resize(projects->GetCount() + 1);

    m_languages = languages;
    m_numLanguages = numLanguages;

    // Check if all files have been saved
    bool all_saved = true;
    for (size_t i = 0, nb_projects = projects->GetCount(); i < nb_projects; ++i)
    {
        cbProject* project = projects->Item(i);
        for (int j = 0, nb_files = project->GetFilesCount(); j < nb_files; ++j)
        {
            ProjectFile* pf = project->GetFile(j);
            if (pf->GetFileState() == fvsModified)
            {
                all_saved = false;
                break;
            }
        }
    }

    // If not, ask user if we can save them
    if (!all_saved)
    {
        if (cbMessageBox(_T("Some files are not saved.\nDo you want to save them before running the plugin?"),
                         _("Warning"),
                         wxICON_EXCLAMATION | wxYES_NO,
                         Manager::Get()->GetAppWindow()) == wxID_YES)
        {
            for (size_t i = 0, nb_projects = projects->GetCount(); i < nb_projects; ++i)
                (*projects)[i]->SaveAllFiles();
        }
    }

    cbProject* project = Manager::Get()->GetProjectManager()->GetActiveProject();
    int index = m_choice->FindString(project->GetTitle(), true);
    m_choice->SetSelection(index);
    DoParseProject(index);

    ShowResults(index);

    ShowModal();

    return 0;
}
Пример #4
0
int Pop() {
	State *currentState;

	currentState = myQueue->queueHead;
	
	if (IsEmpty()) {
		printf("%s", "The queue is empty, Pop operation cannot be done!");
		return 0;
	}

	// Is it the final state?
	if (IsFinalState(currentState)) {
		ShowResults();
		return 1;
	}
	else {

		// Find the position where the number zero of the current matrix is
		FindZeroPosition(currentState->matrix);

		// Is it possible to change the numbers within the matrix?
		if (CanMoveUp()) {
			CreateNewState(currentState, UP);
		}
		if (CanMoveDown()) {
			CreateNewState(currentState, DOWN);
		}
		if (CanMoveLeft()) {
			CreateNewState(currentState, LEFT);
		}
		if (CanMoveRight()) {
			CreateNewState(currentState, RIGHT);
		}
	}

	// Take out from the queue
	// Move the queue first state to the next element
	// Decrement one state of the queue, but we need to store it once we need to show the actions taken, at the end
	myQueue->queueHead = myQueue->queueHead->next;
	myQueue->numberOfElements--;

	// free(currentState);

	return 2;
}
Пример #5
0
void CodeStatExecDlg::OnIdle(wxIdleEvent& evt)
{
    if (!m_changed)
        return;

    m_changed = false;

    int index = m_choice->GetSelection();
    if (index == 0)
    {
        DoParseWorkspace();

    }
    else
        DoParseProject(index);
    ShowResults(index);

    evt.Skip();
}
Пример #6
0
/*
 * Format EC packet into text form for output to console
 */
void CamulecmdApp::Process_Answer_v2(const CECPacket *response)
{
	wxString s;
	wxString msgFailedUnknown(_("Request failed with an unknown error."));
	wxASSERT(response);
	switch (response->GetOpCode()) {
		case EC_OP_NOOP:
			s << _("Operation was successful.");
			break;
		case EC_OP_FAILED:
			{
				const CECTag *tag = response->GetFirstTagSafe();
				if (tag->IsString()) {
					s <<	CFormat(_("Request failed with the following error: %s")) % wxGetTranslation(tag->GetStringData());
				} else {
					s << msgFailedUnknown;
				}
			}
			break;
		case EC_OP_SET_PREFERENCES:
			{
				const CECTag *tab = response->GetTagByNameSafe(EC_TAG_PREFS_SECURITY);
				const CECTag *ipfilterLevel = tab->GetTagByName(EC_TAG_IPFILTER_LEVEL);
				if (ipfilterLevel) {
					if (m_last_cmd_id == CMD_ID_GET_IPFILTER ||
					    m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE ||
					    m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE_CLIENTS) {
						s += CFormat(_("IP filtering for clients is %s.\n"))
								% ((tab->GetTagByName(EC_TAG_IPFILTER_CLIENTS) == NULL) ? _("OFF") : _("ON"));
					}
					if (m_last_cmd_id == CMD_ID_GET_IPFILTER ||
					    m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE ||
					    m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE_SERVERS) {
						s += CFormat(_("IP filtering for servers is %s.\n"))
								% ((tab->GetTagByName(EC_TAG_IPFILTER_SERVERS) == NULL) ? _("OFF") : _("ON"));
					}
					if (m_last_cmd_id == CMD_ID_GET_IPFILTER ||
					    m_last_cmd_id == CMD_ID_GET_IPFILTER_LEVEL) {
						s << CFormat(_("Current IPFilter Level is %d.\n")) % ipfilterLevel->GetInt();
					}
				}
				tab = response->GetTagByNameSafe(EC_TAG_PREFS_CONNECTIONS);
				const CECTag *connMaxUL = tab->GetTagByName(EC_TAG_CONN_MAX_UL);
				const CECTag *connMaxDL = tab->GetTagByName(EC_TAG_CONN_MAX_DL);
				if (connMaxUL && connMaxDL) {
					s << CFormat(_("Bandwidth limits: Up: %u kB/s, Down: %u kB/s.\n"))
						% connMaxUL->GetInt() % connMaxDL->GetInt();
				}
			}
			break;
		case EC_OP_STRINGS:
			for (CECPacket::const_iterator it = response->begin(); it != response->end(); ++it) {
				const CECTag &tag = *it;
				s << tag.GetStringData() << wxT("\n");
			}
			break;
		case EC_OP_STATS: {
			const CEC_ConnState_Tag *connState = static_cast<const CEC_ConnState_Tag*>(response->GetTagByName(EC_TAG_CONNSTATE));
			if (connState) {
				s << _("eD2k") << wxT(": ");
				if (connState->IsConnectedED2K()) {
					const CECTag *server = connState->GetTagByName(EC_TAG_SERVER);
					const CECTag *serverName = server ? server->GetTagByName(EC_TAG_SERVER_NAME) : NULL;
					if (server && serverName) {
						s << CFormat(_("Connected to %s %s %s")) %
						 serverName->GetStringData() %
						 server->GetIPv4Data().StringIP() %
						 (connState->HasLowID() ? _("with LowID") : _("with HighID"));
					}
				} else if (connState->IsConnectingED2K()) {
					s << _("Now connecting");
				} else {
					s << _("Not connected");
				}
				s << wxT('\n') << _("Kad") << wxT(": ");
				if (connState->IsKadRunning()) {
					if (connState->IsConnectedKademlia()) {
						s << _("Connected") << wxT(" (");
						if (connState->IsKadFirewalled()) {
							s << _("firewalled");
						} else {
							s << _("ok");
						}
						s << wxT(')');
					} else {
						s << _("Not connected");
					}
				} else {
					s << _("Not running");
				}
				s << wxT('\n');
			}
			const CECTag *tmpTag;
			if ((tmpTag = response->GetTagByName(EC_TAG_STATS_DL_SPEED)) != 0) {
				s <<	CFormat(_("\nDownload:\t%s")) % CastItoSpeed(tmpTag->GetInt());
			}
			if ((tmpTag = response->GetTagByName(EC_TAG_STATS_UL_SPEED)) != 0) {
				s <<	CFormat(_("\nUpload:\t%s")) % CastItoSpeed(tmpTag->GetInt());
			}
			if ((tmpTag = response->GetTagByName(EC_TAG_STATS_UL_QUEUE_LEN)) != 0) {
				s <<	CFormat(_("\nClients in queue:\t%d\n")) % tmpTag->GetInt();
			}
			if ((tmpTag = response->GetTagByName(EC_TAG_STATS_TOTAL_SRC_COUNT)) != 0) {
				s <<	CFormat(_("\nTotal sources:\t%d\n")) % tmpTag->GetInt();
			}
			break;
		}
		case EC_OP_DLOAD_QUEUE:
			for (CECPacket::const_iterator it = response->begin(); it != response->end(); ++it) {
				const CEC_PartFile_Tag *tag = static_cast<const CEC_PartFile_Tag *>(&*it);
				uint64 filesize, donesize;
				filesize = tag->SizeFull();
				donesize = tag->SizeDone();
				s <<	tag->FileHashString() << wxT(" ") <<
					tag->FileName() <<
					(CFormat(wxT("\n\t [%.1f%%] %4i/%4i "))
						% ((float)donesize / ((float)filesize)*100.0)
						% ((int)tag->SourceCount() - (int)tag->SourceNotCurrCount())
						% (int)tag->SourceCount()) <<
					((int)tag->SourceCountA4AF() ? wxString(CFormat(wxT("+%2.2i ")) % (int)tag->SourceCountA4AF()) : wxString(wxT("    "))) <<
					((int)tag->SourceXferCount() ? wxString(CFormat(wxT("(%2.2i) - ")) % (int)tag->SourceXferCount()) : wxString(wxT("     - "))) <<
					tag->GetFileStatusString();
				s << wxT(" - ") << tag->PartMetName();
				if (tag->DownPrio() < 10) {
					s << wxT(" - ") << PriorityToStr((int)tag->DownPrio(), 0);
				} else {
					s << wxT(" - ") << PriorityToStr((tag->DownPrio() - 10), 1);
				}
				if ( tag->SourceXferCount() > 0) {
					s << wxT(" - ") + CastItoSpeed(tag->Speed());
				}
				s << wxT("\n");
			}
			break;
		case EC_OP_ULOAD_QUEUE:
			for (CECPacket::const_iterator it = response->begin(); it != response->end(); ++it) {
				const CECTag *tag = & *it;
				const CECTag *clientName = tag->GetTagByName(EC_TAG_CLIENT_NAME);
				const CECTag *partfileName = tag->GetTagByName(EC_TAG_PARTFILE_NAME);
				const CECTag *partfileSizeXfer = tag->GetTagByName(EC_TAG_PARTFILE_SIZE_XFER);
				const CECTag *partfileSpeed = tag->GetTagByName(EC_TAG_CLIENT_UP_SPEED);
				if (clientName && partfileName && partfileSizeXfer && partfileSpeed) {
					s <<	wxT("\n") <<
						CFormat(wxT("%10u ")) % tag->GetInt() <<
						clientName->GetStringData() << wxT(" ") <<
						partfileName->GetStringData() << wxT(" ") <<
						CastItoXBytes(partfileSizeXfer->GetInt()) << wxT(" ") <<
						CastItoSpeed(partfileSpeed->GetInt());
				}
			}
			break;
		case EC_OP_LOG:
			for (CECPacket::const_iterator it = response->begin(); it != response->end(); ++it) {
				const CECTag &tag = *it;
				s << tag.GetStringData() << wxT("\n");
			}
			break;
		case EC_OP_SERVER_LIST:
			for (CECPacket::const_iterator it = response->begin(); it != response->end(); ++it) {
				const CECTag &tag = *it;
				const CECTag *serverName = tag.GetTagByName(EC_TAG_SERVER_NAME);
				if (serverName) {
					wxString ip = tag.GetIPv4Data().StringIP();
					ip.Append(' ', 24 - ip.Length());
					s << ip << serverName->GetStringData() << wxT("\n");
				}
			}
			break;

		case EC_OP_SHARED_FILES:
			for (CECPacket::const_iterator it = response->begin(); it != response->end(); ++it) {
				const CEC_SharedFile_Tag *tag = static_cast<const CEC_SharedFile_Tag *>(&*it);
				s << tag->FileHashString() << wxT(" ");
				wxString filePath = tag->FilePath();
				bool ispartfile = true;
				if (filePath.EndsWith(wxT(".part"))) {
					for (unsigned i = 0; i < filePath.Length() - 5; i++) {
						if (filePath[i] < wxT('0') || filePath[i] > wxT('9')) {
							ispartfile = false;
							break;
						}
					}
				} else {
					ispartfile = false;
				}
				if (ispartfile) {
					s << _("[PartFile]") << wxT(" ");
				} else {
					s << filePath
#ifdef __WINDOWS__
					  << wxT('\\');
#else
					  << wxT('/');
#endif
				}
				s << tag->FileName()
				  << wxT("\n\t") << PriorityToStr(tag->UpPrio() % 10, tag->UpPrio() >= 10) << wxT(" - ") << CFormat(wxT("%i(%i) / %i(%i) - %s (%s) - %.2f\n"))
					% tag->GetRequests() % tag->GetAllRequests()
					% tag->GetAccepts() % tag->GetAllAccepts()
					% CastItoXBytes(tag->GetXferred()) % CastItoXBytes(tag->GetAllXferred())
					% (static_cast<float>(tag->GetAllXferred()) / static_cast<float>(tag->SizeFull()));
			}
			break;

		case EC_OP_STATSTREE:
			s << StatTree2Text(static_cast<const CEC_StatTree_Node_Tag*>(response->GetTagByName(EC_TAG_STATTREE_NODE)), 0);
			break;

		case EC_OP_SEARCH_RESULTS:
		{
			int i = 0;
			m_Results_map.clear();
			s += CFormat(_("Number of search results: %i\n")) % response->GetTagCount();
			for (CECPacket::const_iterator it = response->begin(); it != response->end(); ++it) {
				const CEC_SearchFile_Tag *tag = static_cast<const CEC_SearchFile_Tag *>(&*it);
				//printf("Tag FileName: %s \n",(const char*)unicode2char(tag->FileName()));
				m_Results_map[i++] = new SearchFile(tag);
			}
			ShowResults(m_Results_map);
			break;
		}
		case EC_OP_SEARCH_PROGRESS:
		{
			const CECTag *tab = response->GetTagByNameSafe(EC_TAG_SEARCH_STATUS);
			uint32 progress = tab->GetInt();
			if (progress <= 100) {
				s += CFormat(_("Search progress: %u %% \n")) % progress;
			} else {
				s += _("Search progress not available");
			}
			break;
		}
		default:
			s += CFormat(_("Received an unknown reply from the server, OpCode = %#x.")) % response->GetOpCode();
	}
Пример #7
0
void
SelectMove(short side, SelectMove_mode iop)
{
    static short i, tempb, tempc, tempsf, tempst, xside, rpt;
    static short alpha, beta, score;
    static struct GameRec  *g;
    short sqking, in_check, blockable;

#ifdef BOOKTEST
    printf("hashbd = %ld (hashkey >> 16)|side = %d\n",
           hashbd, (hashkey >> 16)|side);
#endif

    flag.timeout = false;
    flag.back = false;
    flag.musttimeout = false;

    xside = side ^ 1;

#if ttblsz
    recycle = (GameCnt % rehash) - rehash;
#endif

    ExaminePosition(side);

    /* if background mode set to infinite */
    if (iop == BACKGROUND_MODE)
    {
        background = true;
        /* if background mode set response time to infinite */
        ResponseTime = 9999999;
    }
    else
    {
        player = side;
        SetResponseTime(side);
    }

#ifdef QUIETBACKGROUND
    if (!background)
#endif /* QUIETBACKGROUND */
        ShowResponseTime();

    ExtraTime = 0;

    score = ScorePosition(side);

#ifdef QUIETBACKGROUND
    if (!background)
#endif /* QUIETBACKGROUND */
        ShowSidetoMove();

#ifdef QUIETBACKGROUND
    if (!background)
#endif /* QUIETBACKGROUND */
        SearchStartStuff(side);

#ifdef HISTORY
    array_zero(history, sizeof_history);
#endif

    FROMsquare = TOsquare = -1;
    PV = 0;

    if (iop == FOREGROUND_MODE)
        hint = 0;

    /*
     * If the last move was the hint, select the computed answer to the
     * hint as first move to examine.
     */

#if MAXDEPTH > 3
    if (GameCnt > 0)
    {
        SwagHt = (GameList[GameCnt].gmove == PrVar[2]) ? PrVar[3] : 0;
    }
    else
#endif
        SwagHt = 0;


    for (i = 0; i < MAXDEPTH; i++)
        PrVar[i] = killr0[i] = killr1[i] = killr2[i] = killr3[i] = 0;

    /* set initial window for search */

    if (flag.tsume)
    {
        alpha =  -(SCORE_LIMIT + 999);
        beta = SCORE_LIMIT + 999;
    }
    else
    {
        alpha = score - ((computer == white) ? BAwindow : WAwindow);
        beta  = score + ((computer == white) ? BBwindow : WBwindow);
    }

    rpt = 0;
    TrPnt[1] = 0;
    root = &Tree[0];

    sqking = PieceList[side][0];
    in_check = (board[sqking] == king)
        ? SqAttacked(sqking, side^1, &blockable)
        : false;

    MoveList(side, 1, in_check, blockable);

    for (i = TrPnt[1]; i < TrPnt[2]; i++)
    {
        if (!pick(i, TrPnt[2] - 1))
            break;
    }

    /* Can I get a book move? */

    if (flag.regularstart && Book)
    {
        flag.timeout = bookflag = OpeningBook(&hint, side);

        if (TCflag)
            ResponseTime += ResponseTime;
    }

    /* Zero stats for hash table. */

    reminus = replus = 0;
    GenCnt = NodeCnt = ETnodes = EvalNodes = HashCnt
        = FHashAdd = HashAdd = FHashCnt = THashCol = HashCol = 0;

    globalscore = plyscore = score;
    Jscore = 0;
    zwndw = 20;


    /********************* main loop ********************************/

    Sdepth = (MaxSearchDepth < (MINDEPTH - 1))
        ? MaxSearchDepth
        : (MINDEPTH - 1);

    while (!flag.timeout)
    {
        /* go down a level at a time */
        Sdepth++;

#ifdef NULLMOVE
        null = 0;
        PVari = 1;
#endif

        /* terminate search at DepthBeyond ply past goal depth */
        if (flag.tsume)
            DepthBeyond = Sdepth;
        else
#if defined SLOW_CPU
            DepthBeyond = Sdepth + ((Sdepth == 1) ? 3 : 5);
#else
        DepthBeyond = Sdepth + ((Sdepth == 1) ? 7 : 11);
#endif

# ifdef QUIETBACKGROUND
        if (!background)
#endif /* QUIETBACKGROUND */
            ShowDepth(' ');

        /* search at this level returns score of PV */
        score = search(side, 1, Sdepth, alpha, beta, PrVar, &rpt);

        /* save PV as killer */
        for (i = 1; i <= Sdepth; i++)
            killr0[i] = PrVar[i];

        /* low search failure re-search with (-inf, score) limits  */
        if (score < alpha)
        {
            reminus++;
#ifdef QUIETBACKGROUND
            if (!background)
#endif /* QUIETBACKGROUND */
                ShowDepth('-');

            if (TCflag && TCcount < MAXTCCOUNTR)
            {
                if (hard_time_limit)
                    ExtraTime += (MAXTCCOUNTR - TCcount) * TCleft;
                else
                    ExtraTime += (8 * TCleft);

                TCcount = MAXTCCOUNTR - 1;
            }

            score = search(side, 1, Sdepth, -(SCORE_LIMIT + 999),
                           (SCORE_LIMIT + 999), PrVar, &rpt);
        }
        /* high search failure re-search with (score, +inf) limits */
        else if (score > beta && !(root->flags & exact))
        {
            replus++;
#ifdef QUIETBACKGROUND
            if (!background)
#endif /* QUIETBACKGROUND */
                ShowDepth('+');

            score = search(side, 1, Sdepth, -(SCORE_LIMIT + 999),
                           (SCORE_LIMIT + 999), PrVar, &rpt);
        }

        /**************** out of search ***********************************/
        CheckForTimeout(score, globalscore, Jscore, zwndw);

        /************************ time control ****************************/

        /* save PV as killer */
        for (i = 1; i <= Sdepth + 1; i++)
            killr0[i] = PrVar[i];

        if (!flag.timeout)
            Tscore[0] = score;

        /* if (!flag.timeout) */
        /*
          for (i = TrPnt[1] + 1; i < TrPnt[2]; i++)
          if (!pick (i, TrPnt[2] - 1))
          break;
        */

        /* if done or nothing good to look at quit */
        if ((root->flags & exact) || (score < -SCORE_LIMIT))
            flag.timeout = true;

        /* find the next best move put below root */

        if (!flag.timeout)
        {
#if !defined NODYNALPHA
            Jscore = (plyscore + score) >> 1;
#endif
            zwndw = 20 + abs(Jscore / 12);
            plyscore = score;

            /* recompute search window */
            beta = score + ((computer == white) ? BBwindow : WBwindow);
#if !defined NODYNALPHA
            alpha = ((Jscore < score) ? Jscore : score)
                - ((computer == white) ? BAwindow : WAwindow)
                - zwndw;
#else
            alpha = score - ((computer == white) ? BAwindow : WAwindow);
#endif
        }

#ifdef QUIETBACKGROUND
        if (!background)
#endif /* QUIETBACKGROUND */
            ShowResults(score, PrVar, '.');
    }
Пример #8
0
void
MainManager::Initialize()
{
	qRegisterMetaType<AnalysisRecord>();

	M4D::Imaging::APipeFilter *filter = new M4D::Imaging::ImageConvertor< InputImageType >();
	_conversionPipeline.AddFilter( filter );
	_inConnection =  static_cast< InImageConnection * >(&(_conversionPipeline.MakeInputConnection( *filter, 0, false )));
	_inConvConnection =  static_cast< ImageConnectionType * >(&(_conversionPipeline.MakeOutputConnection( *filter, 0, true ) ));


	CreateResultProcessPipeline();

	_resultsPage = new ResultsPage( *this );
	
	QObject::connect( this, SIGNAL(ResultProcessingStarted()), _resultsPage, SLOT( WaitForData() ), Qt::QueuedConnection );
	QObject::connect( this, SIGNAL(ShowResultsSignal( AnalysisRecord )), _resultsPage, SLOT( ShowResults( AnalysisRecord ) ), Qt::QueuedConnection );

	//TODO
}
void        Run( HWND hwnd)

{
    ULONG       rc;
    ULONG   	ctr;
    ULONG   	ulID;
    PRWSHDR     pHdr = 0;
    PRWSBLD     pBld;
    PRWSARG     pArg;
    char *      pBuf;
    char *      pErr = 0;

do
{
    ctr = sizeof(RWSBLD) + 6*sizeof(RWSARG);
    memset( (PVOID)argbuf, 0, ctr);

    pBld = (PRWSBLD)argbuf;
    pArg = CALCARGPTR( pBld);
    pBuf = &argbuf[ctr];

    pBld->ppHdr = &pHdr;

    if (GetProc( hwnd, pBld, &pBuf) == FALSE)
        ERRBREAK( "proc is missing or invalid")

    if (GetRtn( hwnd, pBld) == FALSE)
        ERRBREAK( "invalid return type")

    for (ctr=0, ulID=IDC_ARG1TYPE; ctr < 6; ctr++, ulID += 4)
    {
        rc = GetArg( hwnd, &pArg[ctr], ulID, &pBuf);
        if (rc)
            break;
        pBld->argCnt++;
    }
    if (rc == 2)
    {
        sprintf( rtnbuf, "\r\nArg%d is invalid\r\n", ctr+1);
        pErr = rtnbuf;
        break;
    }

    rc = RwsCallIndirect( pBld);
    if (rc)
    {
        pErr = rtnbuf + sprintf( rtnbuf, "\r\nRwsCallIndirect rc= %d (", rc);
        RwsGetRcString( rc, 256, pErr);
        strcat( pErr, ")\r\n");
        pErr = rtnbuf;
        break;
    }

    ShowResults( hwnd, pBld);

} while (fFalse);

    RwsFreeMem( pHdr);

    if (pErr)
    {
        WinSendDlgItemMsg( hwnd, IDC_RESULT, MLM_SETSEL, (MP)0x7fffffff, (MP)0x7fffffff);
        WinSendDlgItemMsg( hwnd, IDC_RESULT, MLM_SETFIRSTCHAR, (MP)0x7fffffff, 0);
        WinSendDlgItemMsg( hwnd, IDC_RESULT, MLM_INSERT, (MP)pErr, 0);
    }

    return;
}
Пример #10
0
FenPrincipale::FenPrincipale()
{	
	showMaximized();
	//showNormal();

	QMenu *menuFichier = menuBar()->addMenu("&Fichier");

	QAction *actionLoadImage = menuFichier->addAction("&Load Image");	
	actionLoadImage->setIcon(QIcon("Icons/fileopen.png"));
	menuFichier->addAction(actionLoadImage);

	QAction *actionExit = menuFichier->addAction("&Quitter");
	actionExit->setIcon(QIcon("Icons/fileclose.png"));
	menuFichier->addAction(actionExit);

	//QMenu *menuTools = menuBar()->addMenu("&Tools");

	QMenu *menuComm = menuBar()->addMenu("&Communication");

	QAction *actionSend = menuComm->addAction("&Send to server");	
	actionSend->setIcon(QIcon("Icons/ok.png"));

	// Création de la barre d'outils

    QToolBar *toolBarFichier = addToolBar("Fichier");
    toolBarFichier->addAction(actionLoadImage);
	toolBarFichier->addAction(actionExit);
	toolBarFichier->addSeparator();
	toolBarFichier->addAction(actionSend);
	
	QObject::connect(actionLoadImage, SIGNAL(triggered()), this, SLOT(LoadImageW()));
    QObject::connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
    QObject::connect(actionSend, SIGNAL(triggered()), this, SLOT(SendServer()));
	QObject::connect(actionSend, SIGNAL(triggered()), this, SLOT(ShowResults()));
    
	//
	// Création des docks
	//

	// dock IMAGE

	dockImage = new QDockWidget("Image", this);
	setCentralWidget(dockImage);

	ImageWidget = new QWidget;
	dockImage->setWidget(ImageWidget);

	// dock SERVEUR

	dockServeur = new QDockWidget("Serveur", this);
	addDockWidget(Qt::LeftDockWidgetArea, dockServeur);


	QWidget *paramDock = new QWidget;
	dockServeur->setWidget(paramDock);

	QSize s(220,20);

	adressServer1 = new QLineEdit(QString("138.195.102.25"));
	adressServer1->setMaximumSize(s);

	QHBoxLayout *adressLayout = new QHBoxLayout;
	adressLayout->addWidget(adressServer1);

	QWidget *adressWidget = new QWidget;
	adressWidget->setLayout(adressLayout);

	portAdressServer = new QLineEdit(QString("6006"));
	portAdressServer->setMaximumSize(s);

	QHBoxLayout *portLayout = new QHBoxLayout;
	portLayout->addWidget(portAdressServer);

	QWidget *portAdressWidget = new QWidget;
	portAdressWidget->setLayout(portLayout);

	QLabel *adressLabel = new QLabel("Adresse IP",paramDock);
	QLabel *portLabel = new QLabel("Port",paramDock);

	QPushButton *okServer = new QPushButton("Send");
	QObject::connect(okServer, SIGNAL(clicked()),this,SLOT(SendServer()));
	QObject::connect(okServer, SIGNAL(clicked()),this,SLOT(ShowResults()));

	QVBoxLayout *paramLayout = new QVBoxLayout(paramDock);
	paramLayout->addWidget(adressLabel);
	paramLayout->addWidget(adressWidget);
	paramLayout->addWidget(portLabel);
	paramLayout->addWidget(portAdressWidget);
	paramLayout->addWidget(okServer);
	paramLayout->setAlignment(Qt::AlignLeft);
	paramDock->setLayout(paramLayout);
	//dockServeur->setGeometry(QRect(100,200,200,250));
	dockServeur->setMaximumSize(250,200);

	// dock RESULTATS

	dockResults = new QDockWidget("Resultats",this);
	addDockWidget(Qt::RightDockWidgetArea, dockResults);
	dockResults->setMaximumWidth(250);

	WidgetResults = new QWidget;
	scrollArea = new QScrollArea;

	dockResults->setWidget(scrollArea);


	

	QPixmap *mini = new QPixmap(QString("test.jpg"));
	Result R(mini,98,"t");
	QPixmap *mini2 = new QPixmap(QString("9143.gif.jpg"));
	Result R2(mini2,95,"v");
	QPixmap *mini3 = new QPixmap(QString("test.jpg"));
	Result R3(mini3,92,"t");
	QPixmap *mini4 = new QPixmap(QString("test.jpg"));
	Result R4(mini4,90,"t");
	QPixmap *mini5 = new QPixmap(QString("test.jpg"));
	Result R5(mini5,88,"t");
	QPixmap *mini6 = new QPixmap(QString("test.jpg"));
	Result R6(mini6,86,"t");
	QPixmap *mini7 = new QPixmap(QString("test.jpg"));
	Result R7(mini7,84,"t");
	QPixmap *mini8 = new QPixmap(QString("test.jpg"));
	Result R8(mini8,82,"t");
	QPixmap *mini9 = new QPixmap(QString("test.jpg"));
	Result R9(mini9,81,"t");
	QPixmap *mini10 = new QPixmap(QString("test.jpg"));
	Result R10(mini10,79,"t");
	QPixmap *mini11 = new QPixmap(QString("test.jpg"));
	Result R11(mini11,78,"t");
	QPixmap *mini12 = new QPixmap(QString("test.jpg"));
	Result R12(mini12,77,"t");
	QPixmap *mini13 = new QPixmap(QString("test.jpg"));
	Result R13(mini13,76,"t");
	QPixmap *mini14 = new QPixmap(QString("test.jpg"));
	Result R14(mini14,75,"t");

	T.push_back(R);
	T.push_back(R2);
	T.push_back(R3);
	T.push_back(R4);
	T.push_back(R5);
	T.push_back(R6);
	T.push_back(R7);
	T.push_back(R8);
	T.push_back(R9);
	T.push_back(R10);
	T.push_back(R11);
	T.push_back(R12);
	T.push_back(R13);
	T.push_back(R14);

}
Пример #11
0
void main(int argc, char *argv[])
{
	// for region shape descriptor
	int				i, j, k, n, m, Count, TopNum, ClassNum, AllClassNum;
	pMatRes			pmr, pTop;
	int				SIM;
//	double			SIM;
//	clock_t			start, finish;
	FILE			*fpt, *fpt1, *fpt2, *fpt4;
	char			filename[200], cmpfn[200], srcfn[2000][200], destfn[200], c1[200];
	float			PreciseRecall[RESAM], OneClassPreciseRecall[RESAM], AllClassPreciseRecall[RESAM];
	float			locate, interpol_1, interpol_2;
	double			dtmp;
	clock_t			start, finish;

	// initialize: read camera pair
	fpt = fopen("q8_table", "rb");
	fread(q8_table, sizeof(unsigned char), 65536, fpt);
	fclose(fpt);

	// initialize: read camera pair
	fpt = fopen("align10.txt", "rb");
	fread(align10, sizeof(unsigned char), 60*CAMNUM_2, fpt);
	fclose(fpt);

	// read feature of all models
	fpt1 = fopen("list.txt", "r");
	Count = 0;
	while( fgets(destfn, 200, fpt1) )
	{
		// read coefficient from model 2
		destfn[strlen(destfn)-1] = 0x00;
		// #1
		sprintf(filename, "%s_q8_v1.8.art", destfn);
		if( (fpt = fopen(filename, "rb")) == NULL )				{	printf("%s does not exist.\n", filename);	continue;	}
		fread(dest_ArtCoeff[Count], ANGLE * CAMNUM * ART_COEF, sizeof(unsigned char), fpt);
		fclose(fpt);
		sprintf(filename, "%s_q8_v1.8.fd", destfn);
		if( (fpt = fopen(filename, "rb")) == NULL )				{	printf("%s does not exist.\n", filename);	continue;	}
		fread(dest_FdCoeff_q8[Count], sizeof(unsigned char),  ANGLE * CAMNUM * FD_COEF, fpt);
		fclose(fpt);
		sprintf(filename, "%s_q8_v1.8.cir", destfn);
		if( (fpt = fopen(filename, "rb")) == NULL )				{	printf("%s does not exist.\n", filename);	continue;	}
		fread(dest_CirCoeff_q8[Count], sizeof(unsigned char),  ANGLE * CAMNUM, fpt);
		fclose(fpt);
		sprintf(filename, "%s_q8_v1.8.ecc", destfn);
		if( (fpt = fopen(filename, "rb")) == NULL )				{	printf("%s does not exist.\n", filename);	continue;	}
		fread(dest_EccCoeff_q8[Count], sizeof(unsigned char),  ANGLE * CAMNUM, fpt);
		fclose(fpt);

/*		// #2
		sprintf(filename, "%s.sh", destfn);
		if( (fpt = fopen(filename, "rb")) == NULL )				{	printf("%s does not exist.\n", filename);	continue;	}
		for(i=0, k=0; i<SPHERE_NUM; i++)
		{
			fscanf(fpt, "%s", c1);
			for(j=0 ;j<HAMONIC_NUM; j++, k++)
			{
				fscanf(fpt, "%lf", &dtmp);
				SHdest_Coeff[Count][k] = dtmp;
			}
		}
		fclose(fpt);

		// #3
		sprintf(filename, "%s.s3d", destfn);
		if( (fpt = fopen(filename, "rb")) == NULL )				{	printf("%s does not exist.\n", filename);	continue;	}
		for(i=0; i<S3D_KEY_NUM; i++)
		{
			fscanf(fpt, "%lf", &dtmp);
			S3Ddest_Coeff[Count][i] = dtmp;
		}
		fclose(fpt);
*/
		Count ++;
	}
	fclose(fpt1);

	if( Count != ModelNum )
	{	printf("Error!!\n");	return ;	}

	// ****************
	// NNNNOOOOTTTTEEEE: the ModelNum should be the same as the number of all models
//	ModelNum = 1833;
	TopNum = ModelNum;		// show top 10
	pmr = (pMatRes) malloc (ModelNum * sizeof(MatRes));
	pTop = (pMatRes) malloc ( TopNum * sizeof(MatRes) );

	// initialize
	for(i=0; i<RESAM; i++)
		AllClassPreciseRecall[i] = 0;
	AllClassNum = 0;

	// read filename of two models
	fpt4 = fopen("compare.txt", "r");
	while( fscanf(fpt4, "%s", cmpfn) != EOF )
	{
		sprintf(filename, "%s.txt", cmpfn);
		fpt2 = fopen(filename, "r");
		ClassNum = 0;
		while( fgets(srcfn[ClassNum], 200, fpt2) )
		{
			srcfn[ClassNum][strlen(srcfn[ClassNum])-1] = 0x00;
			ClassNum++;
		}
		fclose(fpt2);

		AllClassNum += ClassNum;
		// initialize
		for(i=0; i<RESAM; i++)
			OneClassPreciseRecall[i] = 0;

		for(n=0; n<ClassNum; n++)
		{
			// read coefficient from model
			// #1
			// ART
			sprintf(filename, "%s_q8_v1.8.art", srcfn[n]);
			if( (fpt = fopen(filename, "rb")) == NULL )			{	printf("%s does not exist.\n", filename);	return;	}
			fread(src_ArtCoeff, SRC_ANGLE * CAMNUM * ART_COEF, sizeof(unsigned char), fpt);
			fclose(fpt);
			// FD
			sprintf(filename, "%s_q8_v1.8.fd", srcfn[n]);
			if( (fpt = fopen(filename, "rb")) == NULL )			{	printf("%s does not exist.\n", filename);	return;	}
			fread(src_FdCoeff_q8, sizeof(unsigned char),  ANGLE * CAMNUM * FD_COEF, fpt);
			fclose(fpt);
			// CIR
			sprintf(filename, "%s_q8_v1.8.cir", srcfn[n]);
			if( (fpt = fopen(filename, "rb")) == NULL )			{	printf("%s does not exist.\n", filename);	return;	}
			fread(src_CirCoeff_q8, sizeof(unsigned char),  ANGLE * CAMNUM, fpt);
			fclose(fpt);
			// ECC
			sprintf(filename, "%s_q8_v1.8.ecc", srcfn[n]);
			if( (fpt = fopen(filename, "rb")) == NULL )			{	printf("%s does not exist.\n", filename);	return;	}
			fread(src_EccCoeff_q8, sizeof(unsigned char),  ANGLE * CAMNUM, fpt);
			fclose(fpt);

			// #2
			//SH
/*			sprintf(filename, "%s.sh", srcfn[n]);
			if( (fpt = fopen(filename, "r")) == NULL )			{	printf("%s does not exist.\n", filename);	return;	}
			for(i=0, k=0; i<SPHERE_NUM; i++)
			{
				fscanf(fpt, "%s", c1);
				for(j=0 ;j<HAMONIC_NUM; j++, k++)
				{
					fscanf(fpt, "%lf", &dtmp);
					SHsrc_Coeff[k] = dtmp;
				}
			}
			fclose(fpt);

			// #3
			//S3D
			sprintf(filename, "%s.s3d", srcfn[n]);
			if( (fpt = fopen(filename, "r")) == NULL )			{	printf("%s does not exist.\n", filename);	return;	}
			for(i=0; i<S3D_KEY_NUM; i++)
			{
				fscanf(fpt, "%lf", &dtmp);
				S3Dsrc_Coeff[i] = dtmp;
			}
			fclose(fpt);
*/

			// record execute time --- start
			start = clock();

			// FIRST MATCH
			fpt1 = fopen("list.txt", "r");
			Count = 0;
			while( fgets(destfn, 200, fpt1) )
			{
				destfn[strlen(destfn)-1] = 0x00;
				// Matching
				// to be 1.0 : 0.55 : 0.48
//				SIM =	(double)MatchART_q8(dest_ArtCoeff[Count]) + 
//						(double)MatchFD_q8(dest_FdCoeff_q8[Count]) + 
//						16 * MatchSH(SHdest_Coeff[Count]) + 
//						2048 * MatchS3D(S3Ddest_Coeff[Count]);
//				SIM = MatchART_q8(dest_ArtCoeff[Count]) + MatchFD_q8(dest_FdCoeff_q8[Count]);
				SIM = MatchLF(dest_ArtCoeff[Count], dest_FdCoeff_q8[Count], dest_CirCoeff_q8[Count], dest_EccCoeff_q8[Count]);

				// add to a list
				strcpy(pmr[Count].name, destfn);
				pmr[Count].sim = SIM;
				pmr[Count].index = Count;

				Count ++;
			}
			fclose(fpt1);

			// sort
			for(i=0; i<TopNum; i++)
			{
				pTop[i].sim = INT_MAX;
				strcpy(pTop[i].name, "");
			}
			for(k=0; k<ModelNum; k++)
				for(i=0; i<TopNum; i++)
					if( pmr[k].sim < pTop[i].sim )
					{
						for(j=TopNum-2; j>=i; j--)
						{
							strcpy(pTop[j+1].name, pTop[j].name);
							pTop[j+1].sim = pTop[j].sim;
							pTop[j+1].index = pTop[j].index;
						}
						strcpy(pTop[i].name, pmr[k].name);
						pTop[i].sim = pmr[k].sim;
						pTop[i].index = pmr[k].index;
						break;
					}
		
			// record execute time --- end
			finish = clock();
			fpt = fopen("compare_time.txt", "a");
			fprintf(fpt, "%s: %f sec\n", srcfn[n], (double)(finish - start) / CLOCKS_PER_SEC );
			fclose(fpt);

			// check if each item is in this same class
			for(k=0; k<TopNum; k++)
			{
				pTop[k].Recall = 0;
				for(m=0; m<ClassNum; m++)
					if( strcmp(pTop[k].name, srcfn[m]) == 0 )
					{
						pTop[k].Recall = 1;
						break;
					}
			}

			// 1 1 0 0 1 0 1 0 0 0 1 ...
			// 1 2 2 2 3 3 4 4 4 4 5 ...
			for(k=1; k<TopNum; k++)
				pTop[k].Recall += pTop[k-1].Recall;

			// 1 2 2 2 3 3 4 4 4  4  5 ...  r
			// - - - - - - - - -  -  - ...  - =  precise ratio
			// 1 2 3 4 5 6 7 8 9 10 11 ...  K
			for(k=0; k<TopNum; k++)
			{
				if( pTop[k].Recall < ClassNum )
					pTop[k].Precise = (float)pTop[k].Recall / (float)(k+1);
				else if( pTop[k].Recall == ClassNum )
				{
					pTop[k].Precise = (float)pTop[k].Recall / (float)(k+1);
					//Recall = k+1;
					break;
				}
			}

			// ******************************************************************************
			// copy pTop[k].Precise according to the order of Recall
			// check if each item is in this same class
			i = 0;
			for(k=0; k<TopNum && i<ClassNum; k++)
			{
				for(m=0; m<ClassNum; m++)
					if( strcmp(pTop[k].name, srcfn[m]) == 0 )
					{
						pTop[i++].Precise = pTop[k].Precise;
						break;
					}
			}

			// normaliza K (recall all) to 1000
			for(i=0; i<RESAM; i++)
			{
				locate = (float) (i * (ClassNum-1)) / (float) (RESAM-1);
				interpol_1 = locate - (int)locate;
				interpol_2 = 1.0f - interpol_1;
				PreciseRecall[i] =	interpol_2 * pTop[(int)locate].Precise +
									interpol_1 * pTop[(int)locate+1].Precise;
				// in average
				OneClassPreciseRecall[i] += PreciseRecall[i];
				// all class in average
				AllClassPreciseRecall[i] += PreciseRecall[i];
			}
//			sprintf(filename, "Results\\%s\\%s_%03d__LightField_v1.7.txt", cmpfn, cmpfn, n);
//			fpt = fopen(filename, "w");
	//		fprintf(fpt, "%s - Recall: %d/%d\n", srcfn[n], ClassNum, Recall);
//			for(i=0; i<RESAM; i++)
//				fprintf(fpt, "%f\n", PreciseRecall[i]);
//			fprintf(fpt, "\n");
//			fclose(fpt);

			printf("%s_%03d\n", cmpfn, n);

			//Show results
			sprintf(filename, "Results\\%s\\%s_%03d_v1.8.html", cmpfn, cmpfn, n);
			ShowResults(filename, pTop, ClassNum);
		}

		// in average
		sprintf(filename, "Results\\%s\\%s_v1.8.txt", cmpfn, cmpfn);
		fpt = fopen(filename, "w");
	//	fprintf(fpt, "%s - Recall: %d/%d\n", srcfn[n], ClassNum, Recall);
		for(i=0; i<RESAM; i++)
			fprintf(fpt, "%f\n", OneClassPreciseRecall[i] / ClassNum );
		fprintf(fpt, "\n");
		fclose(fpt);

		printf("\"%s\" OK.\n", cmpfn);
	}

	// all class in average
	sprintf(filename, "Results\\total_v1.8.txt");
	fpt = fopen(filename, "w");
//	fprintf(fpt, "%s - Recall: %d/%d\n", srcfn[n], ClassNum, Recall);
	for(i=0; i<RESAM; i++)
		fprintf(fpt, "%f\n", AllClassPreciseRecall[i] / AllClassNum );
	fprintf(fpt, "\n");
	fclose(fpt);

	printf("\"%s\" OK.\n", cmpfn);
	
	fclose(fpt4);
	
	free(pmr);
	free(pTop);
}