コード例 #1
0
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;
}
コード例 #2
0
ファイル: CheckboxComponent.cpp プロジェクト: PaulPopa/Games
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();
	}
}
コード例 #3
0
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;
}
コード例 #4
0
// 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;
	}
}
コード例 #5
0
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();
}
コード例 #6
0
// 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;
	}
}
コード例 #7
0
//-------------------------------------------------------------------------
void CTinyCadDoc::AddImage( CDrawMetaFile *pObject )
{
	Add( pObject );
	UnSelect();
	CDrawBlockImport *pImport = new CDrawBlockImport(this);
	SelectObject(pImport); 
	Select( pObject );
	pImport->Import();
}
コード例 #8
0
ファイル: plugin_widget.cpp プロジェクト: yatagai/MetaTools
/**
 * @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();
}
コード例 #9
0
ファイル: CheckboxComponent.cpp プロジェクト: PaulPopa/Games
void CheckboxComponent::Toggle()
{
	if (m_selected)
	{
		UnSelect();
	}
	else
	{
		Select();
	}
}
コード例 #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;
}
コード例 #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;
}
コード例 #12
0
// 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 );
}
コード例 #13
0
// 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;
			}
		}
	}
}
コード例 #14
0
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();
	}
}
コード例 #15
0
ファイル: plugin_widget.cpp プロジェクト: yatagai/MetaTools
/**
 * @brief		Leaveイベント.		
 * @author		yatagaik.
 * @param  in	event	イベント.
 */ 
void PluginWidget::leaveEvent(QEvent * /*event*/)
{
    UnSelect();
}