Exemplo n.º 1
0
void RubberSheet::applyTransform(shared_ptr<OsmMap>& map)
{
  _map = map;

  if (!_interpolator2to1)
  {
    LOG_WARN("No appropriate interpolator was specified, skipping rubber sheet transform.");
    return;
  }

  if (_projection.get() != 0)
  {
    MapReprojector::reproject(_map, _projection);
  }
  else
  {
    // if it is already planar then nothing will be done.
    MapReprojector::reprojectToPlanar(_map);
  }

  const OsmMap::NodeMap& nm = map->getNodeMap();
  for (OsmMap::NodeMap::const_iterator it = nm.constBegin(); it != nm.constEnd(); ++it)
  {
    const shared_ptr<Node>& n = it.value();

    if (_ref == false || n->getStatus() == Status::Unknown2)
    {
      Coordinate c = n->toCoordinate();
      Coordinate newC = _translate(c, n->getStatus());

      n->setX(newC.x);
      n->setY(newC.y);
    }
  }
}
Exemplo n.º 2
0
/**
 * vsg_matrix3@t@_translate_new:
 * @x: a #@type@
 * @y: a #@type@
 *
 * Creates a new #VsgMatrix3@t@ corresponding to a 2D translation with
 * coordinates (@x,@y).
 *
 * Returns: new #VsgMatrix3@t@ instance
 */
VsgMatrix3@t@ *vsg_matrix3@t@_translate_new (@type@ x, @type@ y)
{
  VsgMatrix3@t@ *result = vsg_matrix3@t@_identity_new ();

  vsg_matrix3@t@_translate (result, x, y);

  return result;

}
Exemplo n.º 3
0
void ToEnglishTranslationVisitor::visit(const boost::shared_ptr<Element>& e)
{
  if (_tagKeys.isEmpty())
  {
    throw HootException("No tag keys specified for language translation.");
  }

  LOG_VART(e);

  //if this var was set while parsing the previous element, increment the counter now
  if (_currentElementHasSuccessfulTagTranslation)
  {
    _numElementsWithSuccessfulTagTranslation++;
  }
  _currentElementHasSuccessfulTagTranslation = false;

  const Tags& tags = e->getTags();
  bool elementProcessed = false;
  for (QSet<QString>::const_iterator tagKeysItr = _tagKeys.begin();
       tagKeysItr != _tagKeys.end(); ++tagKeysItr)
  {
    const QString toTranslateTagKey = *tagKeysItr;
    if (tags.contains(toTranslateTagKey))
    {     
      //making skipping tags that already have an english translated tag optional, b/c a many of the
      //OSM english translations I've seen are either just copies of the foreign language text or are
      //not very good translations
      const QString preTranslatedTagKey = toTranslateTagKey + ":en";
      if (!_ignorePreTranslatedTags && tags.contains(preTranslatedTagKey))
      {
        LOG_TRACE(
          "Skipping element with pre-translated tag: " << preTranslatedTagKey << "=" <<
          tags.get(toTranslateTagKey).trimmed());
      }
      else
      {
        _translate(e, toTranslateTagKey);
        elementProcessed = true;
      }
    }
  }

  if (elementProcessed)
  {
    _numProcessedElements++;
    if (_numProcessedElements % _taskStatusUpdateInterval == 0)
    {
      PROGRESS_INFO("Attempted tag translation for " << _numProcessedElements << " elements.");
    }
  }

  _numTotalElements++;
  if (_numTotalElements % _taskStatusUpdateInterval == 0)
  {
    PROGRESS_INFO("Visited " << _numTotalElements << " elements.");
  }
}
Exemplo n.º 4
0
	/**
	 *  @param target use the buffer bound to the target specified
	 *  @param access the access specifier for the buffer mapping
	 *
	 * This class is non-copyable.
	 *
	 *  @glsymbols
	 *  @glfunref{MapBuffer}
	 *
	 *  @throws Error
	 */
	BufferRawMap(BufferTarget target, Bitfield<BufferMapAccess> access)
	 : _offset(0)
	 , _size(_get_size(target))
	 , _ptr(
		OGLPLUS_GLFUNC(MapBuffer)(
			GLenum(target),
			_translate(GLbitfield(access))
		)
	), _target(target)
	{
		OGLPLUS_CHECK(
			MapBuffer,
			ObjectError,
			ObjectBinding(_target)
		);
	}
Exemplo n.º 5
0
	/**
	 *  @param buffer use the specified buffer
	 *  @param access the access specifier for the buffer mapping
	 *
	 * This class is non-copyable.
	 *
	 *  @throws Error
	 */
	DSABufferRawMapEXT(
		BufferName buffer,
		Bitfield<BufferMapAccess> access
	): _offset(0)
	 , _size(_get_size(GetGLName(buffer)))
	 , _ptr(
		OGLPLUS_GLFUNC(MapNamedBufferEXT)(
			GetGLName(buffer),
			_translate(GLbitfield(access))
		)
	), _buf_name(GetGLName(buffer))
	{
		OGLPLUS_CHECK(
			MapNamedBufferEXT,
			ObjectError,
			Object(buffer)
		);
	}
Exemplo n.º 6
0
void cdxCDynamicWnd::DoInitWindow(CWnd & rWnd, const CSize & szInitial)
{
	ASSERT(::IsWindow(rWnd.m_hWnd) && szInitial.cx && szInitial.cy);	// ensure the window exists ...

	m_iDisabled		=	0;
	m_pWnd		=	&rWnd;
	m_szInitial	=	szInitial;
	m_szMin		=	szInitial;

	/*
	 * this window will flicker somewhat deadly if you do not have the
	 * WS_CLIPCHILDREN style set for you window.
	 * You may like to use the following line anywhere
	 * to apply it:
	 
		  CWnd::ModifyStyle(0,WS_CLIPCHILDREN);

    */

#ifdef _DEBUG
	if(!(rWnd.GetStyle() & WS_CLIPCHILDREN) && !(m_nFlags & flSWPCopyBits))
	{
		TRACE(_T("***\n"
					"*** cdxCDynamicWnd class note: If your window flickers too much, add the WS_CLIPCHILDREN style to it\n"
					"***                            or try to set the flSWPCopyBits flags !!!\n"
					"***\n"));
	}
#endif

	//
	// now, if a DYNAMIC MAP is been defined,
	// we start working with it
	//

	const __dynEntry	*pEntry,*pLast	=	NULL;
	UINT					nInitCnt	=	GetCtrlCount();

	if(pLast = __getDynMap(pLast))
	{
		HWND		hwnd;
		SBYTES	bytes;

		for(pEntry = pLast; pEntry->type != __end; ++pEntry)
		{
			if((pEntry->id != DYNAMIC_MAP_DEFAULT_ID)
				&& !( hwnd = ::GetDlgItem(m_pWnd->m_hWnd,pEntry->id) ))
			{
				TRACE(_T("*** NOTE[cdxCDynamicWnd::DoInitWindow()]: Dynamic map initialization: There's no control with the id 0x%lx !\n"),pEntry->id);
				continue;
			}

			switch(pEntry->type)
			{
				case	__bytes:

					bytes[X1]	=	pEntry->b1;
					bytes[Y1]	=	pEntry->b2;
					bytes[X2]	=	pEntry->b3;
					bytes[Y2]	=	pEntry->b4;
					break;

				case	__modes:
					
					_translate((Mode)pEntry->b1,bytes[X1],bytes[X2]);
					_translate((Mode)pEntry->b2,bytes[Y1],bytes[Y2]);
					break;

				default:

					ASSERT(false);		// never come here !!!!!
					break;
			}

			if(pEntry->id == DYNAMIC_MAP_DEFAULT_ID)
				AllControls(bytes,false,false);
			else
				AddSzControl(hwnd,bytes,M_szNull,false);
		}
	}

	//
	// handle creation flags
	//

	if(m_nFlags & flSizeIcon)
	{
		m_pSizeIcon	=	WNEW cdxCSizeIconCtrl;
		VERIFY( m_pSizeIcon->Create(m_pWnd) );

		AddSzControl(m_pSizeIcon->m_hWnd,BotRight,M_szNull,false);
		m_pSizeIcon->ShowWindow(SW_SHOW);
	}

	m_bIsAntiFlickering	=	false;
	m_nMyTimerID			=	DEFAULT_TIMER_ID;
	m_dwClassStyle			=	::GetClassLong(*m_pWnd,GCL_STYLE) & (CS_VREDRAW|CS_HREDRAW);

	OnInitialized();

	if(nInitCnt < GetCtrlCount())
		Layout();
}
Exemplo n.º 7
0
static svg_status_t _SDL_SVG_ApplyViewBox (void *closure,
                                           svg_view_box_t view_box,
                                           svg_length_t *width,
                                           svg_length_t *height)
{
SDL_svg_context *c = closure;
double vpar, svgar;
double logic_width, logic_height;
double logic_x, logic_y;
double phys_width, phys_height;

	dprintf("svg_ApplyViewBox\n");

	phys_width = ConvertLength(width);
	phys_height = ConvertLength(height);

	vpar = view_box.box.width / view_box.box.height;
	svgar = phys_width / phys_height;
	logic_x = view_box.box.x;
	logic_y = view_box.box.y;
	logic_width = view_box.box.width;
	logic_height = view_box.box.height;

	if (view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_NONE)
	{
		_scale (c,
			 phys_width / logic_width,
			 phys_height / logic_height);
		_translate (c, -logic_x, -logic_y);
	} else if((vpar < svgar &&
			view_box.meet_or_slice == SVG_MEET_OR_SLICE_MEET) ||
			(vpar >= svgar &&
			view_box.meet_or_slice == SVG_MEET_OR_SLICE_SLICE))
	{
		_scale (c,
			phys_height / logic_height, phys_height / logic_height);

		if (view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMINYMIN ||
			view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMINYMID ||
			view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMINYMAX)
			_translate (c, -logic_x, -logic_y);
		else if(view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMIDYMIN ||
			view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMIDYMID ||
			view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMIDYMAX)
			_translate (c,
				 -logic_x - (logic_width - phys_width * logic_height / phys_height) / 2,
				 -logic_y);
		else
			_translate (c,
			 -logic_x - (logic_width - phys_width * logic_height / phys_height),
			 -logic_y);
	} else
	{
		_scale (c, phys_width / logic_width, phys_width / logic_width);

		if (view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMINYMIN ||
			view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMIDYMIN ||
			view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMAXYMIN)
			_translate (c, -logic_x, -logic_y);
		else if(view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMINYMID ||
			view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMIDYMID ||
			view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMAXYMID)
			_translate (c,
				 -logic_x,
				 -logic_y - (logic_height - phys_height * logic_width / phys_width) / 2);
		else
			_translate (c,
			 -logic_x,
			 -logic_y - (logic_height - phys_height * logic_width / phys_width));
	}



	return SVG_STATUS_SUCCESS;
}