当前位置: 首页>>代码示例>>C++>>正文


C++ CDrawingObject::GetType方法代码示例

本文整理汇总了C++中CDrawingObject::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ CDrawingObject::GetType方法的具体用法?C++ CDrawingObject::GetType怎么用?C++ CDrawingObject::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDrawingObject的用法示例。


在下文中一共展示了CDrawingObject::GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetPartsPerPackage

// Enforce parts per package
void CTinyCadSymbolDoc::SetPartsPerPackage(int p)
{
	if (GetPart() >= p)
	{
		m_part = p - 1;
	}

	drawingCollection dels;

	// Find out how many parts in this package
	drawingIterator it = GetDrawingBegin();
	while (it != GetDrawingEnd()) 
	{
		CDrawingObject *pointer = *it;

		if (pointer->GetType()==xPinEx && ((CDrawPin *)pointer)->GetPart() >= p)
		{
			dels.push_back( pointer );
		}

		++ it;
	}

	// Now perform the deletions
	it = dels.begin();
	while (it != dels.end()) 
	{
		Delete( *it );
		++ it;
	}
}
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:32,代码来源:TinyCadSymbolDoc.cpp

示例2: Select

// 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;
	}
}
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:29,代码来源:TinyCadDoc.cpp

示例3: EditPartInPackage

// Set which part in the package to edit
void CTinyCadSymbolDoc::EditPartInPackage( int p )
{
	int OldPart = GetPart();
	
	// Get rid of any drawing tool
	SelectObject(new CDrawEditItem(this));

	m_part = p;

	// Are there any pins selected for this part
	int innew = FALSE,inold = FALSE;

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

		if (pointer->GetType()==xPinEx && ((CDrawPin *)pointer)->GetPart()==GetPart())
				innew = TRUE;
		if (pointer->GetType()==xPinEx && ((CDrawPin *)pointer)->GetPart()==OldPart)
				inold = TRUE;
		
		++ it;
	}

	// Do we need to copy over the pins?
	if (!innew && inold && Message(IDS_COPYPINS,MB_YESNO | MB_ICONQUESTION)==IDYES) 
	{
		CDrawPin *NewPin;
		drawingIterator it = GetDrawingBegin();
		while (it != GetDrawingEnd()) 
		{
			CDrawingObject *pointer = *it;
			if (pointer->GetType()==xPinEx && ((CDrawPin *)pointer)->GetPart()==OldPart) {
				NewPin = new CDrawPin(this);
				*NewPin = *((CDrawPin *)pointer);
				NewPin->SetPart(GetPart());
				Add(NewPin);
			}
			
			++ it;
		}
	}

	Invalidate();
}
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:47,代码来源:TinyCadSymbolDoc.cpp

示例4: ReplaceSymbol

// Replace all of the symbols in our drawing with a different one...
void CTinyCadDoc::ReplaceSymbol( hSYMBOL old_symbol, hSYMBOL new_symbol, bool keep_old_fields )
{
  // Search for methods, and look at their pins
	drawingIterator it = GetDrawingBegin();
	while (it != GetDrawingEnd()) 
	{
		CDrawingObject *ObjPtr = *it;
		if (ObjPtr->GetType() == xMethodEx3)
		{
			CDrawMethod *pMethod = static_cast<CDrawMethod*>(ObjPtr);
			pMethod->ReplaceSymbol( old_symbol, new_symbol, keep_old_fields );
			pMethod->Display( TRUE );
		}

		++ it;
	}
}
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:18,代码来源:TinyCadDoc.cpp

示例5: UngroupSymbols

// 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;
			}
		}
	}
}
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:49,代码来源:TinyCadDoc.cpp

示例6: GetPartsPerPackage

int CTinyCadSymbolDoc::GetPartsPerPackage()
{
	// Find out how many parts in this package
	int max=0;
	drawingIterator it = GetDrawingBegin();
	while (it != GetDrawingEnd()) 
	{
		CDrawingObject *pointer = *it;

		if (pointer->GetType()==xPinEx && ((CDrawPin *)pointer)->GetPart()>max)
		{
			max = ((CDrawPin *)pointer)->GetPart();
		}

		++ it;
	}

	return max + 1;
}
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:19,代码来源:TinyCadSymbolDoc.cpp

示例7: DeleteErrors

// Remove all errors from this design
void CTinyCadDoc::DeleteErrors()
{
  // Get rid of any drawing tool
  SelectObject(new CDrawEditItem(this));

	drawingIterator it = GetDrawingBegin();
	while (it != GetDrawingEnd()) 
	{
		drawingIterator current = it;
		++ it;
		
		CDrawingObject *pointer = *current;
		if (pointer->GetType()==xError) 
		{
			m_drawing.erase(current);
			delete pointer;
		}
	}

	Invalidate();
}
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:22,代码来源:TinyCadDoc.cpp

示例8: OnSpecialAnotate

// Auto anotate the design
void CTinyCadView::OnSpecialAnotate()
{
  CDlgAnotateBox theDialog(this,theASetup);

  // Get rid of any drawing tool
  GetCurrentDocument()->SelectObject(new CDrawEditItem(GetCurrentDocument()));

  // Do the dialog
  int action = theDialog.DoModal();
  
  if (action == IDC_REF_PAINTER)
  {
	  theASetup = theDialog.v;
	  GetCurrentDocument()->SelectObject(new CDrawRefPainter(GetCurrentDocument(), theASetup.startval ));
	  return;
  }
  else if (action !=IDOK)
  {
	return;
  }

  theASetup = theDialog.v;

  // Set the busy icon
  SetCursor( AfxGetApp()->LoadStandardCursor( IDC_WAIT ) );
  

  // Now add/remove references
  CDrawMethod *thisMethod;
  CSymbolRecord *thisSymbol;
  int value=0;
  int part=0;
  BOOL IsSet,IsMatch,MissingSymbols=FALSE;
  

	for (int i = 0; i < 2; i++)
	{
		int sheet = theASetup.all_sheets ? 0 : GetDocument()->GetActiveSheetIndex();

		do
		{
			drawingIterator it = GetDocument()->GetSheet(sheet)->GetDrawingBegin();
			while (it != GetDocument()->GetSheet(sheet)->GetDrawingEnd()) 
			{
				CDrawingObject *pointer = *it;
				// Look for method objects
				if (pointer->GetType() == xMethodEx3) 
				{
					thisMethod = (CDrawMethod *)pointer;
					thisSymbol = thisMethod->GetSymbolData();

					// If there is no symbol then cannot modify this symbol!
					if (thisMethod->IsNoSymbol()) 
					{
						MissingSymbols = TRUE;
						++ it;
						continue;
					}

					// Has this symbol got a reference?
					IsSet   = thisMethod->HasRef();

					switch (theASetup.reference)
					{
					case 0:		// All references
						IsMatch = TRUE;
						break;
					case 1:		// Un-numbered references
						IsMatch = !thisMethod->HasRef();
						break;
					case 2:		// References that match...
						IsMatch = theASetup.matchval == thisSymbol->reference;
						break;
					}

					if (IsMatch)
					{

						// First pass  - we remove references if necessary,
						// Second pass - we add refences back in...
						//
						if (i == 0)
						{
							// Remove any matching references (if necessary)
							if (IsSet && (theASetup.value!=1 || thisMethod->GetRefVal()>=theASetup.startval) ) 
							{
								thisMethod->RemoveReference();
							}
						}
						else
						{
							// Now add back any references
							if (theASetup.action == 0) 
							{
								if (theASetup.reference != 1)
								{
									value = (theASetup.value == 0) ? 1 : theASetup.startval;
								}
								thisMethod->AddReference( value, theASetup.all_sheets );
//.........这里部分代码省略.........
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:101,代码来源:Special.cpp

示例9: SaveXML

//-------------------------------------------------------------------------
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();
  }
}
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:73,代码来源:Io.cpp

示例10: GetStickyPoint

CDPoint CTinyCadDoc::GetStickyPoint( CDPoint q, BOOL pins, BOOL wires, BOOL &is_stuck, BOOL &is_junction )
{
  CDPoint r(0,0);
  bool first = true;
  double min_distance = 0;
  int items = 0;

  int range = GetOption().GetAutoSnapRange();

  if (!GetOption().GetAutoSnap())
  {
  	  is_stuck = FALSE;
	  is_junction = FALSE;
	  return q;
  }


  // Search for methods, and look at their pins
	drawingIterator it = GetDrawingBegin();
	while (it != GetDrawingEnd()) 
	{
		CDrawingObject *ObjPtr = *it;

		switch (ObjPtr->GetType()) 
		{
			case xWire:
				#define theLine ((CDrawLine*)ObjPtr)
				if (wires)
				{
					CDPoint d;
					CLineUtils l( theLine->m_point_a, theLine->m_point_b );
					double distance = l.DistanceFromPoint( q, d );

					if (d == r)
					{
						items ++;
					}

					if (first || distance < min_distance)
					{
						if (r != d)
						{
							// have we split this wire?
							if (d != theLine->m_point_a && d != theLine->m_point_b)
							{
								items = 2;
							}
							else
							{
								items = 1;
							}
						}
						r = d;
						first = false;
						min_distance = distance;
					}
				}
				break;
			default:
				if (pins)
				{
					CDRect s( ObjPtr->m_point_a.x, ObjPtr->m_point_a.y, ObjPtr->m_point_b.x, ObjPtr->m_point_b.y );
					s.NormalizeRect();
					s.left -= range * 2;
					s.right += range * 2;
					s.bottom += range * 2;
					s.top -= range * 2;

					if (s.PtInRect(q))
					{
						CActiveNode a;
						ObjPtr->GetActiveListFirst( a );
						while (ObjPtr->GetActive(a)) 
						{
							// This is a valid pin...
							CDPoint d = a.m_a;
							double dx = d.x - q.x;
							double dy = d.y - q.y;
							double distance = sqrt(dx*dx + dy*dy);

							if (r == d)
							{
								items ++;
							}

							if (first || distance < min_distance)
							{
								if (r != d)
								{
									items = 1;
								}

								r = d;
								first = false;
								min_distance = distance;
							}
						}
					}
				}
				break;
//.........这里部分代码省略.........
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:101,代码来源:TinyCadDoc.cpp

示例11: OnSpecialCheck

void CTinyCadView::OnSpecialCheck()
{
	// Get rid of any drawing tool
	GetCurrentDocument()->SelectObject(new CDrawEditItem(GetCurrentDocument()));

	CDlgERCBox theDialog;

	static union { ErrorTest e; WORD i; } theErrorTest;

	theErrorTest.i = CTinyCadRegistry::GetInt("ERC", 0xffff);


	// Get the user's options
	theDialog.SetErrorTest(theErrorTest.e);
	if (theDialog.DoModal() != IDOK)
	{
		return;
	}

	theErrorTest.e = theDialog.GetErrorTest();  
	CTinyCadRegistry::Set("ERC",theErrorTest.i);

	// Set the Busy icon
	SetCursor( AfxGetApp()->LoadStandardCursor( IDC_WAIT ) );

	// Generate the netlist
	CNetList netlist;
	netlist.m_follow_imports = false;
	CTinyCadMultiDoc *pDoc = static_cast<CTinyCadMultiDoc*>(GetDocument());
	netlist.MakeNet( pDoc );
	netCollection *nets = &netlist.m_nets;

	// Delete all the errors which are currently in the design
	theERCListBox.Close();
	// GetCurrentDocument()->DeleteErrors();
	theERCListBox.Open( pDoc );
	int CurrentError = 0;

	// Scan the design for duplicated references
	if ((theErrorTest.e).DupRef)
	{
		std::set<CString>	refs;

		CString last = "";

		for (int i = 0; i < pDoc->GetNumberOfSheets(); i++)
		{
			drawingIterator it = pDoc->GetSheet(i)->GetDrawingBegin();
			while (it != pDoc->GetSheet(i)->GetDrawingEnd()) 
			{
				CDrawingObject *pointer = *it;

				if (pointer->GetType()==xMethodEx3) 
				{
					CString ref = static_cast<CDrawMethod *>(pointer)->GetField(CDrawMethod::Ref);

					if (refs.find( ref ) != refs.end())
					{
						// We have a duplicate...
						CString buffer;
						buffer.LoadString( ERR_DUPREF );
						pDoc->GetSheet(i)->Add(new CDrawError(pDoc->GetSheet(i),static_cast<CDrawMethod *>(pointer)->GetFieldPos(CDrawMethod::Ref),CurrentError++));
						theERCListBox.AddString(buffer);
					}
					else
					{
						refs.insert( ref );
					}
				}

				++ it;
			}
		}
	}


	// Scan netlist to determine the type of each net
	netCollection::iterator nit = nets->begin();

	while (nit != nets->end()) 
	{
		nodeVector::iterator nv_it = (*nit).second.begin();

		int theNetType = nUnknown;
		CString lastPower = "";
		int connections = 0;

		CDPoint pos;
		int sheet = 0;

		while (theNetType < ERR_BASE && nv_it != (*nit).second.end()) 
		{
			CNetListNode& theNode = *nv_it;

			CDrawingObject* pObject = theNode.m_parent;
			
			if (pObject != NULL) 
			{
				// Determine the type of this node
				int node_type = nUnknown;
//.........这里部分代码省略.........
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:101,代码来源:Net.cpp

示例12: WriteNetListFilePADS

// Create netlist and output as a PCB file (PADS-PCB)
void CNetList::WriteNetListFilePADS( CTinyCadMultiDoc *pDesign, const TCHAR *filename )
{
  FILE *theFile;
  errno_t err;
  err = _tfopen_s(&theFile, filename,_T("w"));
  if ((theFile == NULL) || (err != 0))
  {
	Message(IDS_CANNOTOPEN);
	return;
  }

  // Set the Busy icon
  SetCursor( AfxGetApp()->LoadStandardCursor( IDC_WAIT ) );

  // Get the net list
  MakeNet( pDesign );

  _ftprintf(theFile,_T("*PADS-PCB*\n"));


  _ftprintf(theFile,_T("*PART*\n"));
  

  // Keep track of the references we have outputted...
  std::set<CString>	referenced;

	// Do this for all of the files in the imports list...
	fileCollection::iterator fi = m_imports.begin();
	for (;fi != m_imports.end(); ++ fi)
	{
		CTinyCadMultiDoc *dsn = pDesign;

		if ((*fi)->m_file_name_index != 0)
		{
			dsn = (*fi)->m_pDesign;
		}

		// Generate a component for every sheet in this design
		for (int i = 0; i < dsn->GetNumberOfSheets(); i++)
		{

			drawingIterator it = dsn->GetSheet(i)->GetDrawingBegin();
			while (it != dsn->GetSheet(i)->GetDrawingEnd()) 
			{
				CDrawingObject *pointer = *it;

				if (pointer->GetType() == xMethodEx3) 
				{
					CDrawMethod *pMethod = static_cast<CDrawMethod *>(pointer);
					CString Ref  = pMethod->GetRefSheet(m_prefix_references,m_prefix_import,(*fi)->m_file_name_index,i+1);

					// Do we need to output this part?
					if (referenced.find( Ref ) == referenced.end())
					{
						referenced.insert( Ref );

						CString Package = _T("This part has no 'Package' attribute");
						for (int i = 2; i < pMethod->GetFieldCount(); i++)
						{
							if (pMethod->GetFieldName(i).CompareNoCase(_T("package")) == 0)
							{
								Package = pMethod->GetField(i);
							}
						}


						// Pad to correct length...
						do
						{
							Ref = Ref + _T(" ");
						}
						while (Ref.GetLength() < 8);
						_ftprintf(theFile,_T("%s%s\n"), Ref, Package);
					}
				}
				
				++ it;
			}
	}
	}

  _ftprintf(theFile,_T("\n*NET*\n"));
  int Label = 0;

  netCollection::iterator nit = m_nets.begin();

	while (nit != m_nets.end()) 
	{
		nodeVector::iterator nv_it = (*nit).second.begin();

		CString theLine,theLabel;

		if (nv_it != (*nit).second.end()) 
		{
			theLine = _T("");
			BOOL first = TRUE, Labeled = FALSE;
			int len = 0;
			int count = 0;

//.........这里部分代码省略.........
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:101,代码来源:NetList.cpp

示例13: MakeNetForSheet

// Perform the work of making a netlist from a single sheet in this design...
void CNetList::MakeNetForSheet( fileCollection &imports, int file_index_id, int &file_name_index, int sheet, CTinyCadDoc *pDesign )
{
  // Get rid of any old data
  m_CurrentNet = 1;
  m_nodes.erase( m_nodes.begin(), m_nodes.end() );
  m_nets.erase( m_nets.begin(), m_nets.end() );

  // Here is some temporary data for this function
  typedef std::map<CString,int> stringCollection;
  stringCollection	Powers;
  stringCollection	Connected;

  // Search for nodes, and build the node tree
  drawingIterator it = pDesign->GetDrawingBegin();
  for (;it != pDesign->GetDrawingEnd(); ++ it ) 
  {
	CDrawingObject *ObjPtr = *it;
	stringCollection::iterator found;
	int hold;
	CDPoint tr;

	switch (ObjPtr->GetType()) 
	{
		case xHierarchicalSymbol:
			{
				CDrawHierarchicalSymbol *pSymbol = static_cast<CDrawHierarchicalSymbol*>(ObjPtr);

				// Try and stop recursion by limiting the number of imports
				if (imports.size() > 100)
				{
					AfxMessageBox( IDS_RECURSION );
					continue;
				}

				// Push back this filename into the list of extra imports
				CImportFile *f = new CImportFile;
				++ file_name_index;
				f->m_file_name_index = file_name_index;
				if (f->Load( pSymbol->GetFilename() ) )
				{
					imports.push_back( f );

					// Now search the symbol for pins to link the other symbols to
					drawingCollection method;
					pSymbol->ExtractSymbol(tr,method);

					drawingIterator it = method.begin();
					while ( it != method.end() ) 
					{
						CDrawingObject *pointer = *it;

						if (pointer->GetType()==xPinEx) 
						{
							CDrawPin *thePin = static_cast<CDrawPin*>(pointer);

							// This in effect labels the node with the new node name...
							CNetListNode n( file_name_index, sheet, thePin, thePin->GetActivePoint(pSymbol) );
							n.setLabel( thePin->GetPinName() );
							n.m_reference = pSymbol->GetRefSheet(m_prefix_references,m_prefix_import,file_index_id,sheet);
							n.m_pin = thePin->GetNumber();
							n.m_pMethod = pSymbol;
							Add(n);
						}

						++ it;
					}
				}
				else
				{
					delete f;
				}
			}
			break;
		case xMethodEx3:
			#define thePin ((CDrawPin*)pointer)
			#define theMethod ((CDrawMethod*)ObjPtr)
			{
				drawingCollection method;
				((CDrawMethod *)ObjPtr)->ExtractSymbol(tr,method);

				drawingIterator it = method.begin();
				while ( it != method.end() ) 
				{
					CDrawingObject *pointer = *it;

					if (pointer->GetType()==xPinEx && !(thePin->IsPower()) ) 
					{
						CNetListNode n( file_index_id, sheet, thePin,thePin->GetActivePoint(theMethod));
						n.m_reference = theMethod->GetRefSheet(m_prefix_references,m_prefix_import,file_index_id,sheet);
						n.m_pin = thePin->GetNumber();
						n.m_pMethod = theMethod;
						Add(n);
					}

					++ it;
				}

				// Has this symbol had it's power connected?
				if (Connected.find(theMethod->GetRefSheet(m_prefix_references,m_prefix_import,file_index_id,sheet)) == Connected.end()) 
//.........这里部分代码省略.........
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:101,代码来源:NetList.cpp

示例14: WriteSpiceFile

// Create netlist and output as a SPICE file
void CNetList::WriteSpiceFile( CTinyCadMultiDoc *pDesign, const TCHAR *filename )
{
	// Open the filename for the spice file
	FILE *theFile;
	errno_t err;
	err = _tfopen_s(&theFile, filename,_T("w"));
	if ((theFile == NULL) || (err != 0))
	{
		Message(IDS_CANNOTOPEN);
		return;
	}

	// Output the standard header comment - expected on line 1 by some Spice engines
	_ftprintf(theFile,_T("* Schematics Netlist *\n"));

	createErrorFile( filename );

	_ftprintf(m_err_file,_T("Results of Spice file generation for %s\n\n"),
		pDesign->GetPathName() );


	// Set the Busy icon
	SetCursor( AfxGetApp()->LoadStandardCursor( IDC_WAIT ) );

	// Create the net list
	m_prefix_import = TRUE;
	m_prefix_references = TRUE;
	MakeNet( pDesign );

	
	// Now we have the net list we must convert it into a file suitable for
	// spice...
	//
	// The netlist represents a single vector per net, however, spice requires
	// a vector per symbol.  We have to rotate the array, so that we have one
	// entry in our vector for each of the symbols in our drawing....
	//
	
	typedef std::map<CString,CNetListSymbol>	symbolCollection;
	symbolCollection symbols;
	labelCollection labels;


	netCollection::iterator nit = m_nets.begin();

	while (nit != m_nets.end()) 
	{
		nodeVector::iterator nv_it = (*nit).second.begin();

		while (nv_it != (*nit).second.end()) 
		{
			CNetListNode& theNode = *nv_it;
			++ nv_it;

			// Is this node a symbol?
			if (!theNode.m_reference.IsEmpty() && theNode.m_pMethod->GetType() == xMethodEx3 )
			{
				// Yes, so update the pin allocations in the symbol map...
				CNetListSymbol &symbol = symbols[ theNode.m_reference ];

				symbol.m_pins[ theNode.m_pin ] = theNode.m_NetList;
				symbol.m_pMethod = theNode.m_pMethod;
			}

			// Is this node a label?
			if (!theNode.getLabel().IsEmpty())
			{
				// Yes, so update the label collection
				labels[ theNode.m_NetList ] = theNode.getLabel();
			}
		}

		++ nit;
	}


	//
	// We scan the symbols array and extract any file imports
	// That we need from the fields of the symbols...
	//
	symbolCollection::iterator sit = symbols.begin();

	typedef std::set<CString> strings;
	typedef std::vector<strings> string_collection;
	string_collection prolog_lines;
	string_collection epilog_lines;
	prolog_lines.resize( 10 );
	epilog_lines.resize( 10 );

	// Do this for all of the files in the imports list...
	fileCollection::iterator fi = m_imports.begin();
	for (;fi != m_imports.end(); ++ fi)
	{
		CTinyCadMultiDoc *dsn = pDesign;

		if ((*fi)->m_file_name_index != 0)
		{
			dsn = (*fi)->m_pDesign;
		}
//.........这里部分代码省略.........
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:101,代码来源:NetList.cpp

示例15: WriteNetListFileTinyCAD

// Create netlist and output as a PCB file
void CNetList::WriteNetListFileTinyCAD( CTinyCadMultiDoc *pDesign, const TCHAR *filename )
{
  FILE *theFile;
  errno_t err;
  err = _tfopen_s(&theFile, filename,_T("w"));
  if ((theFile == NULL) || (err != 0))
  {
	Message(IDS_CANNOTOPEN);
	return;
  }

  // Set the Busy icon
  SetCursor( AfxGetApp()->LoadStandardCursor( IDC_WAIT ) );

  // Get the net list
  MakeNet( pDesign );

  _ftprintf(theFile,NetComment _T(" ====+  Net List for %s  +====\n\n"), pDesign->GetPathName() );


  _ftprintf(theFile,NetComment _T(" ======+ The component list\n\n"));

  // Keep track of the references we have outputted...
  std::set<CString>	referenced;

  	// Do this for all of the files in the imports list...
	fileCollection::iterator fi = m_imports.begin();
	for (;fi != m_imports.end(); ++ fi)
	{
		CTinyCadMultiDoc *dsn = pDesign;

		if ((*fi)->m_file_name_index != 0)
		{
			dsn = (*fi)->m_pDesign;
		}

		// Generate a component for every sheet in this design
		for (int i = 0; i < dsn->GetNumberOfSheets(); i++)
		{
			drawingIterator it = dsn->GetSheet(i)->GetDrawingBegin();
			while (it != dsn->GetSheet(i)->GetDrawingEnd()) 
			{
			CDrawingObject *pointer = *it;

			if (pointer->GetType() == xMethodEx3) 
			{
				CDrawMethod *pMethod = static_cast<CDrawMethod *>(pointer);
				CString Name = pMethod->GetField(CDrawMethod::Name);
				CString Ref  = pMethod->GetRefSheet(m_prefix_references,m_prefix_import,(*fi)->m_file_name_index,i+1);

				// Do we need to output this part?
				if (referenced.find( Ref ) == referenced.end())
				{
					referenced.insert( Ref );

					_ftprintf(theFile,_T("COMPONENT '%s' = %s\n"),Ref,Name);

					// Now write it it's "other" references
					for (int i = 2; i < pMethod->GetFieldCount(); i++)
					{
						_ftprintf(theFile,_T("\tOPTION '%s' = %s\n"),pMethod->GetFieldName(i), pMethod->GetField(i) );
					}
				}
			}
			
			++ it;
			}
		}
	}

  _ftprintf(theFile,_T("\n\n") NetComment _T(" ======+ The net list\n\n"));
  int Label = 0;

  netCollection::iterator nit = m_nets.begin();

	while (nit != m_nets.end()) 
	{
		nodeVector::iterator nv_it = (*nit).second.begin();

		CString theLine,theLabel;

		if (nv_it != (*nit).second.end()) 
		{
			theLine = "";
			BOOL first = TRUE,PrintLine=FALSE, Labeled = FALSE;

			while (nv_it != (*nit).second.end()) 
			{
				CNetListNode& theNode = *nv_it;
				++ nv_it;

				if (theNode.getLabel() != "" && !Labeled) 
				{
					theLabel = theNode.getLabel();
					Labeled = TRUE;
				}
				else
				{
					CString add;
//.........这里部分代码省略.........
开发者ID:saranyan,项目名称:tinycad_graph_matching,代码行数:101,代码来源:NetList.cpp


注:本文中的CDrawingObject::GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。