BOOL CTinyCadDoc::Import( CStream& ar )
{
	drawingCollection drawing;

	if (ReadFile(ar, FALSE, drawing) )
	{
		
		for( drawingCollection::iterator i = drawing.begin(); i != drawing.end(); i++ )
		{
			Add( *i );
		}
		UnSelect();
		SetModifiedFlag( FALSE );

		// Now select the objects
		UnSelect();
		
		for( drawingIterator j = drawing.begin(); j != drawing.end(); j++ )
		{
			Select( *j );
		}

		return TRUE;
	}

	return FALSE;
}
Beispiel #2
0
void CheckboxComponent::CheckMouseCollision()
{
	Vector2f diff = g_input->GetMousePosition() - m_object->GetGlobalPos();
	float alpha = -m_object->GetGlobalRotation() * (float)PI / 180.f;
	Vector2f rotatedDiff = Vector2f(diff.x * cos(alpha) - diff.y * sin(alpha), diff.x * sin(alpha) + diff.y * cos(alpha));

	if (rotatedDiff.x >= 0 &&
		rotatedDiff.y >= 0 &&

		rotatedDiff.x <= m_size.x &&
		rotatedDiff.y <= m_size.y)
	{
		Focus();
		if (g_input->WasPressedThisTurn(MOUSE_LEFT))
		{
			if (m_selected)
			{
				UnSelect();
			}
			else
			{
				Select();
			}
		}
	}
	else
	{
		Unfocus();
	}
}
BOOL CTinyCadDoc::OnNewDocument()
{
	BOOL bReturn = super::OnNewDocument();

	if( bReturn )
	{
		GetDetails().Reset();

  SetPart(0);

  SelectObject(new CDrawEditItem(this));
  UnSelect();

	// Remove all objects from memory
		
		for( drawingIterator i = GetDrawingBegin(); i != GetDrawingEnd(); i++ ) 
	{
			CDrawingObject* pointer = *i;
		delete pointer;
	}
		m_drawing.clear();

    // Now delete the Redo List
	m_undo_level = 0;
	m_change_set = FALSE;
	FlushRedo();
	m_undo_level = 0;
  NameDir = 1;
  PinDir = 1;
  part = 0;
  show_power = FALSE;
	}

	return bReturn;
}
// The object selection functions
// This selects objects in a box
// (We don't select construction objects)
void CTinyCadDoc::Select(CDPoint p1,CDPoint p2)
{
  double left=min(p1.x,p2.x);
  double right=max(p1.x,p2.x);
  double top=min(p1.y,p2.y);
  double bottom=max(p1.y,p2.y);

  UnSelect();

	drawingIterator it = GetDrawingBegin();
	while (it != GetDrawingEnd()) 
	{
		CDrawingObject *obj = *it;

		if (    obj->IsInside(left,right,top,bottom) 
			&& !obj->IsConstruction()
			&& 
			(obj->GetType() != xJunction || !GetOption().GetAutoJunc() ) )
		{
			obj->Display();
			Select( obj );
		} 
  		
		++ it;
	}
}
CTinyCadDoc::~CTinyCadDoc()
{
	CTinyCadRegistry::Set("GridSpacingF",m_snap.GetAccurateGrid());
	CTinyCadRegistry::Set("GridSnap",m_snap.GetGridSnap());

	// Remove any editing tool
	if( edit )
	{
		edit->EndEdit();
		delete edit;
	}

	// Unselect all items
	UnSelect();

	// Now delete the contents of this document
	for( drawingIterator i = GetDrawingBegin(); i != GetDrawingEnd(); i++ ) 
	{
		CDrawingObject *pointer = *i;
		delete pointer;
	}
	
	m_drawing.clear();

	// Remove the undo/redo list
	m_undo_level = 0;
	FlushRedo();
}
// Duplicate the selected objects
void CTinyCadDoc::SelectDup()
{
	drawingCollection newSelection;

	selectIterator it = GetSelectBegin();
	while ( it != GetSelectEnd() ) 
	{
		CDrawingObject *obj=*it;

		CDrawingObject *pNewObject = obj->Store();
		newSelection.push_back( pNewObject );

		obj->Display();
		++ it;
	}



	// Swap over the selection to the new
	// objects...
	UnSelect();
	drawingCollection::iterator itx = newSelection.begin();
	while ( itx != newSelection.end() ) 
	{
		Select( *itx );

		// ... and mark for change...
		MarkChangeForUndo( *itx );
		++ itx;
	}
}
//-------------------------------------------------------------------------
void CTinyCadDoc::AddImage( CDrawMetaFile *pObject )
{
	Add( pObject );
	UnSelect();
	CDrawBlockImport *pImport = new CDrawBlockImport(this);
	SelectObject(pImport); 
	Select( pObject );
	pImport->Import();
}
Beispiel #8
0
/**
 * @brief		マウスクリックイベント.		
 * @author		yatagaik.
 * @param	in	mouse_event	マウスイベント.
 */
void PluginWidget::mouseReleaseEvent(QMouseEvent * /*mouse_event*/)
{
    if (!m_plugin->IsExecute())
    {
        meta_tools::PluginManager::Order()->OpenPlugin(m_plugin);
    }
    UnSelect();
    m_plugin_manager_widget->close();
}
Beispiel #9
0
void CheckboxComponent::Toggle()
{
	if (m_selected)
	{
		UnSelect();
	}
	else
	{
		Select();
	}
}
Beispiel #10
0
BOOL CTinyCadDoc::ReadFileXML(CXMLReader &xml, BOOL AlreadyStarted )
{
	drawingCollection drawing;

	if (ReadFileXML(xml, TRUE, drawing, AlreadyStarted) )
	{
		m_drawing.insert( m_drawing.end(), drawing.begin(), drawing.end() );
		UnSelect();
		SetModifiedFlag( FALSE );

		return TRUE;
	}

	return FALSE;
}
Beispiel #11
0
BOOL CTinyCadDoc::ReadFile(CStream &theArchive)
{
	drawingCollection drawing;

	if (ReadFile(theArchive, TRUE, drawing) )
	{
		m_drawing.insert( m_drawing.end(), drawing.begin(), drawing.end() );
		UnSelect();
		SetModifiedFlag( FALSE );

		return TRUE;
	}

	return FALSE;
}
// Remove an item from the drawing...
void CTinyCadDoc::Delete( drawingIterator it)
{
	CDrawingObject *pointer = *it;

	pointer->Display();
	if (pointer == GetSelectable())
	{
		SetSelectable( NULL );
	}
	UnSelect(pointer);

	MarkDeleteForUndo( *it );
	delete *it;
	m_drawing.erase( it );

	SetModifiedFlag( TRUE );
}
// Called after a paste or import to enable the
// document to sort out the imported block when
// necessary
void CTinyCadDoc::UngroupSymbols()
{
	// Scan and convert any imported symbols
	// into their component parts
	drawingIterator it = GetDrawingBegin();
	while (it != GetDrawingEnd()) 
	{
		drawingIterator current = it;
		++ it;
		CDrawingObject *pObject = *current;

		// Is this a method object?
		if (   pObject->GetType() == xMethodEx3
			&& IsSelected(pObject))
		{
			// Convert to the actual type
			CDrawMethod *pMethod = static_cast<CDrawMethod*>(pObject);

			// Get the symbol data
			CDPoint tr;
			drawingCollection method;
			pMethod->ExtractSymbol( tr,method );
			
			// Remove the method from the linked list
			UnSelect(pMethod);
			Delete( pMethod );

			// Now re-insert using the offset of the main
			// method
			CDPoint offset = method.front()->m_point_a;
			drawingIterator it = method.begin();
			while (it != method.end())
			{
				CDrawingObject *pInsertObject = *it;
				CDrawingObject *pDup = pInsertObject->Store();
				
				pDup->m_point_a += offset;
				pDup->m_point_b += offset;

				Select( pDup );
				
				++ it;
			}
		}
	}
}
void TextHighlighterComponent::CheckMouseCollision()
{
	auto textComp = m_object->GetComponent<TextComponent>();
	assert(textComp);

	Vector2f diff = g_input->GetMousePosition() - m_object->GetGlobalPos();
	float alpha = -m_object->GetGlobalRotation() * (float)PI / 180.f;
	Vector2f rotatedDiff = Vector2f(diff.x * cos(alpha) - diff.y * sin(alpha), diff.x * sin(alpha) + diff.y * cos(alpha));

	if (rotatedDiff.x >= 0 &&
		rotatedDiff.y >= 0 &&

		rotatedDiff.x <= textComp->GetSize().x &&
		rotatedDiff.y <= textComp->GetSize().y)
	{
		Select();
	}
	else
	{
		UnSelect();
	}
}
Beispiel #15
0
/**
 * @brief		Leaveイベント.		
 * @author		yatagaik.
 * @param  in	event	イベント.
 */ 
void PluginWidget::leaveEvent(QEvent * /*event*/)
{
    UnSelect();
}