Ejemplo n.º 1
0
// Load and save to an XML file
void CDrawPower::SaveXML(CXMLWriter &xml)
{
	xml.addTag(GetXMLTag());

	xml.addAttribute(_T("pos"), CDPoint(m_point_a));
	xml.addAttribute(_T("which"), which);
	xml.addAttribute(_T("direction"), dir);
	xml.addChildData(str);

	xml.closeTag();
}
Ejemplo n.º 2
0
// Load and save to an XML file
void CDrawSquare::SaveXML( CXMLWriter &xml )
{
    xml.addTag(GetXMLTag(IsSquare()));

    xml.addAttribute( _T("a"), CDPoint(m_point_a) );
    xml.addAttribute( _T("b"), CDPoint(m_point_b) );
    xml.addAttribute( _T("style"), Style );
    xml.addAttribute( _T("fill"), Fill );

    xml.closeTag();
}
// Load and save to an XML file
void CDrawMetaFile::SaveXML( CXMLWriter &xml )
{
	xml.addTag(GetXMLTag());

	xml.addAttribute( _T("a"), CDPoint(m_point_a) );
	xml.addAttribute( _T("b"), CDPoint(m_point_b) );
	xml.addAttribute( _T("id"), m_metafile );

	xml.closeTag();

}
Ejemplo n.º 4
0
// Load and save to an XML file
void CDrawLine::SaveXML( CXMLWriter &xml )
{
	xml.addTag(GetXMLTag(xtype));

	switch (xtype) 
	{
	case xBus:
	case xWire:
		if (!m_use_default_style)
		{
			xml.addAttribute( _T("style"), m_style );
		}
		break;
	default:
		xml.addAttribute( _T("style"), m_style );
		break;
	}	

	xml.addAttribute( _T("a"), m_point_a );
	xml.addAttribute( _T("b"), m_point_b );
	xml.closeTag();
}
Ejemplo n.º 5
0
//-------------------------------------------------------------------------
void CTinyCadDoc::SaveXML(CXMLWriter &xml, drawingCollection &drawing, BOOL Details, BOOL SaveSelect, BOOL SaveResources )
{
  // Write the objects to the file
  try
  {  
	xml.addTag(GetXMLTag());

	// If necessary write the header stamp
	if (Details) 
	{
		xml.addTag(_T("NAME"));
		xml.addChildData( m_sheet_name );
		xml.closeTag();

		xml.addTag(_T("DETAILS"));
		m_oDetails.WriteXML( xml );
		m_snap.SaveXML( xml );
		xml.closeTag();
	}

	if (SaveResources)
	{
		// Find out which resources are in use
		
		for( drawingIterator i = drawing.begin(); i != drawing.end(); i++ )
		{
			(*i)->TagResources();
		}

		// Save the resource details details
		theOptions.SaveFontsXML(xml);
		theOptions.SaveStylesXML(xml);
		theOptions.SaveFillStylesXML(xml);
		theOptions.SaveMetaFilesXML(xml);
	}

	// Only save the symbols if we are not saving
	// to a library or the header...
	if (Details)
	{
		theOptions.SaveSymbolsXML(xml);
	}

	if (Details)
	{
		theOptions.WriteXML( xml) ;
	}

	for( drawingIterator i = drawing.begin(); i != drawing.end(); i++ )
	{
		CDrawingObject* obj = *i;

		if (obj->GetType() != xError
			&& 	(Details || !obj->IsConstruction()) 
			&&  (!SaveSelect || IsSelected( obj )) )
		{

			// Now save the actual object data
			obj->SaveXML(xml);
		}
	}

	xml.closeTag();

  }
  catch ( CException *e) 
  {
	// Could not save the file properly
    e->ReportError();
    e->Delete();
  }
}
Ejemplo n.º 6
0
////// Load a design from a file, loaded design will be selected //////
BOOL CTinyCadDoc::ReadFileXML(CXMLReader &xml, BOOL Details, drawingCollection &drawing, BOOL AlreadyStarted)
{
  try
  {
	// Read in the first item...
	CString name;
	bool sheets = false;

	if (!AlreadyStarted)
	{
		xml.nextTag( name );
		if (name == "TinyCADSheets")
		{
			xml.intoTag();
			sheets = true;
			// We must search for the first TinyCAD section
			while (xml.nextTag( name ) && name != GetXMLTag())
			{
			}
		}
		
		// Check we are at the right point
		if (name != GetXMLTag())
		{
			Message(IDS_ABORTVERSION,MB_ICONEXCLAMATION);
			return FALSE;
		}
	}

	BOOL ResetMerge = TRUE;

	xml.intoTag();

	while (	xml.nextTag( name ) )
	{
		// Save the old layer setting
		CDrawingObject *obj = NULL;

		if (name == "DETAILS" )
		{
			if (Details)
			{
				GetDetails().ReadXML( xml, m_snap );
			}
		}
		else if (name == "NAME")
		{
			if (Details)
			{
				xml.getChildData( m_sheet_name );
			}
		}
		else if (name == "GRID")
		{
			if (Details)
			{
				m_snap.LoadXML( xml );
			}
		}
		else if (name == "FONT")
		{
			if (ResetMerge)
			{
				theOptions.ResetMerge();
				ResetMerge = FALSE;
			}
			theOptions.LoadFontXML(xml);
		}
		else if (name == "STYLE")
		{
			if (ResetMerge)
			{
				theOptions.ResetMerge();
				ResetMerge = FALSE;
			}
			theOptions.LoadStyleXML(xml);
		}
		else if (name == "FILL")
		{
			if (ResetMerge)
			{
				theOptions.ResetMerge();
				ResetMerge = FALSE;
			}
			theOptions.LoadFillStyleXML(xml);
		}
		else if (name == "META" || name == "IMAGE")
		{
			if (ResetMerge)
			{
				theOptions.ResetMerge();
				ResetMerge = FALSE;
			}
			theOptions.LoadMetaFileXML(xml);
		}
		else if (name == "SYMBOLDEF")
		{
			if (ResetMerge)
			{
				theOptions.ResetMerge();
				ResetMerge = FALSE;
			}
			theOptions.LoadSymbolXML(xml);
		}
		else if (name == "OPTIONS")
		{
			theOptions.ReadXML( xml );
		}
		else if (name == CDrawBusSlash::GetXMLTag())
		{
			obj = new CDrawBusSlash(this);
		}
		else if (name == CDrawTag::GetXMLTag())
		{
			obj = new CDrawTag(this);
		}
		else if (name == CDrawJunction::GetXMLTag())
		{
			obj = new CDrawJunction(this);
		}
		else if (name == CDrawLine::GetXMLTag(xBus))
		{
			obj = new CDrawLine(this, xBus);
		}
		else if (name == CDrawLine::GetXMLTag(xWire))
		{
			obj = new CDrawLine(this, xWire);
		}
		else if (name == CDrawLine::GetXMLTag(xLineEx2))
		{
			obj = new CDrawLine(this, xLineEx2);
		}
		else if (name == CDrawMetaFile::GetXMLTag())
		{
			obj = new CDrawMetaFile(this);
		}
		else if (name == CDrawMethod::GetXMLTag())
		{
			obj = new CDrawMethod(this);
		}
		else if (name == CDrawHierarchicalSymbol::GetXMLTag())
		{
			obj = new CDrawHierarchicalSymbol(this);
		}
		else if (name == CDrawNoConnect::GetXMLTag())
		{
			obj = new CDrawNoConnect(this);
		}
		else if (name == CDrawPin::GetXMLTag())
		{
			obj = new CDrawPin(this);
		}
		else if (name == CDrawRuler::GetXMLTag())
		{
			obj = new CDrawRuler(this, FALSE);
		}
		else if (name == CDrawSquare::GetXMLTag( TRUE ))
		{
			obj = new CDrawSquare(this, xSquareEx3);
		}
		else if (name == CDrawSquare::GetXMLTag( FALSE ))
		{
			obj = new CDrawSquare(this, xCircleEx3);
		}
		else if (name == CDrawText::GetXMLTag(xTextEx2))
		{
			obj = new CDrawText(this, xTextEx2);
		}
		else if (name == CDrawText::GetXMLTag(xBusNameEx))
		{
			obj = new CDrawText(this, xBusNameEx);
		}
		else if (name == CDrawLabel::GetXMLTag())
		{
			obj = new CDrawLabel(this);
		}
		else if (name == CDrawPolygon::GetXMLTag())
		{
			obj = new CDrawPolygon(this);
		}
		else if (name == CDrawPower::GetXMLTag())
		{
			obj = new CDrawPower(this);
		}

		if (obj != NULL)
		{
			// Load this object...
			obj->LoadXML( xml );

			// Now add object to linked list
			drawing.insert( drawing.end(), obj );
		}
	}

	xml.outofTag();

	if (sheets)
	{
		xml.outofTag();
	}
  }
  catch( CException *e ) 
  {
	  e->ReportError();
	  e->Delete();
	  return FALSE;
  }


  return drawing.size() > 0;
}