Beispiel #1
0
 GeoPoint ToGeoPoint(lua_State *L, int idx) {
   lua_getfield(L, 1, "longitude");
   lua_getfield(L, 1, "latitude");
   GeoPoint value(ToAngle(L, -2), ToAngle(L, -1));
   lua_pop(L, 2);
   return value;
 }
void CDrawLine::Move(CDPoint p, CDPoint no_snap_p)
{
  if (!m_segment) 
  {
	  BOOL new_is_stuck = FALSE;
	  BOOL new_is_junction = FALSE;

	  // Are we a line to be snapped to pins?
	  if (xtype == xWire)
	  {
		  p = m_pDesign->GetStickyPoint(p, TRUE,TRUE,new_is_stuck,new_is_junction);
	  }


	  if (p != m_point_b)
	  {
		Display();
		is_stuck = new_is_stuck;
		is_junction = new_is_junction;
		m_point_b=p;
		ToAngle();
		Display();
	  }
  }
  else
  {
	  Display();
	  m_point_b = GetStickyPoint( p );
	  m_point_a = m_point_b;
	  Display();
  }
}
void CDrawLine::LButtonDown(CDPoint p, CDPoint s)
{
  // New undo level for each placement...
  m_pDesign->BeginNewChangeSet();


  p = GetStickyPoint( p );

  if (m_segment) 
  {
	m_point_a=p;
	m_point_b=p;
	m_segment=!m_segment;

	  if (is_junction)
	  {
		  m_pDesign->AddNewJunction( m_point_a );
	  }

	  // If there was an object of the same type under this point,
	  // then take it's colour & style
	  drawingIterator i = m_pDesign->GetDrawingBegin();
	  while (i != m_pDesign->GetDrawingEnd())
	  {
		  if ((*i)->GetType() == xtype)
		  {
			  // Is this within our start range?
			  CDrawLine *line = static_cast<CDrawLine*>(*i);
			  CLineUtils l( line->m_point_a, line->m_point_b );
			  double d;
			  if (l.IsPointOnLine( p,d ))
			  {
				  m_use_default_style = line->m_use_default_style;
				  m_style = line->m_style;
				  break;
			  }
		  }
		  ++ i;
	  }
  } 
  else 
  {
	m_point_b=p;
	ToAngle();
	// Remove from screen
	Display();
	CDPoint c=m_point_b;

	switch (g_EditToolBar.m_DrawLineEdit.mode) {
		case 1: m_point_b=CDPoint(m_point_b.x,m_point_a.y);
			break;
		case 2: m_point_b=CDPoint(m_point_a.x,m_point_b.y);
			break;
	}
	
	BOOL was_stuck = is_stuck;
	if (is_stuck && g_EditToolBar.m_DrawLineEdit.mode > 0)
	{
		int old_is_junction = is_junction;
		is_junction = FALSE;

		// Place two lines
		is_stuck = FALSE;
		if (m_point_a != m_point_b)
		{
			// Store and then Check for merge & junctions
			m_drag_utils_a.MergeLinePoint( Store() );
		}
		m_point_a = m_point_b;
		m_point_b = c;

		is_junction = old_is_junction;
	}
	is_stuck = FALSE;
	if (m_point_a != m_point_b)
	{
	    // Store and then Check for merge & junctions
	    m_drag_utils_a.MergeLinePoint( Store() );
	}
	Display();	// Write to screen

	if (!was_stuck)
	{
		m_point_a=m_point_b;
		m_point_b=c;
		m_segment=0;
		ToAngle();
	}
	else
	{
		RButtonDown(p,s);
	}
  }
  Display();
}