예제 #1
0
//=============================================================================*
wostream& BAR_Error::PrettyPrint(wostream& out) const
//=============================================================================*
{ 
    out << GetType() << L"(bar";
    out.width(4);
    out.fill('0');
    return out << m_iErrCode << L"): " << GetMessage() 
               << ( GetDetails().empty() ? L"" : L", ") << GetDetails();
}
예제 #2
0
	const TCHAR * GetSummary(std::_tstring & html, bool includeHtmlHeader, bool includeHeader)
	{
		CComPtr<IHtmlHelper> htmlHelper = CreateIHtmlHelper(m_category, GetIConfig(QUERYBUILDER_CFG)->Get(GLOBAL_PREF_SHOWALL));
		if (includeHtmlHeader)
		{
			htmlHelper->Open(_T("Entity"));
		}
		if (includeHeader)
		{
			htmlHelper->AppendHeading(GetCategory());
		}
#ifndef _DEBUG
		try
		{
#endif
			CComPtr<ITable> details = GetDetails(true);
			if (details)
			{
				std::_tstring ll;
				htmlHelper->AppendTable(details, ll);
				htmlHelper->AppendFooter(ll);
			}
#ifndef _DEBUG
		}
		catch(...)	//Big hack for demo
		{
			ATLASSERT(false);
		}
#endif
		html = htmlHelper->Close(includeHtmlHeader);
		return html.c_str();
	}
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
bool
HTMLSummaryElement::IsMainSummary() const
{
  HTMLDetailsElement* details = GetDetails();
  if (!details) {
    return false;
  }

  return details->GetFirstSummary() == this || IsRootOfNativeAnonymousSubtree();
}
예제 #5
0
	void GetAdvancedSearch(CAdvancedSearch & search, bool sampleData)
	{
		CComPtr<IHtmlHelper> htmlHelper = CreateIHtmlHelper(m_category, GetIConfig(QUERYBUILDER_CFG)->Get(GLOBAL_PREF_SHOWALL));
#ifndef _DEBUG
		try
		{
#endif
			CComPtr<ITable> details = GetDetails(sampleData);
			if (details)
			{
				htmlHelper->AppendTable(details, search);
			}
#ifndef _DEBUG
		}
		catch(...)	//Big hack for demo
		{
			ATLASSERT(false);
		}
#endif
		htmlHelper->Close();
	}
예제 #6
0
	const TCHAR * GetDebug(std::_tstring & html)
	{
		CComPtr<IHtmlHelper> htmlHelper = CreateIHtmlHelper(m_category, GetIConfig(QUERYBUILDER_CFG)->Get(GLOBAL_PREF_SHOWALL));
#ifndef _DEBUG
		try
		{
#endif
			CComPtr<ITable> details = GetDetails(true);
			if (details)
			{
				htmlHelper->AppendTableDebug(details);
			}
#ifndef _DEBUG
		}
		catch(...)	//Big hack for demo
		{
			ATLASSERT(false);
		}
#endif
		html = htmlHelper->Close();
		return html.c_str();
	}
예제 #7
0
WorldPacket Quest::BuildQueryData(LocaleConstant loc) const
{
    WorldPackets::Quest::QueryQuestInfoResponse response;

    std::string locQuestTitle = GetTitle();
    std::string locQuestDetails = GetDetails();
    std::string locQuestObjectives = GetObjectives();
    std::string locQuestAreaDescription = GetAreaDescription();
    std::string locQuestCompletedText = GetCompletedText();

    std::string locQuestObjectiveText[QUEST_OBJECTIVES_COUNT];
    for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
        locQuestObjectiveText[i] = ObjectiveText[i];

    if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(GetQuestId()))
    {
        ObjectMgr::GetLocaleString(localeData->Title, loc, locQuestTitle);
        ObjectMgr::GetLocaleString(localeData->Details, loc, locQuestDetails);
        ObjectMgr::GetLocaleString(localeData->Objectives, loc, locQuestObjectives);
        ObjectMgr::GetLocaleString(localeData->AreaDescription, loc, locQuestAreaDescription);
        ObjectMgr::GetLocaleString(localeData->CompletedText, loc, locQuestCompletedText);

        for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
            ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], loc, locQuestObjectiveText[i]);
    }

    response.Info.QuestID = GetQuestId();
    response.Info.QuestMethod = GetQuestMethod();
    response.Info.QuestLevel = GetQuestLevel();
    response.Info.QuestMinLevel = GetMinLevel();
    response.Info.QuestSortID = GetZoneOrSort();

    response.Info.QuestType = GetType();
    response.Info.SuggestedGroupNum = GetSuggestedPlayers();

    response.Info.RequiredFactionId[0] = GetRepObjectiveFaction();
    response.Info.RequiredFactionValue[0] = GetRepObjectiveValue();

    response.Info.RequiredFactionId[1] = GetRepObjectiveFaction2();
    response.Info.RequiredFactionValue[1] = GetRepObjectiveValue2();

    response.Info.RewardNextQuest = GetNextQuestInChain();
    response.Info.RewardXPDifficulty = GetXPId();

    response.Info.RewardMoney = GetRewOrReqMoney();
    response.Info.RewardBonusMoney = GetRewMoneyMaxLevel();
    response.Info.RewardDisplaySpell = GetRewSpell();
    response.Info.RewardSpell = GetRewSpellCast();

    response.Info.RewardHonor = GetRewHonorAddition();
    response.Info.RewardKillHonor = GetRewHonorMultiplier();

    response.Info.StartItem = GetSrcItemId();
    response.Info.Flags = GetFlags();
    response.Info.RewardTitleId = GetCharTitleId();
    response.Info.RequiredPlayerKills = GetPlayersSlain();
    response.Info.RewardTalents = GetBonusTalents();
    response.Info.RewardArenaPoints = GetRewArenaPoints();

    for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
    {
        response.Info.RewardItems[i] = RewardItemId[i];
        response.Info.RewardAmount[i] = RewardItemIdCount[i];
    }

    for (uint8 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
    {
        response.Info.UnfilteredChoiceItems[i].ItemID = RewardChoiceItemId[i];
        response.Info.UnfilteredChoiceItems[i].Quantity = RewardChoiceItemCount[i];
    }

    for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)             // reward factions ids
        response.Info.RewardFactionID[i] = RewardFactionId[i];

    for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)             // columnid+1 QuestFactionReward.dbc?
        response.Info.RewardFactionValue[i] = RewardFactionValueId[i];

    for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)             // unk (0)
        response.Info.RewardFactionValueOverride[i] = RewardFactionValueIdOverride[i];

    response.Info.POIContinent = GetPOIContinent();
    response.Info.POIx = GetPOIx();
    response.Info.POIy = GetPOIy();
    response.Info.POIPriority = GetPointOpt();

    if (sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS))
        Quest::AddQuestLevelToTitle(locQuestTitle, GetQuestLevel());

    response.Info.Title = locQuestTitle;
    response.Info.Objectives = locQuestObjectives;
    response.Info.Details = locQuestDetails;
    response.Info.AreaDescription = locQuestAreaDescription;
    response.Info.CompletedText = locQuestCompletedText;

    for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
    {
        response.Info.RequiredNpcOrGo[i] = RequiredNpcOrGo[i];
        response.Info.RequiredNpcOrGoCount[i] = RequiredNpcOrGoCount[i];
        response.Info.ItemDrop[i] = ItemDrop[i];
    }

    for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
    {
        response.Info.RequiredItemId[i] = RequiredItemId[i];
        response.Info.RequiredItemCount[i] = RequiredItemCount[i];
    }

    for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
        response.Info.ObjectiveText[i] = locQuestObjectiveText[i];

    return *response.Write();
}
예제 #8
0
void Quest::InitializeQueryData()
{
	queryData.Initialize(SMSG_QUEST_QUERY_RESPONSE, 1);

	queryData << uint32(GetQuestId());                    // quest id
	queryData << uint32(GetQuestMethod());                // Accepted values: 0, 1 or 2. 0 == IsAutoComplete() (skip objectives/details)
	queryData << uint32(GetQuestLevel());                 // may be -1, static data, in other cases must be used dynamic level: Player::GetQuestLevel (0 is not known, but assuming this is no longer valid for quest intended for client)
	queryData << uint32(GetMinLevel());                   // min level
	queryData << uint32(GetZoneOrSort());                 // zone or sort to display in quest log

	queryData << uint32(GetType());                       // quest type
	queryData << uint32(GetSuggestedPlayers());           // suggested players count

	queryData << uint32(GetRepObjectiveFaction());        // shown in quest log as part of quest objective
	queryData << uint32(GetRepObjectiveValue());          // shown in quest log as part of quest objective

	queryData << uint32(GetRepObjectiveFaction2());       // shown in quest log as part of quest objective OPPOSITE faction
	queryData << uint32(GetRepObjectiveValue2());         // shown in quest log as part of quest objective OPPOSITE faction

	queryData << uint32(GetNextQuestInChain());           // client will request this quest from NPC, if not 0
	queryData << uint32(GetXPId());                       // used for calculating rewarded experience

	if (HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
		queryData << uint32(0);                                  // Hide money rewarded
	else
		queryData << uint32(GetRewOrReqMoney());          // reward money (below max lvl)

	queryData << uint32(GetRewMoneyMaxLevel());           // used in XP calculation at client
	queryData << uint32(GetRewSpell());                   // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
	queryData << int32(GetRewSpellCast());                // casted spell

	// rewarded honor points
	queryData << uint32(GetRewHonorAddition());
	queryData << float(GetRewHonorMultiplier());
	queryData << uint32(GetSrcItemId());                  // source item id
	queryData << uint32(GetFlags() & 0xFFFF);             // quest flags
	queryData << uint32(GetCharTitleId());                // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
	queryData << uint32(GetPlayersSlain());               // players slain
	queryData << uint32(GetBonusTalents());               // bonus talents
	queryData << uint32(GetRewArenaPoints());             // bonus arena points
	queryData << uint32(0);                                      // review rep show mask

	if (HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
	{
		for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i)
			queryData << uint32(0) << uint32(0);
		for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
			queryData << uint32(0) << uint32(0);
	}
	else
	{
		for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i)
		{
			queryData << uint32(RewardItemId[i]);
			queryData << uint32(RewardItemIdCount[i]);
		}
		for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
		{
			queryData << uint32(RewardChoiceItemId[i]);
			queryData << uint32(RewardChoiceItemCount[i]);
		}
	}

	for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)        // reward factions ids
		queryData << uint32(RewardFactionId[i]);

	for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)        // columnid+1 QuestFactionReward.dbc?
		queryData << int32(RewardFactionValueId[i]);

	for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)           // unk (0)
		queryData << int32(RewardFactionValueIdOverride[i]);

	queryData << GetPointMapId();
	queryData << GetPointX();
	queryData << GetPointY();
	queryData << GetPointOpt();

	queryData << GetTitle();
	queryData << GetObjectives();
	queryData << GetDetails();
	queryData << GetEndText();
	queryData << GetCompletedText();                                  // display in quest objectives window once all objectives are completed

	for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
	{
		if (RequiredNpcOrGo[i] < 0)
			queryData << uint32((RequiredNpcOrGo[i] * (-1)) | 0x80000000);    // client expects gameobject template id in form (id|0x80000000)
		else
			queryData << uint32(RequiredNpcOrGo[i]);

		queryData << uint32(RequiredNpcOrGoCount[i]);
		queryData << uint32(RequiredSourceItemId[i]);
		queryData << uint32(0);                                  // req source count?
	}

	for (uint32 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
	{
		queryData << uint32(RequiredItemId[i]);
		queryData << uint32(RequiredItemCount[i]);
	}

	for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
		queryData << ObjectiveText[i];
}
예제 #9
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;
}
예제 #10
0
//-- Load a design from a file, loaded design will be selected
BOOL CTinyCadDoc::ReadFile(CStream &theArchive, BOOL Details, drawingCollection &drawing)
{
  try
  {
	// Save the old layer setting
	CDrawingObject*	obj		= NULL;
	BYTE			tp		= xNULL;
	CHeaderStamp	oHeader;

	LONG pos = theArchive.GetPos();

	oHeader.Read( theArchive );

	if( ! oHeader.IsChecked(false) )
	{
		// Perhaps this is XML?
		theArchive.Seek(pos);
		CXMLReader xml( &theArchive );
		return ReadFileXML( xml, Details, drawing, FALSE );
	}

	while (tp!=xEndFile) {
		theArchive >> tp;

		switch (tp) {
			case xDesignInformation:
				GetDetails().Read( theArchive );
				break;
			case xDesignInformation2:
				GetDetails().ReadEx( theArchive );
				m_snap.Load( theArchive, Details );
				break;
			case xOptions:
				if( Details )
				{
					theOptions.ReadNative( theArchive );
				}
				else
				{
					COption().ReadNative( theArchive );
				}
				obj = NULL;
				break;
			case xFont:
				theOptions.LoadFonts(theArchive);
				obj = NULL;
				break;
			case xLineStyle:
				theOptions.LoadStyles(theArchive);
				obj = NULL;
				break;
			case xFillStyle:
				theOptions.LoadFillStyles(theArchive);
				obj = NULL;
				break;
			case xMetaFiles:
				theOptions.LoadMetaFiles(theArchive);
				obj = NULL;
				break;
			case xSymbols:
				theOptions.LoadSymbols(theArchive);
				obj = NULL;
				break;
			case xLayerTable:
				{
					// Read in the number of Layers in this list
					CString theNewName;
					WORD NumberOfResources;
					theArchive >> NumberOfResources;

					hRESOURCE OldResourceNumber = 0;

					while (NumberOfResources > 0) {
						theArchive >> OldResourceNumber;
						theArchive >> theNewName;
						NumberOfResources--;
					}
					obj = NULL;
				}
				break;
			case xRuler:
				obj = new CDrawRuler(this,FALSE);
				break;
			case xBus:
				obj = new CDrawLine(this,xBus);
				break;
			case xWire:
				obj = new CDrawLine(this,xWire);
				break;
			case xBusName:
				obj = new CDrawText(this,xBusName);
				break;
			case xBusNameEx:
				obj = new CDrawText(this,xBusNameEx);
				break;
			case xLabel:  	
				obj = new CDrawLabel(this);
				break;
			case xLabelEx:
				obj = new CDrawLabel(this);
				break;
			case xLabelEx2:
				obj = new CDrawLabel(this);
				break;
			case xJunction:
				obj = new CDrawJunction(this);
				break;
			case xNoConnect:
				obj = new CDrawNoConnect(this);
				break;
			case xBusSlash:
				obj = new CDrawBusSlash(this);
				break;
			case xPower:
				obj = new CDrawPower(this);
				break;
			case xPin:
			case xPinEx:
				obj = new CDrawPin(this);
				break;
			case xLine:
				obj = new CDrawPolygon(this,xLine);
				break;
			case xLineEx:
				obj = new CDrawPolygon(this,xLineEx);
				break;
			case xLineEx2:
				obj = new CDrawPolygon(this,xLineEx2);
				break;
			case xPolygon:
				obj = new CDrawPolygon(this,xPolygon);
				break;
			case xDash:
				obj = new CDrawPolygon(this,xDash);
				break;
			case xText:		// The old text type
				obj = new CDrawText(this,xText);
				break;
			case xTextEx:
				obj = new CDrawText(this,xTextEx);
				break;
			case xTextEx2:
				obj = new CDrawText(this,xTextEx2);
				break;
			case xCircle:
			case xCircleEx:
			case xCircleEx2:
			case xCircleEx3:
				obj = new CDrawSquare(this,xCircleEx3);
				break;
			case xSquare:
			case xSquareEx:
			case xSquareEx2:
			case xSquareEx3:
				obj = new CDrawSquare(this,xSquareEx3);
				break;
			case xArc:
			case xArcEx:
			case xArcEx2:
				obj = new CDrawPolygon(this,static_cast<ObjType>(tp));
				break;
			case xMethod:		// The old method type
			case xMethodEx:
			case xMethodEx2:
			case xMethodEx3:
				obj = new CDrawMethod(this);
				break;
			case xTag:
				obj = new CDrawTag(this);
				break;
			case xMetaFile:
				obj = new CDrawMetaFile(this);
				break;
			default:
				obj = NULL;
				break;
		}
		
		if (obj!=NULL) 
		{
			// Provide special handling for old objects
			switch (tp) {
				case xSquare:
				case xSquareEx:
				case xCircle:
				case xCircleEx:
					((CDrawSquare *)obj)->OldLoad(theArchive,tp);
					break;
				case xCircleEx2:
				case xSquareEx2:
					((CDrawSquare *)obj)->OldLoad2(theArchive);
					break;
				case xMethod:
					((CDrawMethod *)obj)->OldLoad(theArchive);
					break;
				case xMethodEx:
					((CDrawMethod *)obj)->OldLoad2(theArchive);
					break;
				case xMethodEx2:
					((CDrawMethod *)obj)->OldLoad3(theArchive);
					break;
				case xPin:
					((CDrawPin *)obj)->OldLoad(theArchive);
					break;
				case xLabel:
				case xLabelEx:
				case xLabelEx2:
					((CDrawLabel *)obj)->Load(theArchive,(ObjType)tp);
					break;
				default:
					obj->Load(theArchive);
					break;
			}

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

  }

  catch( CException *e) 
  {
		CString s;
		CString msg;
		e->GetErrorMessage( msg.GetBuffer(256), 256, NULL );
		msg.ReleaseBuffer();
		s.Format(_T("Cannot load file.\r\n%s"),
			msg );
		AfxMessageBox( s );
		e->Delete();
  }


  return drawing.size() > 0;
}
예제 #11
0
// Convert this document into a metafile for pasting into
// other applications
HENHMETAFILE CTinyCadDoc::CreateMetafile( CDC &ref_dc, const TCHAR *file_name, bool bw )
{

	// Calculate the boundries
	CDRect rect = CDRect(0,0,0,0);

	if (IsSelected())
	{
		BOOL first = TRUE;

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

			if (first) 
			{
				rect.top = pointer->m_point_a.y;
				rect.bottom = pointer->m_point_a.y;
				rect.left = pointer->m_point_a.x;
				rect.right = pointer->m_point_a.x;
				first = FALSE;
			}

			rect.top 	 = min(rect.top,min(pointer->m_point_a.y,pointer->m_point_b.y));
			rect.bottom = max(rect.bottom,max(pointer->m_point_a.y,pointer->m_point_b.y));
			rect.left 	 = min(rect.left,min(pointer->m_point_a.x,pointer->m_point_b.x));
			rect.right  = max(rect.right,max(pointer->m_point_a.x,pointer->m_point_b.x));

			++ it;
		}
	}
	else
	{
		rect = CDRect( 0,0, GetDetails().m_szPage.cx, GetDetails().m_szPage.cy );
	}

	rect.InflateRect( 0,0, 10,10 );


	// Transform the origin so the design lies at 0,0
	Transform newTransform;


	int iWidthMM = ref_dc.GetDeviceCaps(HORZSIZE); 
	int iHeightMM = ref_dc.GetDeviceCaps(VERTSIZE); 
	int iWidthPels = ref_dc.GetDeviceCaps(HORZRES); 
	int iHeightPels = ref_dc.GetDeviceCaps(VERTRES); 
 
	// Convert client coordinates to .01-mm units. 
	// Use iWidthMM, iWidthPels, iHeightMM, and 
	// iHeightPels to determine the number of 
	// .01-millimeter units per pixel in the x- 
	//  and y-directions. 
 
	rect.left = (rect.left * iWidthMM * 100)/iWidthPels; 
	rect.top = (rect.top * iHeightMM * 100)/iHeightPels; 
	rect.right = (rect.right * iWidthMM * 100)/iWidthPels; 
	rect.bottom = (rect.bottom * iHeightMM * 100)/iHeightPels;


	// Create the metafile device context. 
	CRect ir( static_cast<int>(rect.left),static_cast<int>(rect.top),static_cast<int>(rect.right),static_cast<int>(rect.bottom) );
	HDC hdcMeta = CreateEnhMetaFile(ref_dc.m_hDC,file_name, &ir, GetDetails().GetTitle() ); 
 
	if (!hdcMeta) 
	{
		AfxMessageBox(_T("Cannot create enhanced metafile for the copy"));
		return NULL;
	}

	CDC theMetaDC;
	theMetaDC.Attach( hdcMeta );

	// Now render into this dc
	newTransform.SetZoomFactor( 1.0 );

	// Create the DC and render...
	{
		CContext dc(&theMetaDC,newTransform);
		dc.SetBlack( bw );

		if (IsSelected())
		{
			// Draw just the selected part
			CJunctionUtils j(this);
			selectIterator it = GetSelectBegin();
			while ( it != GetSelectEnd() ) 
			{
				j.AddObjectToTodo( *it );
				(*it)->Paint(dc,draw_normal);
				++ it;
			}
			j.PaintJunctions( dc, draw_normal );
		}
		else
		{
			// Draw the whole design into the metafile
			for( drawingIterator i = GetDrawingBegin(); i != GetDrawingEnd(); i++ ) 
			{
				(*i)->Paint(dc,draw_normal);
			}

			// Show the design details
			Display( dc );
		}

	}

	theMetaDC.Detach();

	return CloseEnhMetaFile( hdcMeta );
}
예제 #12
0
// Save as a PNG file
void CTinyCadDoc::SavePNG( const TCHAR *file_name, CDC &ref_dc, int scaling, bool bw, bool rotate )
{
	// Calculate the boundries
	CDRect rect = CDRect(0,0,0,0);

	if (IsSelected())
	{
		BOOL first = TRUE;

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

			if (first) 
			{
				rect.top = pointer->m_point_a.y;
				rect.bottom = pointer->m_point_a.y;
				rect.left = pointer->m_point_a.x;
				rect.right = pointer->m_point_a.x;
				first = FALSE;
			}

			rect.top 	 = min(rect.top,min(pointer->m_point_a.y,pointer->m_point_b.y));
			rect.bottom = max(rect.bottom,max(pointer->m_point_a.y,pointer->m_point_b.y));
			rect.left 	 = min(rect.left,min(pointer->m_point_a.x,pointer->m_point_b.x));
			rect.right  = max(rect.right,max(pointer->m_point_a.x,pointer->m_point_b.x));

			++ it;
		}
	}
	else
	{
		rect = CDRect( 0,0, GetDetails().m_szPage.cx, GetDetails().m_szPage.cy );
	}

	rect.InflateRect( 0,0, 10,10 );


	// Transform the origin so the design lies at 0,0
	Transform newTransform;
	newTransform.SetOrigin( CDPoint( rect.left, rect.top ) );

	// Set the scaling
	newTransform.SetZoomFactor( static_cast<double>(scaling) / 100.0 );
	rect.right = (rect.right * scaling) / 100;
	rect.bottom = (rect.bottom * scaling) / 100;

	CImagePNG png;
	
	CBitmap *bitmap = png.CreateImageBitmap( static_cast<int>(rect.Width()), static_cast<int>(rect.Height()), ref_dc, 32 );


	CDC bitmap_dc;
	bitmap_dc.CreateCompatibleDC( &ref_dc );
	CBitmap *old_bitmap = bitmap_dc.SelectObject( bitmap );

	bitmap_dc.SelectStockObject( WHITE_BRUSH );
	bitmap_dc.SelectStockObject( WHITE_PEN );
	bitmap_dc.Rectangle( 0,0,static_cast<int>(rect.Width()), static_cast<int>(rect.Height()) );

	// Create the DC and render...
	{
		CContext dc(&bitmap_dc,newTransform);
		if (bw)
		{
			dc.SetBlack( TRUE );
		}

		if (IsSelected())
		{
			// Draw just the selected part
			CJunctionUtils j( this );			
			for( selectIterator i = GetSelectBegin(); i != GetSelectEnd(); i++ ) 
			{
				j.AddObjectToTodo( *i );
				(*i)->Paint(dc,draw_normal);
			}
			j.PaintJunctions(dc,draw_normal);
		}
		else
		{
			// Draw the whole design into the metafile
			drawingIterator it = GetDrawingBegin();
			while (it != GetDrawingEnd()) 
			{
				(*it)->Paint(dc,draw_normal);
				++ it;
			}

			// Show the design 
			Display( dc );
		}

	}

	bitmap_dc.SelectObject( old_bitmap );

	// Do we rotate?
	if (rotate)
	{
		png.Rotate( ref_dc );
	}

	// ... and save to a png
	png.Save( ref_dc, file_name );
}
예제 #13
0
// Draw the design rulers and the details box
void CTinyCadDoc::Display( CContext& dc )
{
	GetDetails().Display( dc, theOptions, m_pParent->GetPathName() );
}