Beispiel #1
0
/// Read the source slit sizes from a config file string
/// @param line :: line (string) from the config file
void EQSANSLoad::readSourceSlitSize(const std::string &line) {
  boost::regex re_key("wheel", boost::regex::icase);
  if (boost::regex_search(line, re_key)) {
    boost::regex re_sig("([1-8]) wheel[ ]*([1-3])[ \\t]*=[ \\t]*(\\w+)");
    boost::smatch posVec;
    if (boost::regex_search(line, posVec, re_sig)) {
      if (posVec.size() == 4) {
        std::string num_str = posVec[1];
        int slit_number = 0;
        Poco::NumberParser::tryParse(num_str, slit_number);
        slit_number--;

        num_str = posVec[2];
        int wheel_number = 0;
        Poco::NumberParser::tryParse(num_str, wheel_number);
        wheel_number--;

        num_str = posVec[3];
        boost::regex re_size("\\w*?([0-9]+)mm");
        int slit_size = 0;
        if (boost::regex_search(num_str, posVec, re_size)) {
          if (posVec.size() == 2) {
            num_str = posVec[1];
            Poco::NumberParser::tryParse(num_str, slit_size);
          }
        }
        m_slit_positions[wheel_number][slit_number] = slit_size;
      }
    }
  }
}
Beispiel #2
0
/// Read the source slit sizes from a config file string
/// @param line :: line (string) from the config file
void EQSANSLoad::readSourceSlitSize(const std::string& line)
{
  Poco::RegularExpression re_key("wheel", Poco::RegularExpression::RE_CASELESS);
  Poco::RegularExpression::Match match;
  if (re_key.match(line, 0, match))
  {
    Poco::RegularExpression re_sig("([1-8]) wheel[ ]*([1-3])[ \\t]*=[ \\t]*(\\w+)");
    if (re_sig.match(line, 0, match))
    {
      Poco::RegularExpression::MatchVec posVec;
      re_sig.match(line, 0, posVec);
      if (posVec.size()==2)
      {
        std::string num_str = line.substr(posVec[1].offset, posVec[1].length);
        int slit_number = 0;
        Poco::NumberParser::tryParse(num_str, slit_number);
        slit_number--;

        num_str = line.substr(posVec[2].offset, posVec[2].length);
        int wheel_number = 0;
        Poco::NumberParser::tryParse(num_str, wheel_number);
        wheel_number--;

        num_str = line.substr(posVec[3].offset, posVec[3].length);
        Poco::RegularExpression re_size("\\w*?([0-9]+)mm");
        int slit_size = 0;
        re_size.match(num_str, 0, posVec);
        if (posVec.size()==2)
        {
          num_str = line.substr(posVec[1].offset, posVec[1].length);
          Poco::NumberParser::tryParse(num_str, slit_size);
        }
        m_slit_positions[wheel_number][slit_number] = slit_size;
      }
    }
  }
}
Beispiel #3
0
bool opengl_render::init_render(void* ctx, int w, int h, int pix_fmt)
{
	m_hwnd = (HWND)ctx;
	m_image_width = w;
	m_image_height = h;
	m_window_aspect = (float)w / (float)h;

	static PIXELFORMATDESCRIPTOR pfd =  // pfd Tells Windows How We Want Things To Be
	{
		sizeof(PIXELFORMATDESCRIPTOR),	// Size Of This Pixel Format Descriptor
		1,											// Version Number
		PFD_DRAW_TO_WINDOW |					// Format Must Support Window
		PFD_SUPPORT_OPENGL |					// Format Must Support OpenGL
		PFD_DOUBLEBUFFER,						// Must Support Double Buffering
		PFD_TYPE_RGBA,                   // Request An RGBA Format
		24,										// Select Our Color Depth
		0, 0, 0, 0, 0, 0,						// Color Bits Ignored
		0,											// No Alpha Buffer
		0,											// Shift Bit Ignored
		0,											// No Accumulation Buffer
		0, 0, 0, 0,								// Accumulation Bits Ignored
		16,										// 16Bit Z-Buffer (Depth Buffer)  
		0,											// No Stencil Buffer
		0,											// No Auxiliary Buffer
		PFD_MAIN_PLANE,						// Main Drawing Layer
		0,											// Reserved
		0, 0, 0									// Layer Masks Ignored
	};

	if (!(m_hdc = GetDC(m_hwnd)))
	{
		printf("Can't Create A GL Device Context.\n");
		return false;
	}

	GLuint PixelFormat;

	if (!(PixelFormat = ChoosePixelFormat(m_hdc, &pfd)))	// Did Windows Find A Matching Pixel Format?
	{
		printf("Can't Find A Suitable PixelFormat.\n");
		return false;
	}

	if(!SetPixelFormat(m_hdc, PixelFormat, &pfd))        // Are We Able To Set The Pixel Format?
	{
		printf("Can't Set The PixelFormat.\n");
		return false;
	}

	if (!(m_hglrc = wglCreateContext(m_hdc)))  // Are We Able To Get A Rendering Context?
	{
		printf("Can't Create A GL Rendering Context.\n");
		return false;
	}

	if(!wglMakeCurrent(m_hdc, m_hglrc))        // Try To Activate The Rendering Context
	{
		printf("Can't Activate The GL Rendering Context.\n");
		return false;
	}

	RECT rc = { 0 };
	GetClientRect(m_hwnd, &rc);

	re_size(rc.right - rc.left, rc.bottom - rc.top);
	if (!InitGL())
	{
		printf("Initialization Failed.\n");
		return false;
	}

	m_swsctx = sws_getContext(m_image_width, m_image_height, PIX_FMT_YUV420P, m_image_width, m_image_height, 
		PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);

	m_current_width = m_image_width;
	m_current_height = m_image_height;
	m_framebuffer = (uint8_t*)malloc(w * h * sizeof(uint32_t));

	return true;
}