broken SCH_COMPONENT::GetRotationMiroir() rewritten (problem when editing a mirrored and rotated component fixed)
This commit is contained in:
parent
4b212810dd
commit
dea07b0fac
|
@ -820,70 +820,47 @@ void SCH_COMPONENT::SetRotationMiroir( int type_rotate )
|
||||||
|
|
||||||
|
|
||||||
int SCH_COMPONENT::GetRotationMiroir()
|
int SCH_COMPONENT::GetRotationMiroir()
|
||||||
|
/** function GetRotationMiroir()
|
||||||
|
* Used to display component orientation (in dialog editor or info)
|
||||||
|
* @return the orientation and mirror
|
||||||
|
* Note: Because there are different ways to have a given orientation/mirror,
|
||||||
|
* the orientation/mirror is not necessary wht the used does
|
||||||
|
* (example : a mirrorX then a mirrorY give no mirror but rotate the component).
|
||||||
|
* So this function find a rotation and a mirror value
|
||||||
|
* ( CMP_MIROIR_X because this is the first mirror option tested)
|
||||||
|
* but can differs from the orientation made by an user
|
||||||
|
* ( a CMP_MIROIR_Y is find as a CMP_MIROIR_X + orientation 180, because they are equivalent)
|
||||||
|
*
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
int type_rotate = CMP_ORIENT_0;
|
int type_rotate = CMP_ORIENT_0;
|
||||||
int TempMat[2][2], MatNormal[2][2];
|
int ComponentMatOrient[2][2];
|
||||||
int ii;
|
int ii;
|
||||||
bool found = FALSE;
|
|
||||||
|
|
||||||
memcpy( TempMat, m_Transform, sizeof( TempMat ) );
|
#define ROTATE_VALUES_COUNT 12
|
||||||
SetRotationMiroir( CMP_ORIENT_0 );
|
int rotate_value[ROTATE_VALUES_COUNT] = // list of all possibilities, but only the first 8 are actually used
|
||||||
memcpy( MatNormal, m_Transform, sizeof( MatNormal ) );
|
{
|
||||||
|
CMP_ORIENT_0, CMP_ORIENT_90, CMP_ORIENT_180, CMP_ORIENT_270,
|
||||||
|
CMP_MIROIR_X + CMP_ORIENT_0, CMP_MIROIR_X + CMP_ORIENT_90, CMP_MIROIR_X + CMP_ORIENT_180, CMP_MIROIR_X + CMP_ORIENT_270,
|
||||||
|
CMP_MIROIR_Y + CMP_ORIENT_0, CMP_MIROIR_Y + CMP_ORIENT_90, CMP_MIROIR_Y + CMP_ORIENT_180, CMP_MIROIR_Y + CMP_ORIENT_270
|
||||||
|
};
|
||||||
|
|
||||||
for( ii = 0; ii < 4; ii++ )
|
// Try to find the current transform option:
|
||||||
|
memcpy( ComponentMatOrient, m_Transform, sizeof( ComponentMatOrient ) );
|
||||||
|
|
||||||
|
for( ii = 0; ii < ROTATE_VALUES_COUNT; ii++ )
|
||||||
{
|
{
|
||||||
if( memcmp( TempMat, m_Transform, sizeof(MatNormal) ) == 0 )
|
type_rotate = rotate_value[ii];
|
||||||
{
|
SetRotationMiroir( type_rotate );
|
||||||
found = TRUE;
|
if( memcmp( ComponentMatOrient, m_Transform, sizeof(ComponentMatOrient) ) == 0 )
|
||||||
break;
|
return type_rotate;
|
||||||
}
|
|
||||||
SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !found )
|
// Error: orientation not found in list (should not happen)
|
||||||
{
|
DisplayError(NULL, wxT("Component orientation matrix internal error") );
|
||||||
type_rotate = CMP_MIROIR_X + CMP_ORIENT_0;
|
memcpy( m_Transform, ComponentMatOrient, sizeof( ComponentMatOrient ) );
|
||||||
SetRotationMiroir( CMP_NORMAL );
|
|
||||||
SetRotationMiroir( CMP_MIROIR_X );
|
|
||||||
for( ii = 0; ii < 4; ii++ )
|
|
||||||
{
|
|
||||||
if( memcmp( TempMat, m_Transform, sizeof( MatNormal ) ) == 0 )
|
|
||||||
{
|
|
||||||
found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !found )
|
|
||||||
{
|
|
||||||
type_rotate = CMP_MIROIR_Y + CMP_ORIENT_0;
|
|
||||||
SetRotationMiroir( CMP_NORMAL );
|
|
||||||
SetRotationMiroir( CMP_MIROIR_Y );
|
|
||||||
for( ii = 0; ii < 4; ii++ )
|
|
||||||
{
|
|
||||||
if( memcmp( TempMat, m_Transform, sizeof( MatNormal ) ) == 0 )
|
|
||||||
{
|
|
||||||
found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy( m_Transform, TempMat, sizeof( m_Transform ) );
|
|
||||||
|
|
||||||
if( found )
|
|
||||||
{
|
|
||||||
return type_rotate + ii;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxBell();
|
|
||||||
return CMP_NORMAL;
|
return CMP_NORMAL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -170,7 +170,19 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetRotationMiroir( int type );
|
void SetRotationMiroir( int type );
|
||||||
|
/** function GetRotationMiroir()
|
||||||
|
* Used to display component orientation (in dialog editor or info)
|
||||||
|
* @return the orientation and mirror
|
||||||
|
* Note: Because there are different ways to have a given orientation/mirror,
|
||||||
|
* the orientation/mirror is not necessary wht the used does
|
||||||
|
* (example : a mirrorX then a mirrorY give no mirror but rotate the component).
|
||||||
|
* So this function find a rotation and a mirror value
|
||||||
|
* ( CMP_MIROIR_X because this is the first mirror option tested)
|
||||||
|
* but can differs from the orientation made by an user
|
||||||
|
* ( a CMP_MIROIR_Y is find as a CMP_MIROIR_X + orientation 180, because they are equivalent)
|
||||||
|
*/
|
||||||
int GetRotationMiroir();
|
int GetRotationMiroir();
|
||||||
|
|
||||||
wxPoint GetScreenCoord( const wxPoint& coord );
|
wxPoint GetScreenCoord( const wxPoint& coord );
|
||||||
void Display_Infos( WinEDA_DrawFrame* frame );
|
void Display_Infos( WinEDA_DrawFrame* frame );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue