コード例 #1
0
void GammaBlockFileWrite::processData(wxSharedPtr<GammaData> sDataIn)
{
	wxMutexLocker locker(m_processDataMutex);

	if(!m_file.IsOpened())
	{
		switch(sDataIn->type)
		{
		case GAMMA_DATA_TYPE_ITEMS:
			m_file.Open(wxDateTime::Now().Format("%Y%m%d_%H%M%S.gvb"), 
				wxFile::write);
			m_file.Write("GVB", 3);
			break;
		case GAMMA_DATA_TYPE_MATRIX:
			m_file.Open(wxDateTime::Now().Format("%Y%m%d_%H%M%S.gvm"), 
				wxFile::write);
			m_file.Write("GVM", 3);
			break;
		default:
			wxASSERT_MSG(0, _("Not implemented!"));
			return;
		}
	}

	switch(sDataIn->type)
	{
	case GAMMA_DATA_TYPE_ITEMS:
		{
			GammaItems* pDataIn = dynamic_cast<GammaItems*>(sDataIn.get());

			for( std::vector<GammaItem>::iterator iItem = pDataIn->items.begin();
				iItem != pDataIn->items.end(); iItem++ )
			{
				m_file.Write(&(*iItem), sizeof(GammaItem));
			}

			break;
		}
	case GAMMA_DATA_TYPE_MATRIX:
		{
			GammaMatrix* pDataIn = dynamic_cast<GammaMatrix*>(sDataIn.get());
			
			m_file.Write(pDataIn, sizeof(GammaMatrix));

			break;
		}
	default:
		break;
	}
}
コード例 #2
0
ファイル: webview_ie.cpp プロジェクト: lukesingh24/wxWidgets
void wxWebViewIE::LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item)
{
    int pos = -1;
    for(unsigned int i = 0; i < m_historyList.size(); i++)
    {
        //We compare the actual pointers to find the correct item
        if(m_historyList[i].get() == item.get())
            pos = i;
    }
    wxASSERT_MSG(pos != static_cast<int>(m_historyList.size()),
                 "invalid history item");
    m_historyLoadingFromList = true;
    LoadURL(item->GetUrl());
    m_historyPosition = pos;
}
コード例 #3
0
ファイル: webview_ie.cpp プロジェクト: lukesingh24/wxWidgets
void wxWebViewIE::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
{
    wxDynamicLibrary urlMon(wxT("urlmon.dll"));
    if(urlMon.HasSymbol(wxT("CoInternetGetSession")))
    {
        typedef HRESULT (WINAPI *CoInternetGetSession_t)(DWORD, wxIInternetSession**, DWORD);
        wxDYNLIB_FUNCTION(CoInternetGetSession_t, CoInternetGetSession, urlMon);

        ClassFactory* cf = new ClassFactory(handler);
        wxIInternetSession* session;
        HRESULT res = (*pfnCoInternetGetSession)(0, &session, 0);
        if(FAILED(res))
        {
            wxFAIL_MSG("Could not retrive internet session");
        }

        HRESULT hr = session->RegisterNameSpace(cf, CLSID_FileProtocol,
                                                handler->GetName().wc_str(),
                                                0, NULL, 0);
        if(FAILED(hr))
        {
            wxFAIL_MSG("Could not register protocol");
        }
        m_factories.push_back(cf);
    }
    else
    {
        wxFAIL_MSG("urlmon does not contain CoInternetGetSession");
    }
}
コード例 #4
0
ファイル: wxhexdatapanel.cpp プロジェクト: wxIshiko/wxHex
void wxHexDataPanel::Init(wxSharedPtr<wxHexData> data)
{
	m_startOffset = 0;
	m_data = data;
	m_count = data->GetLength();

	InvalidateBestSize();
	Refresh();
	PostSizeEventToParent();
}
コード例 #5
0
    virtual bool DoRemove(wxSharedPtr<wxFSWatchEntryUnix> watch)
    {
        wxCHECK_MSG( IsOk(), false,
                    "Inotify not initialized or invalid inotify descriptor" );

        int ret = DoRemoveInotify(watch.get());
        if (ret == -1)
        {
            wxLogSysError( _("Unable to remove inotify watch") );
            return false;
        }

        if (m_watchMap.erase(watch->GetWatchDescriptor()) != 1)
        {
            wxFAIL_MSG( wxString::Format("Path %s is not watched",
                                          watch->GetPath()) );
        }
        watch->SetWatchDescriptor(-1);
        return true;
    }
コード例 #6
0
    virtual bool DoRemove(wxSharedPtr<wxFSWatchEntryUnix> watch)
    {
        wxCHECK_MSG( IsOk(), false,
                    "Inotify not initialized or invalid inotify descriptor" );

        int ret = DoRemoveInotify(watch.get());
        if (ret == -1)
        {
            // Failures can happen if a dir is deleted just before we try to
            // remove the watch. I think there's a race between calling this
            // code and IN_DELETE_SELF arriving. So just warn.
            wxFileSystemWatcherEvent
                event
                (
                    wxFSW_EVENT_WARNING, wxFSW_WARNING_GENERAL,
                    wxString::Format
                    (
                     _("Unable to remove inotify watch %i"),
                     watch->GetWatchDescriptor()
                    )
                );
            SendEvent(event);
        }

        if (m_watchMap.erase(watch->GetWatchDescriptor()) != 1)
        {
            wxFAIL_MSG( wxString::Format("Path %s is not watched",
                                          watch->GetPath()) );
        }
        // Cache the wd in case any events arrive late
        m_staleDescriptors.Add(watch->GetWatchDescriptor());

        watch->SetWatchDescriptor(-1);
        return true;
    }
コード例 #7
0
    virtual bool DoAdd(wxSharedPtr<wxFSWatchEntryUnix> watch)
    {
        wxCHECK_MSG( IsOk(), false,
                    "Inotify not initialized or invalid inotify descriptor" );

        int wd = DoAddInotify(watch.get());
        if (wd == -1)
        {
            wxLogSysError( _("Unable to add inotify watch") );
            return false;
        }

        wxFSWatchEntryDescriptors::value_type val(wd, watch.get());
        if (!m_watchMap.insert(val).second)
        {
            wxFAIL_MSG( wxString::Format( "Path %s is already watched",
                                           watch->GetPath()) );
            return false;
        }

        return true;
    }
コード例 #8
0
ファイル: fswatcher_kqueue.cpp プロジェクト: madnessw/thesnow
    virtual bool DoAdd(wxSharedPtr<wxFSWatchEntryKq> watch)
    {
        wxCHECK_MSG( IsOk(), false,
                    "Kqueue not initialized or invalid kqueue descriptor" );

        struct kevent event;
        int action = EV_ADD | EV_ENABLE | EV_CLEAR | EV_ERROR;
        int flags = Watcher2NativeFlags(watch->GetFlags());
        EV_SET( &event, watch->GetFileDescriptor(), EVFILT_VNODE, action,
                flags, 0, watch.get() );

        // TODO more error conditions according to man
        // TODO best deal with the error here
        int ret = kevent(m_kfd, &event, 1, NULL, 0, NULL);
        if (ret == -1)
        {
            wxLogSysError(_("Unable to add kqueue watch"));
            return false;
        }

        return true;
    }
コード例 #9
0
ファイル: fswatcher_kqueue.cpp プロジェクト: madnessw/thesnow
    virtual bool DoRemove(wxSharedPtr<wxFSWatchEntryKq> watch)
    {
        wxCHECK_MSG( IsOk(), false,
                    "Kqueue not initialized or invalid kqueue descriptor" );

        // TODO more error conditions according to man
        // XXX closing file descriptor removes the watch. The logic resides in
        // the watch which is not nice, but effective and simple
        bool ret = watch->Close();
        if (ret == -1)
        {
            wxLogSysError(_("Unable to remove kqueue watch"));
            return false;
        }

        return true;
    }
コード例 #10
0
void GammaTransMI::processData(wxSharedPtr<GammaData> sDataIn)
{
	wxMutexLocker locker(m_processDataMutex);

	wxASSERT(GAMMA_DATA_TYPE_MATRIX == sDataIn->type);
	GammaMatrix* pDataIn = dynamic_cast<GammaMatrix*>(sDataIn.get());
	wxSharedPtr<GammaData> sDataOut(new GammaImage());
	GammaImage* pDataOut = dynamic_cast<GammaImage*>(sDataOut.get());

	calcMax(pDataIn->eventMax());

	calcColour(0);
	pDataOut->image.SetRGB( wxRect(0, 0, 256, 256), 
		m_colour.Red(), m_colour.Green(), m_colour.Blue() );

	for(wxUint32 y = 0; y < 256; y++)
	{
		for(wxUint32 x = 0; x < 256; x++)
		{
			if(pDataIn->matrix[POINT(x,y)])
			{
				calcColour(pDataIn->matrix[POINT(x,y)]);
				pDataOut->image.SetRGB( x, y, 
					m_colour.Red(), m_colour.Green(), m_colour.Blue() );
			}
		}
	}

/*	if(GAMMA_TRIG_NONE != pDataIn->trig)
	{
		getManager()->DataTierSetParam(GAMMA_PARAM_UNIFORM_MATRIX_SET, pDataIn->matrix);
		getManager()->PresentationTierSetParam(GAMMA_PARAM_TRIG_TYPE, &pDataIn->trig);
	}
*/
/*	wxLogStatus("eventMax = %u, m_max = %f, eventSum = %"wxLongLongFmtSpec"d, span = %"wxLongLongFmtSpec"d freq = %f k/s", 
		pDataIn->eventMax, m_max, pDataIn->eventSum, pDataIn->span.GetValue().GetValue(), 
		(double)pDataIn->eventSum / pDataIn->span.GetValue().GetValue());
*/

	getManager()->PresentationTierSetParam(GAMMA_PARAM_DATA_TYPE_MATRIX, (void*)pDataIn);

	getManager()->PresentationTierSetParam(GAMMA_PARAM_IMG_DATA, (void*)&pDataOut->image);
	getManager()->PresentationTierSetParam(GAMMA_PARAM_TIME_NOW, &pDataIn->acqTime);

	pushData(sDataOut);
}
コード例 #11
0
void GammaNemaCalc::processData(wxSharedPtr<GammaData> pData)
{	
	wxMutexLocker locker(m_processDataMutex);

	wxASSERT(GAMMA_DATA_TYPE_MATRIX == pData->type);
	m_pDataIn = dynamic_cast<GammaMatrix*>(pData.get());
	GammaMatrix* pDataOut(new GammaMatrix);

	floodFill(wxPoint(0,0), 0);
	marginalRemove();

	convolutionFilter(pDataOut);

	memcpy(m_pDataIn->matrix, pDataOut->matrix, sizeof(wxUint32) * 256 * 256);
	pDataOut->acqTime = m_pDataIn->acqTime;

	wxLogStatus("Intg = %f, Diff(X) = %f, Diff(Y) = %f", 
		getIntgUniformity(), 
		getDiffUniformity(GAMMA_DIRECTION_X), 
		getDiffUniformity(GAMMA_DIRECTION_Y));

	pushData(wxSharedPtr<GammaData>(pDataOut));
}