Esempio n. 1
0
CMultiButton::CMultiButton(QWidget* parent)
  : CBlockGraphicsView(parent),
    m_id(0),
    m_mask(0)
{
  m_scene = new CBlockGraphicsScene(0, 0, 16, 16, parent);

  setScene(m_scene);
  setSceneRect(0, 0, 16, 16, true, true);
  m_scene->setMappingSource(CByteMatrix(1, 1, 0));

}
Esempio n. 2
0
CByteMatrix CByteMatrix::Inv() const
{
	if (m!=n)
	{
		pErrorProc((void*)this,MATERR_DIMENSION,dwData);
		return *this;
	}
	else
	{
		switch (m)
		{
		case 1:
			if (GetModulo256Inv(pMatrix[0])==0)
			{
				pErrorProc((void*)this,MATERR_NOINVERSE,dwData);
				return *this;
			}
			return CByteMatrix(1,1,GetModulo256Inv(pMatrix[0]));
		case 2:
			{
				BYTE nInvDet=GetModulo256Inv(det2(*this));
				if (nInvDet==0)
				{
					pErrorProc((void*)this,MATERR_NOINVERSE,dwData);
					return *this;
				}
				return CByteMatrix(2,2,nInvDet*e(2,2),-nInvDet*e(1,2),-nInvDet*e(2,1),nInvDet*e(1,1));
			}
		case 3:
			{
				BYTE nInvDet=GetModulo256Inv(det3(*this));
				if (nInvDet==0)
				{
					pErrorProc((void*)this,MATERR_NOINVERSE,dwData);
					return *this;
				}
				CByteMatrix inv;
				inv.SetErrorProc(pErrorProc,dwData);
				inv.m=inv.n=3;
				inv.pMatrix=new BYTE[9];
				for (UINT i=1;i<=3;i++)
				{
					for (UINT j=1;j<=3;j++)
					{
						me(inv,j,i)=nInvDet*Cof(i,j);
					}
				}
				return inv;
			}
		default:
			{
				BYTE nInvDet=GetModulo256Inv(det(*this));
				if (nInvDet==0)
				{
					pErrorProc((void*)this,MATERR_NOINVERSE,dwData);
					return *this;
				}
				CByteMatrix inv;
				inv.SetErrorProc(pErrorProc,dwData);
				inv.m=inv.n=m;
				inv.pMatrix=new BYTE[inv.m*inv.m];
				for (UINT i=1;i<=inv.m;i++)
				{
					for (UINT j=1;j<=inv.n;j++)
					{
						me(inv,j,i)=nInvDet*Cof(i,j);
					}
				}
				return inv;
			}
		}
	}
	pErrorProc((void*)this,MATERR_NOINVERSE,dwData);
	return *this;
}