// percentChunk is a number between 0 and 100, the amoun of % points that this will eat up
void CSerialMapStringToOb::storeSerialize(CArchive &ar, CSimpleProgressBar* pProgress,  int percentChunk)
{
	if(ar.IsStoring())
	{
		CObject* pObj;
		CString sKey;
		int sz = GetCount();
		int iProgCount=0;
		int lastPer=0;
		int basePer = 0;
		if(pProgress)
			basePer = pProgress->m_nPercentage;

		POSITION p = GetStartPosition( );
		while(p)
		{
			GetNextAssoc(p, sKey, pObj);
			if(pObj)
				pObj->Serialize(ar);
			if(pProgress)
			{
				++iProgCount;
				int per = basePer + int(percentChunk*iProgCount/sz);
				if(per >= lastPer + 2)
					pProgress->Step(per);
			}
		}
	}
	else
	{
		ASSERT(FALSE); // can only output serialize
	}
}
Esempio n. 2
0
void CCAttrMap::TransformBrushFills(TransformBase& Trans)
{
	CCRuntimeClass	   *pType;
	void			   *pVal;
	for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); )
	{
		GetNextAssoc(Pos,pType,pVal);
		if (pVal != NULL)
		{
			NodeAttribute* pNodeAttr = (NodeAttribute *)pVal;
			
			// check that we are not about to set line width to zero
			if( pNodeAttr->IsALineWidthAttr() && Trans.TransLines != FALSE )
			{
				INT32 Test = labs( INT32(Trans.GetScalar().MakeDouble() * ((AttrLineWidth*)pNodeAttr)->Value.LineWidth) );		
				if (Test <= 10)
					Trans.TransLines = FALSE;
			}

			if (!pNodeAttr->NeedsToRenderAtEachBrushStroke())
				pNodeAttr->Transform(Trans);
		}
	}


}
Esempio n. 3
0
CCAttrMap* CCAttrMap::Copy()
{
	CCAttrMap		   *pNewAttrMap = new CCAttrMap( GetCount() );
	if( pNewAttrMap != NULL )
	{
		// iterating all (key, value) pairs
		for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); )
		{
			CCRuntimeClass *pType;
			void	   *pVal;
			GetNextAssoc( Pos, pType, pVal );

			// Get the attribute value of this attribute
			NodeAttribute* pAttr = (NodeAttribute*)pVal;

			// Copy the attribute
			NodeAttribute* pNewAttr = (NodeAttribute*) (pAttr->SimpleCopy());

			// Stick the new attr into the new attr map
			if (pNewAttr != NULL)
				pNewAttrMap->SetAt(pNewAttr->GetAttributeType(),pNewAttr);
		}
	}

	pNewAttrMap->attrMapCreator = attrMapCreator;

	return pNewAttrMap;
}
Esempio n. 4
0
void CCAttrMap::ApplyAttributesToNode(NodeRenderableInk * pInk)
{
	iterator			pos = GetStartPosition();

	while( pos != GetEndPosition() )
	{
		CCRuntimeClass *pKey;
		void		   *pVal;
		GetNextAssoc(pos, pKey, pVal);

		NodeAttribute * pAttr = (NodeAttribute *)pVal;

		// copy the attribute
		if( pAttr->CanBeAppliedToObject() )
		{
			NodeAttribute * pAttrCopy = NULL;
			pAttr->NodeCopy((Node **)(&pAttrCopy));
			
			pAttrCopy->AttachNode(pInk, LASTCHILD);

			// nb now that GLAs have an independent flag to indicate when
			// they are copied from the default, it is safe to fix linkages
			// this ensures that GLA defaults get copied when BlendRefs are
			// made from complex nodes, and that they are found when MakeAppliedAttributes
			// calls FindAppliedAttributes on the unattached subtree
			// TODO??
			// What about just copying compound node's Parent pointers to 
			// pseudo attach the tree, rather than copying applied attrs to unattached tree
			// Just need to watch when deleting that it doesn't do anything to the
			// parents pointers - which it shouldn't surely?
			pAttrCopy->LinkToGeometry(pInk);
		}
	}
}
Esempio n. 5
0
void CCAttrMap::TransformForBrush(TransformBase& Trans)
{
	CCRuntimeClass	   *pType;
	void			   *pVal;
	for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); )
	{
		GetNextAssoc(Pos,pType,pVal);
		if (pVal != NULL)
		{
			NodeAttribute* pNodeAttr = (NodeAttribute *)pVal;
			
			// check that we are not about to set line width to zero
			if( pNodeAttr->IsALineWidthAttr() && Trans.TransLines != FALSE )
			{
				double Test =  Trans.GetScalar().MakeDouble() * (double)((AttrLineWidth*)pNodeAttr)->Value.LineWidth;
		//		TRACEUSER( "Diccon", _T("Scale line width by %f\n"), Test);
				if (Test <= 1.0)
				{
				//	TRACEUSER( "Diccon", _T("Setting line width scaling OFF\n"));
					Trans.TransLines = FALSE;
				}
			}

			if (pNodeAttr->NeedsToRenderAtEachBrushStroke())
				pNodeAttr->Transform(Trans);
		}
	}
}
Esempio n. 6
0
void CMapFunctionProperties::PrintMap()
{
	
	CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd();
	CObject *pNext;
	
	CFunctionProperties *pCurrent = NULL;
	POSITION pos;
	TCHAR buffer[8];

	

	if( GetCount() == 0 )
	{
		pMainFrame->m_wndOutputTabView.AddMsg1(_T("FunctionProperties Map is Empty"));	
	}
	else
	{
		pMainFrame->m_wndOutputTabView.AddMsg1(_T("*** FUNCTION PROPERTIES MAP ***"));
		
		pos = GetStartPosition();
		while( pos != NULL )
		{
			CString ref = _T("REF_");
			CString strItem = _T("ITEM_");
			CString strFile = _T("FILE_");
			CString strPath = _T("PATH_");
			CString strLang = _T("LANG");
			CString strRType = _T("RETURN_TYPE");

			GetNextAssoc(pos, ref, pNext);
			pCurrent = (CFunctionProperties *) pNext;
			pMainFrame->m_wndOutputTabView.AddMsg1(ref);
			HTREEITEM hItem = pCurrent->getItem();
			int item = (int )hItem;
			strItem +=  _itot( item, buffer, 10 );
			pMainFrame->m_wndOutputTabView.AddMsg1(strItem);
			strFile += (const TCHAR *)pCurrent->getFile();
			pMainFrame->m_wndOutputTabView.AddMsg1(strFile);
			strPath += (const TCHAR *)pCurrent->getPath();
			pMainFrame->m_wndOutputTabView.AddMsg1(strPath);
			int lang = pCurrent->getLanguage();
			strLang =  _itot( lang, buffer, 10 );
			pMainFrame->m_wndOutputTabView.AddMsg1(strLang);
			int rtype = pCurrent->getReturnType();
			strRType = _itot( rtype, buffer, 10 );
			pMainFrame->m_wndOutputTabView.AddMsg1(strRType);
			pMainFrame->m_wndOutputTabView.AddMsg1(_T("************************"));	
		}

	}
	


}
 void FreeAllEntries()
 {
     POSITION pos = GetStartPosition();
     void *p, *pp;
     while (pos)
     {
         GetNextAssoc(pos, p, pp);
         if (p == pp) free(p);
         else
             FailCase("ERROR: freeing invalid pointer %p\n", p);
     }
 }
//--------------------------------------------------------------------------------
bool CFileIndexObjMap::Write(CFile& file)
	{
	DWORD nPos;
	bool bPosOk = false;
	bool bRv = true;
	POSITION pos = GetStartPosition();

	TRY
		{
		nPos = file.GetPosition();
		bPosOk = true;
		DWORD nNum = 'CMAP';
		file.Write(&nNum, sizeof(nNum));
		nNum = GetCount();
		file.Write(&nNum, sizeof(nNum));
		}
	CATCH_ALL(e)
		{
		bRv = false;
		pos = NULL;
		}
	END_CATCH_ALL;

	while(pos != NULL)
		TRY
			{
			LPCTSTR pKey;
			CFileIndexObject* pObj;
			GetNextAssoc(pos, pKey, pObj);
			if(pObj == NULL)
				THROW(new CException);

			pObj->Write(file, false);
			}
		CATCH_ALL(e)
			{
			bRv = false;
			break;
			}
		END_CATCH_ALL;

	if(bPosOk && ! bRv)
		TRY
			{
			file.Seek(nPos, CFile::begin);
			}
		CATCH_ALL(e)
			{
			}
		END_CATCH_ALL;

	return bRv;
	}
Esempio n. 9
0
void CTypeLibCacheMap::RemoveAll(void* pExcept)
{
	POSITION pos = GetStartPosition();
	void* pTypeLibID;
	CTypeLibCache* pCache;
	while (pos != NULL)
	{
		GetNextAssoc(pos, pTypeLibID, (void*&)pCache);
		if (pCache != pExcept)
			delete pCache;
	}
}
Esempio n. 10
0
void CCSRegionsMap::cleanup()
{
    CCSRegions* pRegions = NULL;
    UINT key = 0;
    POSITION pos = GetStartPosition();
    while (pos)  {
        GetNextAssoc(pos, key, pRegions);
        pRegions->RemoveAll();
        delete pRegions;
        pRegions = NULL;
    }
    RemoveAll();
}
Esempio n. 11
0
void CMapVariableProperties::PrintMap()
{
	
	CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd();
	CObject *pNext;
	
	CVariableProperties *pCurrent = NULL;
	POSITION pos;
	TCHAR buffer[8];

	

	if( GetCount() == 0 )
	{
		pMainFrame->m_wndOutputTabView.AddMsg1(_T("VariableProperties Map is Empty"));	
	}
	else
	{
		pMainFrame->m_wndOutputTabView.AddMsg1(_T("*** VARIABLE PROPERTIES MAP ***"));
		
		pos = GetStartPosition();
		while( pos != NULL )
		{
			CString ref = _T("REF_");
			CString strItem = _T("ITEM_");
			CString strFile = _T("FILE_");
			CString strPath = _T("PATH_");
			CString strType = _T("TYPE_");

			GetNextAssoc(pos, ref, pNext);
			pCurrent = (CVariableProperties *) pNext;
			pMainFrame->m_wndOutputTabView.AddMsg1(ref);
			HTREEITEM hItem = pCurrent->getItem();
			int item = (int )hItem;
			strItem +=  _itot( item, buffer, 10 );
			pMainFrame->m_wndOutputTabView.AddMsg1(strItem);
			strFile += (const TCHAR *)pCurrent->getFile();
			pMainFrame->m_wndOutputTabView.AddMsg1(strFile);
			strPath += (const TCHAR *)pCurrent->getPath();
			pMainFrame->m_wndOutputTabView.AddMsg1(strPath);
			int type = pCurrent->getType();
			strType = _itot( type, buffer, 10 );
			pMainFrame->m_wndOutputTabView.AddMsg1(strType);
			pMainFrame->m_wndOutputTabView.AddMsg1(_T("************************"));	
		}

	}
	


}
Esempio n. 12
0
void CSTabCtrl::CPageToControlsMap::RemoveAll( )
{
	POSITION _rPos = GetStartPosition();
	CSTabPage * _pValue = NULL;
	INT _rKey;

	while(_rPos)
	{
		GetNextAssoc(_rPos,_rKey,_pValue);
		delete _pValue;
	}

	CMap <INT, INT&,CSTabPage *, CSTabPage *>::RemoveAll();
}
Esempio n. 13
0
void CCAttrMap::Transform(TransformBase& Trans)
{
	CCRuntimeClass	   *pType;
	void			   *pVal;
	for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); )
	{
		GetNextAssoc(Pos,pType,pVal);
		if (pVal != NULL)
		{
			NodeAttribute* pNodeAttr = (NodeAttribute *)pVal;
			pNodeAttr->Transform(Trans);
		}
	}
}
Esempio n. 14
0
//
// Remove clone clusters that contain only one region
//
bool CCSRegionsMap::removeSingletons()
{
    CCSRegions* pRegions = NULL;
    UINT key;
    POSITION pos = GetStartPosition();
    while (pos)  {
        GetNextAssoc(pos, key, pRegions);
        if (pRegions->GetSize() < 2) {
            RemoveKey(key);
            delete pRegions;
            pRegions = NULL;
        }
    }
    return true;
}
void CConnections::RemoveAll()
{

	POSITION pos;
	CString sKey;
	pos = GetStartPosition();
	CConnection* pConnection;
	
	while (NULL!=pos) {
		GetNextAssoc(pos,sKey,pConnection);
		Remove(sKey);
		pos = GetStartPosition();
	}

}
void CConnections::Serialize( CArchive& archive )
{
	int iCount=0;
	POSITION pos;
	CString sKey;
	CConnection* pConnection;
	WORD wType;
	int i=0;
	
	// call base class function first
	// base class is CObject in this case
	CObject::Serialize( archive );
	
	
	// now do the stuff for our specific class
	if( archive.IsStoring() ){
		iCount=GetCount();
		archive <<iCount;
		
		pos = GetStartPosition();
		
		while (NULL!=pos) {
			GetNextAssoc(pos,sKey,pConnection);
			//Serialize each connection 
			archive <<sKey<< pConnection->Type();
			pConnection->Serialize(archive);
		}
		
	} 
	
	else {
		archive >>iCount;
		
		for (i=0;i<iCount;i++){
			archive >>sKey>>wType;
			pConnection= Add(sKey,wType);
			pConnection->Serialize(archive);
			if (CConnection::AUTO==pConnection->Type()) {
				if (!pConnection->AutoPtr()->m_pIModbusSrv) {
					Remove(sKey);
				}
			}
			
		}
	}
	
}
BOOL CWorldConnList::FindVWComm(IVWComm *pVWComm)
{
	POSITION pos;

	for (pos = GetStartPosition(); pos != NULL; )
	{
		IVWCommConnection *pvKey = NULL;
		ConnectionInfo cinfo;

		GetNextAssoc(pos, pvKey, cinfo);

		if (cinfo.pVWComm == pVWComm) 
			return TRUE;	 
	}

	return FALSE;
}
Esempio n. 18
0
/********************************************************************************************

>	void CCAttrMap::BuildListOfAttributes(List * pList)

	Author:		David_McClarnon (Xara Group Ltd) <*****@*****.**>
	Created:	30/4/99
	Inputs:		The list to use
	Outputs:	-
	Returns:	-
	Purpose:	Builds a list of NodeListItems of all the attributes in this attribute map
	Notes:		Includes all attributes - even those which can't be applied to objects
				Use CanBeAppliedToObject to test
	SeeAlso:	-

********************************************************************************************/
void CCAttrMap::BuildListOfAttributes(List * pList)
{
	iterator			pos = GetStartPosition();

	NodeListItem	   *pItem = NULL;

	while( pos != GetEndPosition() )
	{
		CCRuntimeClass *pKey;
		void		   *pVal;
		GetNextAssoc( pos, pKey, pVal );

		pItem = new NodeListItem((NodeAttribute *)pVal);

		pList->AddTail(pItem);
	}
}
Esempio n. 19
0
/********************************************************************************************

>	BOOL CCAttrMap::IsSeeThrough()

	Author:		Karim_MacDonald (Xara Group Ltd) <*****@*****.**>
	Created:	19/02/2001

	Returns:	TRUE if at least one of our attrs IsSeeThrough(),
				FALSE otherwise.

	Purpose:	Test each of the attributes in this map for see-through-ness.
				This is not the same as transparency - what it means is: if I draw something
				in white, then draw its outline as retrieved from PathBecomeA in black over
				the top, will I still be able to see white bits?
				IsSeeThrough() therefore depends partly on the implementation of PathBecomeA.

				Examples:
					Transparency is always see-through unless it is a zero transparency.
					Line width is not see through - PathBecomeA can cope with this attr.
					Fill colour is not see-through unless it is COLOUR_NONE.
					Brush attrs are normally see-through, as PathBecomeA ignores them.

	See Also:	NodeRenderableInk::IsSeeThrough()

********************************************************************************************/
BOOL CCAttrMap::IsSeeThrough()
{
	CCRuntimeClass	   *pKey;
	void			   *pVal;
	BOOL				bIsSeeThrough = FALSE;

	for ( iterator	pos = GetStartPosition();
					pos != GetEndPosition() && !bIsSeeThrough;	)
	{
		GetNextAssoc(pos, pKey, pVal);
		NodeAttribute* pAttr = (NodeAttribute*)pVal;

		bIsSeeThrough = pAttr->IsSeeThrough(FALSE);
	}

	return bIsSeeThrough;
}
void CWorldConnList::RemoveAll()
{
	// iterate through map, releasing worlds
	POSITION pos;

	for (pos = GetStartPosition(); pos != NULL; )
	{
		IVWCommConnection *pvKey = NULL;
		ConnectionInfo cinfo;

		GetNextAssoc(pos, pvKey, cinfo);

		SAFERELEASE(cinfo.pWorld);
		SAFERELEASE(cinfo.pVWComm);
	}

    CVWMap<IVWCommConnection *,IVWCommConnection *,ConnectionInfo,ConnectionInfo&>::RemoveAll();
}
Esempio n. 21
0
void CMapVariableProperties::ClearMap()
{
	CString ref;
	CObject *pNext = NULL;

	POSITION pos = GetStartPosition();

	while( pos != NULL )
	{
		GetNextAssoc( pos, ref, pNext );
		delete pNext;

	}

	RemoveAll();


}
Esempio n. 22
0
void CCAttrMap::DeleteAttributes()
{
	CCRuntimeClass	   *pType;
	void			   *pVal;

	// iterating all (key, value) pairs
	for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); )
	{
		// Get attr at position Pos
		GetNextAssoc( Pos, pType, pVal );

		if (pVal != NULL)
		{
			RemoveKey(pType);
			// Must cast to NodeAttribute before deleting, otherwise wrong destructor gets called
			delete (NodeAttribute*)pVal;
		}
	}
}
Esempio n. 23
0
void CMapWordToPtr::Dump(CDumpContext& dc) const
{
	CObject::Dump(dc);

	dc << "with " << LONGLONG(m_nCount) << " elements";
	if (dc.GetDepth() > 0)
	{
		// Dump in format "[key] -> value"
		WORD key;
		void* val;

		POSITION pos = GetStartPosition();
		while (pos != NULL)
		{
			GetNextAssoc(pos, key, val);
			dc << "\n\t[" << key << "] = " << val;
		}
	}

	dc << "\n";
}
Esempio n. 24
0
void CMapStringToString::Dump(CDumpContext& dc) const
{
	CObject::Dump(dc);

	dc << "with " << m_nCount << " elements";
	if (dc.GetDepth() > 0)
	{
		// Dump in format "[key] -> value"
		CString key;
		CString val;

		POSITION pos = GetStartPosition();
		while (pos != NULL)
		{
			GetNextAssoc(pos, key, val);
			dc << "\n\t[" << key << "] = " << val;
		}
	}

	dc << "\n";
}
Esempio n. 25
0
/********************************************************************************************

>	void CCAttrMap::Render(RenderRegion * pRegion, BOOL RenderOffscreenAttributes = TRUE)

	Author:		David_McClarnon (Xara Group Ltd) <*****@*****.**>
	Created:	30/4/99
	Inputs:		pRegion						render-region to render into.
				RenderOffscreenAttributes	whether or not to render offscreen attributes,
											eg feathers.
	Outputs:	-
	Returns:	-
	Purpose:	Renders the attribute map into the given render region

	Notes:		Karim 15/11/2000
				Modified so that I can render an attribute map *without*
				rendering any offscreen attributes contained therein.

	SeeAlso:	-

********************************************************************************************/
void CCAttrMap::Render(RenderRegion * pRegion, BOOL RenderOffscreenAttributes)
{
	// OK, we have found the full quota of attributes.  Now render them all.
	iterator			pos = GetStartPosition();
	while( pos != GetEndPosition() )
	{
		CCRuntimeClass *pKey;
		void		   *pVal;
		GetNextAssoc( pos, pKey, pVal );

		NodeAttribute* pAttr = (NodeAttribute*)pVal;

		if ( pAttr->CanBeAppliedToObject() &&
			 pAttr->RenderSubtree(pRegion)==SUBTREE_ROOTONLY )
		{
			// render all attributes, unless we've been specifically asked
			// not to render offscreen attributes.
			if (RenderOffscreenAttributes || !pAttr->IsAnOffscreenAttribute())
				pAttr->Render(pRegion);
		}
	}
}
Esempio n. 26
0
void CMapStringToOb::Serialize( CArchive &ar )
/********************************************/
{
    CObject::Serialize( ar );

    CString key;
    CObject *value;
    if( ar.IsStoring() ) {
        ar.WriteCount( m_nCount );
        POSITION position = GetStartPosition();
        while( position != NULL ) {
            GetNextAssoc( position, key, value );
            ar << key;
            ar << value;
        }
    } else {
        UINT nCount = ar.ReadCount();
        for( int i = 0; i < nCount; i++ ) {
            ar >> key;
            ar >> value;
            SetAt( key, value );
        }
    }
}
Esempio n. 27
0
void CMapDWORDToChar::Dump(CDumpContext& dc) const
{
	ASSERT_VALID(this);

#define MAKESTRING(x) #x
	AFX_DUMP1(dc, "a " MAKESTRING(CMapDWORDToChar) " with ", m_nCount);
	AFX_DUMP0(dc, " elements");
#undef MAKESTRING
	if (dc.GetDepth() > 0)
	{
		// Dump in format "[key] -> value"
		POSITION pos = GetStartPosition();
		DWORD key;
		char val;

		AFX_DUMP0(dc, "\n");
		while (pos != NULL)
		{
			GetNextAssoc(pos, key, val);
			AFX_DUMP1(dc, "\n\t[", key);
//			AFX_DUMP1(dc, "] = ", val);
		}
	}
}