Refactoring of VIEW/VIEW_ITEM classes:
- Remove dependency of EDA_ITEM on VIEW - VIEW_ITEM is now a pure virtual interface
This commit is contained in:
parent
27a10e8597
commit
1c1f4e9a50
|
@ -43,22 +43,23 @@ const BOX2I ORIGIN_VIEWITEM::ViewBBox() const
|
|||
}
|
||||
|
||||
|
||||
void ORIGIN_VIEWITEM::ViewDraw( int, GAL* aGal ) const
|
||||
void ORIGIN_VIEWITEM::ViewDraw( int, VIEW* aView ) const
|
||||
{
|
||||
auto gal = aView->GetGAL();
|
||||
// Nothing to do if the target shouldn't be drawn at 0,0 and that's where the target is. This
|
||||
// mimics the Legacy canvas that doesn't display most targets at 0,0
|
||||
if( !m_drawAtZero && ( m_position.x == 0 ) && ( m_position.y == 0 ) )
|
||||
return;
|
||||
|
||||
aGal->SetIsStroke( true );
|
||||
aGal->SetIsFill( false );
|
||||
aGal->SetLineWidth( 1 );
|
||||
aGal->SetStrokeColor( m_color );
|
||||
VECTOR2D scaledSize = m_view->ToWorld( VECTOR2D( m_size, m_size ), false );
|
||||
gal->SetIsStroke( true );
|
||||
gal->SetIsFill( false );
|
||||
gal->SetLineWidth( 1 );
|
||||
gal->SetStrokeColor( m_color );
|
||||
VECTOR2D scaledSize = aView->ToWorld( VECTOR2D( m_size, m_size ), false );
|
||||
|
||||
// Draw a circle around the marker's centre point if the style demands it
|
||||
if( ( m_style == CIRCLE_CROSS ) || ( m_style == CIRCLE_DOT ) || ( m_style == CIRCLE_X ) )
|
||||
aGal->DrawCircle( m_position, scaledSize.x );
|
||||
gal->DrawCircle( m_position, scaledSize.x );
|
||||
|
||||
switch( m_style )
|
||||
{
|
||||
|
@ -67,22 +68,22 @@ void ORIGIN_VIEWITEM::ViewDraw( int, GAL* aGal ) const
|
|||
|
||||
case CROSS:
|
||||
case CIRCLE_CROSS:
|
||||
aGal->DrawLine( m_position - VECTOR2D( scaledSize.x, 0 ),
|
||||
gal->DrawLine( m_position - VECTOR2D( scaledSize.x, 0 ),
|
||||
m_position + VECTOR2D( scaledSize.x, 0 ) );
|
||||
aGal->DrawLine( m_position - VECTOR2D( 0, scaledSize.y ),
|
||||
gal->DrawLine( m_position - VECTOR2D( 0, scaledSize.y ),
|
||||
m_position + VECTOR2D( 0, scaledSize.y ) );
|
||||
break;
|
||||
|
||||
case X:
|
||||
case CIRCLE_X:
|
||||
aGal->DrawLine( m_position - scaledSize, m_position + scaledSize );
|
||||
gal->DrawLine( m_position - scaledSize, m_position + scaledSize );
|
||||
scaledSize.y = -scaledSize.y;
|
||||
aGal->DrawLine( m_position - scaledSize, m_position + scaledSize );
|
||||
gal->DrawLine( m_position - scaledSize, m_position + scaledSize );
|
||||
break;
|
||||
|
||||
case DOT:
|
||||
case CIRCLE_DOT:
|
||||
aGal->DrawCircle( m_position, scaledSize.x / 4 );
|
||||
gal->DrawCircle( m_position, scaledSize.x / 4 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <view/view.h>
|
||||
#include <view/view_group.h>
|
||||
#include <view/view_item.h>
|
||||
#include <view/view_rtree.h>
|
||||
#include <gal/definitions.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
|
@ -38,7 +39,219 @@
|
|||
#include <profile.h>
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
using namespace KIGFX;
|
||||
namespace KIGFX {
|
||||
|
||||
class VIEW;
|
||||
|
||||
class VIEW_ITEM_DATA
|
||||
{
|
||||
public:
|
||||
VIEW_ITEM_DATA() :
|
||||
m_flags( KIGFX::VISIBLE ),
|
||||
m_requiredUpdate( KIGFX::NONE ),
|
||||
m_groups( nullptr ),
|
||||
m_groupsSize( 0 ) {}
|
||||
|
||||
~VIEW_ITEM_DATA()
|
||||
{
|
||||
delete[] m_groups;
|
||||
}
|
||||
|
||||
int getFlags() const
|
||||
{
|
||||
return m_flags;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class VIEW;
|
||||
|
||||
/**
|
||||
* Function getLayers()
|
||||
* Returns layer numbers used by the item.
|
||||
*
|
||||
* @param aLayers[]: output layer index array
|
||||
* @param aCount: number of layer indices in aLayers[]
|
||||
*/
|
||||
void getLayers( int* aLayers, int& aCount ) const
|
||||
{
|
||||
int* layersPtr = aLayers;
|
||||
|
||||
for( unsigned int i = 0; i < m_layers.size(); ++i )
|
||||
{
|
||||
if( m_layers[i] )
|
||||
*layersPtr++ = i;
|
||||
}
|
||||
|
||||
aCount = m_layers.count();
|
||||
}
|
||||
|
||||
VIEW* m_view; ///< Current dynamic view the item is assigned to.
|
||||
int m_flags; ///< Visibility flags
|
||||
int m_requiredUpdate; ///< Flag required for updating
|
||||
|
||||
///* Helper for storing cached items group ids
|
||||
typedef std::pair<int, int> GroupPair;
|
||||
|
||||
///* Indexes of cached GAL display lists corresponding to the item (for every layer it occupies).
|
||||
///* (in the std::pair "first" stores layer number, "second" stores group id).
|
||||
GroupPair* m_groups;
|
||||
int m_groupsSize;
|
||||
|
||||
/**
|
||||
* Function getGroup()
|
||||
* Returns number of the group id for the given layer, or -1 in case it was not cached before.
|
||||
*
|
||||
* @param aLayer is the layer number for which group id is queried.
|
||||
* @return group id or -1 in case there is no group id (ie. item is not cached).
|
||||
*/
|
||||
int getGroup( int aLayer ) const
|
||||
{
|
||||
for( int i = 0; i < m_groupsSize; ++i )
|
||||
{
|
||||
if( m_groups[i].first == aLayer )
|
||||
return m_groups[i].second;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function getAllGroups()
|
||||
* Returns all group ids for the item (collected from all layers the item occupies).
|
||||
*
|
||||
* @return vector of group ids.
|
||||
*/
|
||||
std::vector<int> getAllGroups() const
|
||||
{
|
||||
std::vector<int> groups( m_groupsSize );
|
||||
|
||||
for( int i = 0; i < m_groupsSize; ++i )
|
||||
{
|
||||
groups[i] = m_groups[i].second;
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function setGroup()
|
||||
* Sets a group id for the item and the layer combination.
|
||||
*
|
||||
* @param aLayer is the layer numbe.
|
||||
* @param aGroup is the group id.
|
||||
*/
|
||||
void setGroup( int aLayer, int aGroup )
|
||||
{
|
||||
//printf("sgGrpSize %d l %d g %d\n", m_groupsSize, aLayer, aGroup);
|
||||
// Look if there is already an entry for the layer
|
||||
for( int i = 0; i < m_groupsSize; ++i )
|
||||
{
|
||||
if( m_groups[i].first == aLayer )
|
||||
{
|
||||
m_groups[i].second = aGroup;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If there was no entry for the given layer - create one
|
||||
GroupPair* newGroups = new GroupPair[m_groupsSize + 1];
|
||||
|
||||
if( m_groupsSize > 0 )
|
||||
{
|
||||
std::copy( m_groups, m_groups + m_groupsSize, newGroups );
|
||||
delete[] m_groups;
|
||||
}
|
||||
|
||||
m_groups = newGroups;
|
||||
newGroups[m_groupsSize++] = GroupPair( aLayer, aGroup );
|
||||
//printf("sgGrpSizeaTexit %d\n", m_groupsSize);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function deleteGroups()
|
||||
* Removes all of the stored group ids. Forces recaching of the item.
|
||||
*/
|
||||
void deleteGroups()
|
||||
{
|
||||
delete[] m_groups;
|
||||
m_groups = NULL;
|
||||
m_groupsSize = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function storesGroups()
|
||||
* Returns information if the item uses at least one group id (ie. if it is cached at all).
|
||||
*
|
||||
* @returns true in case it is cached at least for one layer.
|
||||
*/
|
||||
inline bool storesGroups() const
|
||||
{
|
||||
return m_groupsSize > 0;
|
||||
}
|
||||
|
||||
/// Stores layer numbers used by the item.
|
||||
std::bitset<VIEW::VIEW_MAX_LAYERS> m_layers;
|
||||
|
||||
/**
|
||||
* Function saveLayers()
|
||||
* Saves layers used by the item.
|
||||
*
|
||||
* @param aLayers is an array containing layer numbers to be saved.
|
||||
* @param aCount is the size of the array.
|
||||
*/
|
||||
void saveLayers( int* aLayers, int aCount )
|
||||
{
|
||||
m_layers.reset();
|
||||
|
||||
for( int i = 0; i < aCount; ++i )
|
||||
{
|
||||
// this fires on some eagle board after EAGLE_PLUGIN::Load()
|
||||
wxASSERT( unsigned( aLayers[i] ) <= unsigned( VIEW::VIEW_MAX_LAYERS ) );
|
||||
|
||||
m_layers.set( aLayers[i] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function viewRequiredUpdate()
|
||||
* Returns current update flag for an item.
|
||||
*/
|
||||
int requiredUpdate() const
|
||||
{
|
||||
return m_requiredUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function clearUpdateFlags()
|
||||
* Marks an item as already updated, so it is not going to be redrawn.
|
||||
*/
|
||||
void clearUpdateFlags()
|
||||
{
|
||||
m_requiredUpdate = NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function isRenderable()
|
||||
* Returns if the item should be drawn or not.
|
||||
*/
|
||||
bool isRenderable() const
|
||||
{
|
||||
return m_flags == VISIBLE;
|
||||
}
|
||||
};
|
||||
|
||||
void VIEW::OnDestroy ( VIEW_ITEM* aItem )
|
||||
{
|
||||
auto data = aItem->viewPrivData();
|
||||
|
||||
if(!data)
|
||||
return;
|
||||
|
||||
data->m_view->Remove( aItem );
|
||||
}
|
||||
|
||||
VIEW::VIEW( bool aIsDynamic ) :
|
||||
m_enableOrderModifier( true ),
|
||||
|
@ -91,11 +304,11 @@ void VIEW::Add( VIEW_ITEM* aItem )
|
|||
{
|
||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
aItem->saveLayers( layers, layers_count );
|
||||
aItem->m_viewPrivData = new VIEW_ITEM_DATA;
|
||||
aItem->m_viewPrivData->m_view = this;
|
||||
|
||||
if( m_dynamic )
|
||||
aItem->viewAssign( this );
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
aItem->viewPrivData()->saveLayers( layers, layers_count );
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
{
|
||||
|
@ -104,16 +317,21 @@ void VIEW::Add( VIEW_ITEM* aItem )
|
|||
MarkTargetDirty( l.target );
|
||||
}
|
||||
|
||||
aItem->ViewUpdate( VIEW_ITEM::ALL );
|
||||
SetVisible ( aItem, true );
|
||||
Update( aItem, KIGFX::ALL );
|
||||
}
|
||||
|
||||
|
||||
void VIEW::Remove( VIEW_ITEM* aItem )
|
||||
{
|
||||
if( m_dynamic )
|
||||
aItem->m_view = NULL;
|
||||
if ( !aItem )
|
||||
return;
|
||||
auto viewData = aItem->viewPrivData();
|
||||
|
||||
if( aItem->viewRequiredUpdate() != VIEW_ITEM::NONE ) // prevent from updating a removed item
|
||||
if ( !viewData )
|
||||
return;
|
||||
|
||||
if( viewData->requiredUpdate() != NONE ) // prevent from updating a removed item
|
||||
{
|
||||
std::vector<VIEW_ITEM*>::iterator item = std::find( m_needsUpdate.begin(),
|
||||
m_needsUpdate.end(), aItem );
|
||||
|
@ -121,12 +339,12 @@ void VIEW::Remove( VIEW_ITEM* aItem )
|
|||
if( item != m_needsUpdate.end() )
|
||||
{
|
||||
m_needsUpdate.erase( item );
|
||||
aItem->clearUpdateFlags();
|
||||
viewData->clearUpdateFlags();
|
||||
}
|
||||
}
|
||||
|
||||
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
||||
aItem->getLayers( layers, layers_count );
|
||||
viewData->getLayers( layers, layers_count );
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
{
|
||||
|
@ -135,13 +353,14 @@ void VIEW::Remove( VIEW_ITEM* aItem )
|
|||
MarkTargetDirty( l.target );
|
||||
|
||||
// Clear the GAL cache
|
||||
int prevGroup = aItem->getGroup( layers[i] );
|
||||
int prevGroup = viewData->getGroup( layers[i] );
|
||||
|
||||
if( prevGroup >= 0 )
|
||||
m_gal->DeleteGroup( prevGroup );
|
||||
}
|
||||
|
||||
aItem->deleteGroups();
|
||||
viewData->deleteGroups();
|
||||
aItem->m_viewPrivData = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,7 +389,7 @@ struct queryVisitor
|
|||
|
||||
bool operator()( VIEW_ITEM* aItem )
|
||||
{
|
||||
if( aItem->ViewIsVisible() )
|
||||
if( aItem->viewPrivData()->getFlags() & VISIBLE )
|
||||
m_cont.push_back( VIEW::LAYER_ITEM_PAIR( aItem, m_layer ) );
|
||||
|
||||
return true;
|
||||
|
@ -398,7 +617,7 @@ struct VIEW::updateItemsColor
|
|||
{
|
||||
// Obtain the color that should be used for coloring the item
|
||||
const COLOR4D color = painter->GetSettings()->GetColor( aItem, layer );
|
||||
int group = aItem->getGroup( layer );
|
||||
int group = aItem->viewPrivData()->getGroup( layer );
|
||||
|
||||
if( group >= 0 )
|
||||
gal->ChangeGroupColor( group, color );
|
||||
|
@ -463,7 +682,7 @@ struct VIEW::changeItemsDepth
|
|||
|
||||
bool operator()( VIEW_ITEM* aItem )
|
||||
{
|
||||
int group = aItem->getGroup( layer );
|
||||
int group = aItem->viewPrivData()->getGroup( layer );
|
||||
|
||||
if( group >= 0 )
|
||||
gal->ChangeGroupDepth( group, depth );
|
||||
|
@ -593,9 +812,11 @@ struct VIEW::drawItem
|
|||
|
||||
bool operator()( VIEW_ITEM* aItem )
|
||||
{
|
||||
|
||||
assert ( aItem->viewPrivData() );
|
||||
// Conditions that have te be fulfilled for an item to be drawn
|
||||
bool drawCondition = aItem->isRenderable() &&
|
||||
aItem->ViewGetLOD( layer ) < view->m_scale;
|
||||
bool drawCondition = aItem->viewPrivData()->isRenderable() &&
|
||||
aItem->ViewGetLOD( layer, view ) < view->m_scale;
|
||||
if( !drawCondition )
|
||||
return true;
|
||||
|
||||
|
@ -627,10 +848,12 @@ void VIEW::redrawRect( const BOX2I& aRect )
|
|||
|
||||
void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate )
|
||||
{
|
||||
auto viewData = aItem->viewPrivData();
|
||||
|
||||
if( IsCached( aLayer ) && !aImmediate )
|
||||
{
|
||||
// Draw using cached information or create one
|
||||
int group = aItem->getGroup( aLayer );
|
||||
int group = viewData->getGroup( aLayer );
|
||||
|
||||
if( group >= 0 )
|
||||
{
|
||||
|
@ -639,10 +862,10 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate )
|
|||
else
|
||||
{
|
||||
group = m_gal->BeginGroup();
|
||||
aItem->setGroup( aLayer, group );
|
||||
viewData->setGroup( aLayer, group );
|
||||
|
||||
if( !m_painter->Draw( aItem, aLayer ) )
|
||||
aItem->ViewDraw( aLayer, m_gal ); // Alternative drawing method
|
||||
aItem->ViewDraw( aLayer, this ); // Alternative drawing method
|
||||
|
||||
m_gal->EndGroup();
|
||||
}
|
||||
|
@ -651,7 +874,7 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate )
|
|||
{
|
||||
// Immediate mode
|
||||
if( !m_painter->Draw( aItem, aLayer ) )
|
||||
aItem->ViewDraw( aLayer, m_gal ); // Alternative drawing method
|
||||
aItem->ViewDraw( aLayer, this ); // Alternative drawing method
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -674,7 +897,7 @@ void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate )
|
|||
|
||||
void VIEW::draw( VIEW_GROUP* aGroup, bool aImmediate )
|
||||
{
|
||||
for ( int i = 0; i < aGroup->GetSize(); i++)
|
||||
for ( unsigned int i = 0; i < aGroup->GetSize(); i++)
|
||||
draw( aGroup->GetItem(i), aImmediate );
|
||||
}
|
||||
|
||||
|
@ -682,8 +905,8 @@ struct VIEW::unlinkItem
|
|||
{
|
||||
bool operator()( VIEW_ITEM* aItem )
|
||||
{
|
||||
aItem->m_view = NULL;
|
||||
|
||||
delete aItem->m_viewPrivData;
|
||||
aItem->m_viewPrivData = nullptr;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -698,14 +921,15 @@ struct VIEW::recacheItem
|
|||
|
||||
bool operator()( VIEW_ITEM* aItem )
|
||||
{
|
||||
auto viewData = aItem->viewPrivData();
|
||||
// Remove previously cached group
|
||||
int group = aItem->getGroup( layer );
|
||||
int group = viewData->getGroup( layer );
|
||||
|
||||
if( group >= 0 )
|
||||
gal->DeleteGroup( group );
|
||||
|
||||
aItem->setGroup( layer, -1 );
|
||||
aItem->ViewUpdate( VIEW_ITEM::ALL );
|
||||
viewData->setGroup( layer, -1 );
|
||||
view->Update( aItem );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -723,7 +947,7 @@ void VIEW::Clear()
|
|||
r.SetMaximum();
|
||||
|
||||
for( VIEW_ITEM* item : m_needsUpdate )
|
||||
item->clearUpdateFlags();
|
||||
item->viewPrivData()->clearUpdateFlags();
|
||||
|
||||
m_needsUpdate.clear();
|
||||
|
||||
|
@ -802,7 +1026,7 @@ struct VIEW::clearLayerCache
|
|||
|
||||
bool operator()( VIEW_ITEM* aItem )
|
||||
{
|
||||
aItem->deleteGroups();
|
||||
aItem->viewPrivData()->deleteGroups();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -829,14 +1053,16 @@ void VIEW::clearGroupCache()
|
|||
void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
|
||||
{
|
||||
// updateLayers updates geometry too, so we do not have to update both of them at the same time
|
||||
if( aUpdateFlags & VIEW_ITEM::LAYERS )
|
||||
if( aUpdateFlags & LAYERS )
|
||||
updateLayers( aItem );
|
||||
else if( aUpdateFlags & VIEW_ITEM::GEOMETRY )
|
||||
else if( aUpdateFlags & GEOMETRY )
|
||||
updateBbox( aItem );
|
||||
|
||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
|
||||
printf("invlidate %p", aItem);
|
||||
|
||||
// Iterate through layers used by the item and recache it immediately
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
{
|
||||
|
@ -844,9 +1070,10 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
|
|||
|
||||
if( IsCached( layerId ) )
|
||||
{
|
||||
if( aUpdateFlags & ( VIEW_ITEM::GEOMETRY | VIEW_ITEM::LAYERS ) )
|
||||
printf("updateGeom %p flg %d\n", aItem, aUpdateFlags );
|
||||
if( aUpdateFlags & ( GEOMETRY | LAYERS ) )
|
||||
updateItemGeometry( aItem, layerId );
|
||||
else if( aUpdateFlags & VIEW_ITEM::COLOR )
|
||||
else if( aUpdateFlags & COLOR )
|
||||
updateItemColor( aItem, layerId );
|
||||
}
|
||||
|
||||
|
@ -854,7 +1081,7 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
|
|||
MarkTargetDirty( m_layers[layerId].target );
|
||||
}
|
||||
|
||||
aItem->clearUpdateFlags();
|
||||
aItem->viewPrivData()->clearUpdateFlags();
|
||||
}
|
||||
|
||||
|
||||
|
@ -875,12 +1102,13 @@ void VIEW::sortLayers()
|
|||
|
||||
void VIEW::updateItemColor( VIEW_ITEM* aItem, int aLayer )
|
||||
{
|
||||
auto viewData = aItem->viewPrivData();
|
||||
wxASSERT( (unsigned) aLayer < m_layers.size() );
|
||||
wxASSERT( IsCached( aLayer ) );
|
||||
|
||||
// Obtain the color that should be used for coloring the item on the specific layerId
|
||||
const COLOR4D color = m_painter->GetSettings()->GetColor( aItem, aLayer );
|
||||
int group = aItem->getGroup( aLayer );
|
||||
int group = viewData->getGroup( aLayer );
|
||||
|
||||
// Change the color, only if it has group assigned
|
||||
if( group >= 0 )
|
||||
|
@ -890,6 +1118,7 @@ void VIEW::updateItemColor( VIEW_ITEM* aItem, int aLayer )
|
|||
|
||||
void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
|
||||
{
|
||||
auto viewData = aItem->viewPrivData();
|
||||
wxASSERT( (unsigned) aLayer < m_layers.size() );
|
||||
wxASSERT( IsCached( aLayer ) );
|
||||
|
||||
|
@ -899,16 +1128,18 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
|
|||
m_gal->SetLayerDepth( l.renderingOrder );
|
||||
|
||||
// Redraw the item from scratch
|
||||
int group = aItem->getGroup( aLayer );
|
||||
int group = viewData->getGroup( aLayer );
|
||||
|
||||
if( group >= 0 )
|
||||
m_gal->DeleteGroup( group );
|
||||
|
||||
group = m_gal->BeginGroup();
|
||||
aItem->setGroup( aLayer, group );
|
||||
viewData->setGroup( aLayer, group );
|
||||
|
||||
printf("upadteGeom2: %p\n", aItem );
|
||||
|
||||
if( !m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), aLayer ) )
|
||||
aItem->ViewDraw( aLayer, m_gal ); // Alternative drawing method
|
||||
aItem->ViewDraw( aLayer, this ); // Alternative drawing method
|
||||
|
||||
m_gal->EndGroup();
|
||||
}
|
||||
|
@ -932,10 +1163,11 @@ void VIEW::updateBbox( VIEW_ITEM* aItem )
|
|||
|
||||
void VIEW::updateLayers( VIEW_ITEM* aItem )
|
||||
{
|
||||
auto viewData = aItem->viewPrivData();
|
||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||
|
||||
// Remove the item from previous layer set
|
||||
aItem->getLayers( layers, layers_count );
|
||||
viewData->getLayers( layers, layers_count );
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
{
|
||||
|
@ -946,19 +1178,19 @@ void VIEW::updateLayers( VIEW_ITEM* aItem )
|
|||
if( IsCached( l.id ) )
|
||||
{
|
||||
// Redraw the item from scratch
|
||||
int prevGroup = aItem->getGroup( layers[i] );
|
||||
int prevGroup = viewData->getGroup( layers[i] );
|
||||
|
||||
if( prevGroup >= 0 )
|
||||
{
|
||||
m_gal->DeleteGroup( prevGroup );
|
||||
aItem->setGroup( l.id, -1 );
|
||||
viewData->setGroup( l.id, -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the item to new layer set
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
aItem->saveLayers( layers, layers_count );
|
||||
viewData->saveLayers( layers, layers_count );
|
||||
|
||||
for( int i = 0; i < layers_count; i++ )
|
||||
{
|
||||
|
@ -1012,9 +1244,10 @@ void VIEW::UpdateItems()
|
|||
|
||||
for( VIEW_ITEM* item : m_needsUpdate )
|
||||
{
|
||||
assert( item->viewRequiredUpdate() != VIEW_ITEM::NONE );
|
||||
auto viewData = item->viewPrivData();
|
||||
assert( viewData->m_requiredUpdate != NONE );
|
||||
|
||||
invalidateItem( item, item->viewRequiredUpdate() );
|
||||
invalidateItem( item, viewData->m_requiredUpdate );
|
||||
}
|
||||
|
||||
m_gal->EndUpdate();
|
||||
|
@ -1058,4 +1291,87 @@ const BOX2I VIEW::CalculateExtents()
|
|||
}
|
||||
|
||||
|
||||
void VIEW::SetVisible( VIEW_ITEM *aItem, bool aIsVisible )
|
||||
{
|
||||
auto viewData = aItem->viewPrivData();
|
||||
|
||||
assert( viewData );
|
||||
|
||||
bool cur_visible = viewData->m_flags & VISIBLE;
|
||||
|
||||
if( cur_visible != aIsVisible )
|
||||
{
|
||||
if( aIsVisible )
|
||||
viewData->m_flags |= VISIBLE;
|
||||
else
|
||||
viewData->m_flags &= ~VISIBLE;
|
||||
|
||||
Update( aItem, APPEARANCE | COLOR );
|
||||
}
|
||||
}
|
||||
|
||||
void VIEW::Hide( VIEW_ITEM *aItem, bool aHide )
|
||||
{
|
||||
auto viewData = aItem->viewPrivData();
|
||||
|
||||
if( !( viewData->m_flags & VISIBLE ) )
|
||||
return;
|
||||
|
||||
if( aHide )
|
||||
viewData->m_flags |= HIDDEN;
|
||||
else
|
||||
viewData->m_flags &= ~HIDDEN;
|
||||
|
||||
Update( aItem, APPEARANCE );
|
||||
}
|
||||
|
||||
bool VIEW::IsVisible( const VIEW_ITEM *aItem ) const
|
||||
{
|
||||
const auto viewData = aItem->viewPrivData();
|
||||
|
||||
return viewData->m_flags & VISIBLE;
|
||||
}
|
||||
|
||||
void VIEW::Update( VIEW_ITEM *aItem )
|
||||
{
|
||||
Update( aItem, ALL );
|
||||
}
|
||||
|
||||
void VIEW::Update( VIEW_ITEM *aItem, int aUpdateFlags )
|
||||
{
|
||||
auto viewData = aItem->viewPrivData();
|
||||
|
||||
if ( !viewData )
|
||||
return;
|
||||
|
||||
assert( aUpdateFlags != NONE );
|
||||
bool firstTime = (viewData->m_requiredUpdate == NONE);
|
||||
|
||||
viewData->m_requiredUpdate |= aUpdateFlags;
|
||||
|
||||
if( firstTime )
|
||||
{
|
||||
MarkForUpdate( aItem );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void VIEW::MarkForUpdate( VIEW_ITEM* aItem )
|
||||
{
|
||||
auto viewData = aItem->viewPrivData();
|
||||
|
||||
printf("MarkForUpdate %p\n", aItem);
|
||||
|
||||
assert( viewData->m_requiredUpdate != NONE );
|
||||
|
||||
for ( auto item : m_needsUpdate )
|
||||
assert(item != aItem);
|
||||
|
||||
m_needsUpdate.push_back( aItem );
|
||||
}
|
||||
|
||||
const int VIEW::TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -41,14 +41,17 @@
|
|||
using namespace KIGFX;
|
||||
|
||||
VIEW_GROUP::VIEW_GROUP( VIEW* aView ) :
|
||||
m_layer( ITEM_GAL_LAYER( GP_OVERLAY ) )
|
||||
m_layer( ITEM_GAL_LAYER( GP_OVERLAY ) ),
|
||||
m_view ( aView )
|
||||
{
|
||||
m_view = aView;
|
||||
|
||||
}
|
||||
|
||||
|
||||
VIEW_GROUP::~VIEW_GROUP()
|
||||
{
|
||||
if (m_view && viewPrivData() )
|
||||
m_view->Remove ( this );
|
||||
|
||||
}
|
||||
|
||||
|
@ -56,7 +59,6 @@ VIEW_GROUP::~VIEW_GROUP()
|
|||
void VIEW_GROUP::Add( VIEW_ITEM* aItem )
|
||||
{
|
||||
m_groupItems.push_back( aItem );
|
||||
ViewUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,15 +72,12 @@ void VIEW_GROUP::Remove( VIEW_ITEM* aItem )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ViewUpdate();
|
||||
}
|
||||
|
||||
|
||||
void VIEW_GROUP::Clear()
|
||||
{
|
||||
m_groupItems.clear();
|
||||
ViewUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,33 +100,34 @@ const BOX2I VIEW_GROUP::ViewBBox() const
|
|||
}
|
||||
|
||||
|
||||
void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal ) const
|
||||
void VIEW_GROUP::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
{
|
||||
PAINTER* painter = m_view->GetPainter();
|
||||
auto gal = aView->GetGAL();
|
||||
PAINTER* painter = aView->GetPainter();
|
||||
|
||||
const auto drawList = updateDrawList();
|
||||
|
||||
// Draw all items immediately (without caching)
|
||||
for ( auto item : drawList )
|
||||
{
|
||||
aGal->PushDepth();
|
||||
gal->PushDepth();
|
||||
|
||||
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
||||
item->ViewGetLayers( layers, layers_count );
|
||||
m_view->SortLayers( layers, layers_count );
|
||||
aView->SortLayers( layers, layers_count );
|
||||
|
||||
for( int i = 0; i < layers_count; i++ )
|
||||
{
|
||||
if( m_view->IsCached( layers[i] ) && m_view->IsLayerVisible( layers[i] ) )
|
||||
if( aView->IsCached( layers[i] ) && aView->IsLayerVisible( layers[i] ) )
|
||||
{
|
||||
aGal->AdvanceDepth();
|
||||
gal->AdvanceDepth();
|
||||
|
||||
if( !painter->Draw( item, layers[i] ) )
|
||||
item->ViewDraw( layers[i], aGal ); // Alternative drawing method
|
||||
item->ViewDraw( layers[i], aView ); // Alternative drawing method
|
||||
}
|
||||
}
|
||||
|
||||
aGal->PopDepth();
|
||||
gal->PopDepth();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,10 +172,5 @@ void VIEW_GROUP::ItemsViewUpdate( VIEW_ITEM::VIEW_UPDATE_FLAGS aFlags )
|
|||
|
||||
void VIEW_GROUP::updateBbox()
|
||||
{
|
||||
// Save the used VIEW, as it used nulled during Remove()
|
||||
VIEW* view = m_view;
|
||||
|
||||
// Reinsert the group, so the bounding box can be updated
|
||||
view->Remove( this );
|
||||
view->Add( this );
|
||||
|
||||
}
|
||||
|
|
|
@ -29,81 +29,8 @@
|
|||
|
||||
using namespace KIGFX;
|
||||
|
||||
void VIEW_ITEM::ViewRelease()
|
||||
VIEW_ITEM::~VIEW_ITEM()
|
||||
{
|
||||
if( m_view && m_view->IsDynamic() )
|
||||
m_view->Remove( this );
|
||||
}
|
||||
|
||||
|
||||
void VIEW_ITEM::getLayers( int* aLayers, int& aCount ) const
|
||||
{
|
||||
int* layersPtr = aLayers;
|
||||
|
||||
for( unsigned int i = 0; i < m_layers.size(); ++i )
|
||||
{
|
||||
if( m_layers[i] )
|
||||
*layersPtr++ = i;
|
||||
}
|
||||
|
||||
aCount = m_layers.count();
|
||||
}
|
||||
|
||||
|
||||
int VIEW_ITEM::getGroup( int aLayer ) const
|
||||
{
|
||||
for( int i = 0; i < m_groupsSize; ++i )
|
||||
{
|
||||
if( m_groups[i].first == aLayer )
|
||||
return m_groups[i].second;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
std::vector<int> VIEW_ITEM::getAllGroups() const
|
||||
{
|
||||
std::vector<int> groups( m_groupsSize );
|
||||
|
||||
for( int i = 0; i < m_groupsSize; ++i )
|
||||
{
|
||||
groups[i] = m_groups[i].second;
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
||||
void VIEW_ITEM::setGroup( int aLayer, int aId )
|
||||
{
|
||||
// Look if there is already an entry for the layer
|
||||
for( int i = 0; i < m_groupsSize; ++i )
|
||||
{
|
||||
if( m_groups[i].first == aLayer )
|
||||
{
|
||||
m_groups[i].second = aId;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If there was no entry for the given layer - create one
|
||||
GroupPair* newGroups = new GroupPair[m_groupsSize + 1];
|
||||
|
||||
if( m_groupsSize > 0 )
|
||||
{
|
||||
std::copy( m_groups, m_groups + m_groupsSize, newGroups );
|
||||
delete[] m_groups;
|
||||
}
|
||||
|
||||
m_groups = newGroups;
|
||||
newGroups[m_groupsSize++] = GroupPair( aLayer, aId );
|
||||
}
|
||||
|
||||
|
||||
void VIEW_ITEM::deleteGroups()
|
||||
{
|
||||
delete[] m_groups;
|
||||
m_groups = NULL;
|
||||
m_groupsSize = 0;
|
||||
VIEW::OnDestroy( this );
|
||||
m_viewPrivData = nullptr;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <painter.h>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
#include <class_page_info.h>
|
||||
#include <view/view.h>
|
||||
|
||||
using namespace KIGFX;
|
||||
|
||||
|
@ -44,14 +45,12 @@ WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const PAGE_INFO* aPageInfo, const TITLE_
|
|||
void WORKSHEET_VIEWITEM::SetPageInfo( const PAGE_INFO* aPageInfo )
|
||||
{
|
||||
m_pageInfo = aPageInfo;
|
||||
ViewUpdate( GEOMETRY );
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_VIEWITEM::SetTitleBlock( const TITLE_BLOCK* aTitleBlock )
|
||||
{
|
||||
m_titleBlock = aTitleBlock;
|
||||
ViewUpdate( GEOMETRY );
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,9 +73,10 @@ const BOX2I WORKSHEET_VIEWITEM::ViewBBox() const
|
|||
}
|
||||
|
||||
|
||||
void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const
|
||||
void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
{
|
||||
RENDER_SETTINGS* settings = m_view->GetPainter()->GetSettings();
|
||||
auto gal = aView->GetGAL();
|
||||
auto settings = aView->GetPainter()->GetSettings();
|
||||
wxString fileName( m_fileName.c_str(), wxConvUTF8 );
|
||||
wxString sheetName( m_sheetName.c_str(), wxConvUTF8 );
|
||||
WS_DRAW_ITEM_LIST drawList;
|
||||
|
@ -102,19 +102,19 @@ void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const
|
|||
switch( item->GetType() )
|
||||
{
|
||||
case WS_DRAW_ITEM_BASE::wsg_line:
|
||||
draw( static_cast<const WS_DRAW_ITEM_LINE*>( item ), aGal );
|
||||
draw( static_cast<const WS_DRAW_ITEM_LINE*>( item ), gal );
|
||||
break;
|
||||
|
||||
case WS_DRAW_ITEM_BASE::wsg_rect:
|
||||
draw( static_cast<const WS_DRAW_ITEM_RECT*>( item ), aGal );
|
||||
draw( static_cast<const WS_DRAW_ITEM_RECT*>( item ), gal );
|
||||
break;
|
||||
|
||||
case WS_DRAW_ITEM_BASE::wsg_poly:
|
||||
draw( static_cast<const WS_DRAW_ITEM_POLYGON*>( item ), aGal );
|
||||
draw( static_cast<const WS_DRAW_ITEM_POLYGON*>( item ), gal );
|
||||
break;
|
||||
|
||||
case WS_DRAW_ITEM_BASE::wsg_text:
|
||||
draw( static_cast<const WS_DRAW_ITEM_TEXT*>( item ), aGal );
|
||||
draw( static_cast<const WS_DRAW_ITEM_TEXT*>( item ), gal );
|
||||
break;
|
||||
|
||||
case WS_DRAW_ITEM_BASE::wsg_bitmap:
|
||||
|
@ -125,7 +125,7 @@ void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const
|
|||
}
|
||||
|
||||
// Draw gray line that outlines the sheet size
|
||||
drawBorder( aGal );
|
||||
drawBorder( gal );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -229,12 +229,12 @@ public:
|
|||
inline bool IsBrightened() const { return m_Flags & BRIGHTENED; }
|
||||
|
||||
inline void SetWireImage() { SetFlags( IS_WIRE_IMAGE ); }
|
||||
inline void SetSelected() { SetFlags( SELECTED ); ViewUpdate( COLOR ); }
|
||||
inline void SetHighlighted() { SetFlags( HIGHLIGHTED ); ViewUpdate( COLOR ); }
|
||||
inline void SetSelected() { SetFlags( SELECTED ); }
|
||||
inline void SetHighlighted() { SetFlags( HIGHLIGHTED ); }
|
||||
inline void SetBrightened() { SetFlags( BRIGHTENED ); }
|
||||
|
||||
inline void ClearSelected() { ClearFlags( SELECTED ); ViewUpdate( COLOR ); }
|
||||
inline void ClearHighlighted() { ClearFlags( HIGHLIGHTED ); ViewUpdate( COLOR ); }
|
||||
inline void ClearSelected() { ClearFlags( SELECTED ); }
|
||||
inline void ClearHighlighted() { ClearFlags( HIGHLIGHTED ); }
|
||||
inline void ClearBrightened() { ClearFlags( BRIGHTENED ); }
|
||||
|
||||
void SetModified();
|
||||
|
|
|
@ -50,9 +50,9 @@ public:
|
|||
|
||||
const BOX2I ViewBBox() const override;
|
||||
|
||||
void ViewDraw( int aLayer, KIGFX::GAL* aGal ) const override;
|
||||
void ViewDraw( int aLayer, VIEW* aView ) const override;
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) constm override
|
||||
{
|
||||
aLayers[0] = ITEM_GAL_LAYER( GP_OVERLAY );
|
||||
aCount = 1;
|
||||
|
@ -86,7 +86,6 @@ public:
|
|||
inline void SetPosition( const VECTOR2D& aPosition )
|
||||
{
|
||||
m_position = aPosition;
|
||||
ViewUpdate();
|
||||
}
|
||||
|
||||
inline const VECTOR2D& GetPosition() const
|
||||
|
|
|
@ -70,6 +70,13 @@ public:
|
|||
|
||||
~VIEW();
|
||||
|
||||
// nasty hack, invoked by the destructor of VIEW_ITEM to auto-remove the item
|
||||
// from the owning VIEW if there is any. Kicad relies too much on this mechanism.
|
||||
// this is the only linking dependency now between EDA_ITEM and VIEW class. In near future
|
||||
// I'll replace it with observers.
|
||||
static void OnDestroy ( VIEW_ITEM* aItem );
|
||||
|
||||
|
||||
/**
|
||||
* Function Add()
|
||||
* Adds a VIEW_ITEM to the view.
|
||||
|
@ -84,6 +91,7 @@ public:
|
|||
*/
|
||||
void Remove( VIEW_ITEM* aItem );
|
||||
|
||||
|
||||
/**
|
||||
* Function Query()
|
||||
* Finds all visible items that touch or are within the rectangle aRect.
|
||||
|
@ -95,6 +103,41 @@ public:
|
|||
*/
|
||||
int Query( const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult ) const;
|
||||
|
||||
/**
|
||||
* Function SetVisible()
|
||||
* Sets the item visibility.
|
||||
*
|
||||
* @param aIsVisible: whether the item is visible (on all layers), or not.
|
||||
*/
|
||||
void SetVisible( VIEW_ITEM *aItem, bool aIsVisible = true );
|
||||
|
||||
/**
|
||||
* Function Hide()
|
||||
* Temporarily hides the item in the view (e.g. for overlaying)
|
||||
*
|
||||
* @param aHide: whether the item is hidden (on all layers), or not.
|
||||
*/
|
||||
void Hide( VIEW_ITEM *aItem, bool aHide = true );
|
||||
|
||||
/**
|
||||
* Function IsVisible()
|
||||
* Returns information if the item is visible (or not).
|
||||
*
|
||||
* @return when true, the item is visible (i.e. to be displayed, not visible in the
|
||||
* *current* viewport)
|
||||
*/
|
||||
bool IsVisible( const VIEW_ITEM *aItem ) const;
|
||||
|
||||
/**
|
||||
* Function ViewUpdate()
|
||||
* For dynamic VIEWs, informs the associated VIEW that the graphical representation of
|
||||
* this item has changed. For static views calling has no effect.
|
||||
*
|
||||
* @param aUpdateFlags: how much the object has changed.
|
||||
*/
|
||||
void Update( VIEW_ITEM *aItem );
|
||||
void Update( VIEW_ITEM *aItem, int aUpdateFlags );
|
||||
|
||||
/**
|
||||
* Function SetRequired()
|
||||
* Marks the aRequiredId layer as required for the aLayerId layer. In order to display the
|
||||
|
@ -547,10 +590,7 @@ public:
|
|||
* Adds an item to a list of items that are going to be refreshed upon the next frame rendering.
|
||||
* @param aItem is the item to be refreshed.
|
||||
*/
|
||||
void MarkForUpdate( VIEW_ITEM* aItem )
|
||||
{
|
||||
m_needsUpdate.push_back( aItem );
|
||||
}
|
||||
void MarkForUpdate( VIEW_ITEM* aItem );
|
||||
|
||||
/**
|
||||
* Function UpdateItems()
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
namespace KIGFX
|
||||
{
|
||||
|
||||
class VIEW_GROUP : public VIEW_ITEM
|
||||
{
|
||||
protected:
|
||||
|
@ -95,7 +96,7 @@ public:
|
|||
* @param aLayer is the layer which should be drawn.
|
||||
* @param aGal is the GAL that should be used for drawing.
|
||||
*/
|
||||
virtual void ViewDraw( int aLayer, GAL* aGal ) const override;
|
||||
virtual void ViewDraw( int aLayer, VIEW* aView ) const override;
|
||||
|
||||
/**
|
||||
* Function ViewGetLayers()
|
||||
|
@ -115,7 +116,6 @@ public:
|
|||
inline virtual void SetLayer( int aLayer )
|
||||
{
|
||||
m_layer = aLayer;
|
||||
ViewUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,61 +124,10 @@ public:
|
|||
*/
|
||||
void FreeItems();
|
||||
|
||||
/**
|
||||
* Function GetView()
|
||||
* Returns pointer to the VIEW instance used by items.
|
||||
*
|
||||
* @return Pointer to the VIEW instance.
|
||||
*/
|
||||
KIGFX::VIEW* GetView() const
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ItemsSetVisibility()
|
||||
* Sets visibility of items stored in the VIEW_GROUP.
|
||||
*
|
||||
* @param aVisible decides if items should be visible or not.
|
||||
*/
|
||||
//virtual void ItemsSetVisibility( bool aVisible );
|
||||
|
||||
/**
|
||||
* Function ItemsViewUpdate()
|
||||
* Updates items stored in the VIEW_GROUP.
|
||||
*
|
||||
* @param aFlags determines the way in which items will be updated.
|
||||
*/
|
||||
//virtual void ItemsViewUpdate( VIEW_ITEM::VIEW_UPDATE_FLAGS aFlags );
|
||||
|
||||
protected:
|
||||
|
||||
virtual const ITEMS updateDrawList() const;
|
||||
|
||||
/// These functions cannot be used with VIEW_GROUP as they are intended only to work with
|
||||
/// singular VIEW_ITEMs (there is only one-to-one relation between item/layer combination and
|
||||
/// its group).
|
||||
int getGroup( int aLayer ) const override
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::vector<int> getAllGroups() const override
|
||||
{
|
||||
return std::vector<int>();
|
||||
}
|
||||
|
||||
void setGroup( int aLayer, int aGroup ) override
|
||||
{}
|
||||
|
||||
void deleteGroups() override
|
||||
{}
|
||||
|
||||
bool storesGroups() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Layer on which the group is drawn
|
||||
int m_layer;
|
||||
|
||||
|
@ -189,6 +138,8 @@ protected:
|
|||
private:
|
||||
void updateBbox();
|
||||
|
||||
VIEW *m_view;
|
||||
|
||||
};
|
||||
|
||||
} // namespace KIGFX
|
||||
|
|
|
@ -33,15 +33,40 @@
|
|||
#include <vector>
|
||||
#include <bitset>
|
||||
#include <math/box2.h>
|
||||
#include <view/view.h>
|
||||
#include <gal/definitions.h>
|
||||
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
// Forward declarations
|
||||
class GAL;
|
||||
class PAINTER;
|
||||
class VIEW;
|
||||
class VIEW_ITEM_DATA;
|
||||
|
||||
/**
|
||||
* Enum VIEW_UPDATE_FLAGS.
|
||||
* Defines the how severely the shape/appearance of the item has been changed:
|
||||
* - NONE: TODO
|
||||
* - APPEARANCE: shape or layer set of the item have not been affected,
|
||||
* only colors or visibility.
|
||||
* - COLOR:
|
||||
* - GEOMETRY: shape or layer set of the item have changed, VIEW may need to reindex it.
|
||||
* - LAYERS: TODO
|
||||
* - ALL: all the flags above */
|
||||
enum VIEW_UPDATE_FLAGS {
|
||||
NONE = 0x00, /// No updates are required
|
||||
APPEARANCE = 0x01, /// Visibility flag has changed
|
||||
COLOR = 0x02, /// Color has changed
|
||||
GEOMETRY = 0x04, /// Position or shape has changed
|
||||
LAYERS = 0x08, /// Layers have changed
|
||||
ALL = 0xff
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum VIEW_VISIBILITY_FLAGS.
|
||||
* Defines the visibility of the item (temporarily hidden, invisible, etc).
|
||||
*/
|
||||
enum VIEW_VISIBILITY_FLAGS {
|
||||
VISIBLE = 0x01, /// Item is visible (in general)
|
||||
HIDDEN = 0x02 /// Item is temporarily hidden (e.g. being used by a tool). Overrides VISIBLE flag.
|
||||
};
|
||||
|
||||
/**
|
||||
* Class VIEW_ITEM -
|
||||
|
@ -53,50 +78,17 @@ class PAINTER;
|
|||
* VIEW_ITEM objects are never owned by a VIEW. A single VIEW_ITEM can belong to any number of
|
||||
* static VIEWs, but only one dynamic VIEW due to storage of only one VIEW reference.
|
||||
*/
|
||||
|
||||
class VIEW_ITEM
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Enum VIEW_UPDATE_FLAGS.
|
||||
* Defines the how severely the shape/appearance of the item has been changed:
|
||||
* - NONE: TODO
|
||||
* - APPEARANCE: shape or layer set of the item have not been affected,
|
||||
* only colors or visibility.
|
||||
* - COLOR:
|
||||
* - GEOMETRY: shape or layer set of the item have changed, VIEW may need to reindex it.
|
||||
* - LAYERS: TODO
|
||||
* - ALL: all the flags above */
|
||||
|
||||
enum VIEW_UPDATE_FLAGS {
|
||||
NONE = 0x00, /// No updates are required
|
||||
APPEARANCE = 0x01, /// Visibility flag has changed
|
||||
COLOR = 0x02, /// Color has changed
|
||||
GEOMETRY = 0x04, /// Position or shape has changed
|
||||
LAYERS = 0x08, /// Layers have changed
|
||||
ALL = 0xff
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum VIEW_VISIBILITY_FLAGS.
|
||||
* Defines the visibility of the item (temporarily hidden, invisible, etc).
|
||||
*/
|
||||
enum VIEW_VISIBILITY_FLAGS {
|
||||
VISIBLE = 0x01, /// Item is visible (in general)
|
||||
HIDDEN = 0x02 /// Item is temporarily hidden (e.g. being used by a tool). Overrides VISIBLE flag.
|
||||
};
|
||||
|
||||
VIEW_ITEM() : m_view( NULL ), m_flags( VISIBLE ), m_requiredUpdate( NONE ),
|
||||
m_groups( NULL ), m_groupsSize( 0 ) {}
|
||||
|
||||
/**
|
||||
* Destructor. For dynamic views, removes the item from the view.
|
||||
*/
|
||||
virtual ~VIEW_ITEM()
|
||||
VIEW_ITEM() : m_viewPrivData( nullptr )
|
||||
{
|
||||
ViewRelease();
|
||||
delete[] m_groups;
|
||||
|
||||
}
|
||||
|
||||
virtual ~VIEW_ITEM();
|
||||
|
||||
/**
|
||||
* Function ViewBBox()
|
||||
* returns the bounding box of the item covering all its layers.
|
||||
|
@ -117,7 +109,7 @@ public:
|
|||
* @param aLayer: current drawing layer
|
||||
* @param aGal: pointer to the GAL device we are drawing on
|
||||
*/
|
||||
virtual void ViewDraw( int aLayer, GAL* aGal ) const
|
||||
virtual void ViewDraw( int aLayer, VIEW* aView ) const
|
||||
{}
|
||||
|
||||
/**
|
||||
|
@ -131,226 +123,32 @@ public:
|
|||
*/
|
||||
virtual void ViewGetLayers( int aLayers[], int& aCount ) const = 0;
|
||||
|
||||
/**
|
||||
* Function ViewSetVisible()
|
||||
* Sets the item visibility.
|
||||
*
|
||||
* @param aIsVisible: whether the item is visible (on all layers), or not.
|
||||
*/
|
||||
void ViewSetVisible( bool aIsVisible = true )
|
||||
{
|
||||
bool cur_visible = m_flags & VISIBLE;
|
||||
|
||||
if( cur_visible != aIsVisible )
|
||||
{
|
||||
if( aIsVisible )
|
||||
m_flags |= VISIBLE;
|
||||
else
|
||||
m_flags &= ~VISIBLE;
|
||||
|
||||
ViewUpdate( APPEARANCE | COLOR );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ViewHide()
|
||||
* Temporarily hides the item in the view (e.g. for overlaying)
|
||||
*
|
||||
* @param aHide: whether the item is hidden (on all layers), or not.
|
||||
*/
|
||||
void ViewHide( bool aHide = true )
|
||||
{
|
||||
if( !( m_flags & VISIBLE ) )
|
||||
return;
|
||||
|
||||
if( aHide )
|
||||
m_flags |= HIDDEN;
|
||||
else
|
||||
m_flags &= ~HIDDEN;
|
||||
|
||||
ViewUpdate( APPEARANCE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ViewIsVisible()
|
||||
* Returns information if the item is visible (or not).
|
||||
*
|
||||
* @return when true, the item is visible (i.e. to be displayed, not visible in the
|
||||
* *current* viewport)
|
||||
*/
|
||||
bool ViewIsVisible() const
|
||||
{
|
||||
return m_flags & VISIBLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ViewGetLOD()
|
||||
* Returns the level of detail of the item. A level of detail is the minimal VIEW scale that
|
||||
* is sufficient for an item to be shown on a given layer.
|
||||
*/
|
||||
virtual unsigned int ViewGetLOD( int aLayer ) const
|
||||
virtual unsigned int ViewGetLOD( int aLayer, VIEW* aView ) const
|
||||
{
|
||||
// By default always show the item
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ViewUpdate()
|
||||
* For dynamic VIEWs, informs the associated VIEW that the graphical representation of
|
||||
* this item has changed. For static views calling has no effect.
|
||||
*
|
||||
* @param aUpdateFlags: how much the object has changed.
|
||||
*/
|
||||
virtual void ViewUpdate( int aUpdateFlags = ALL )
|
||||
|
||||
|
||||
public:
|
||||
|
||||
VIEW_ITEM_DATA* viewPrivData() const
|
||||
{
|
||||
if( m_view )
|
||||
{
|
||||
assert( aUpdateFlags != NONE );
|
||||
|
||||
if( m_requiredUpdate == NONE )
|
||||
m_view->MarkForUpdate( this );
|
||||
|
||||
m_requiredUpdate |= aUpdateFlags;
|
||||
}
|
||||
return m_viewPrivData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ViewRelease()
|
||||
* Releases the item from an associated dynamic VIEW. For static views calling has no effect.
|
||||
*/
|
||||
virtual void ViewRelease();
|
||||
|
||||
protected:
|
||||
private:
|
||||
friend class VIEW;
|
||||
|
||||
/**
|
||||
* Function getLayers()
|
||||
* Returns layer numbers used by the item.
|
||||
*
|
||||
* @param aLayers[]: output layer index array
|
||||
* @param aCount: number of layer indices in aLayers[]
|
||||
*/
|
||||
virtual void getLayers( int* aLayers, int& aCount ) const;
|
||||
|
||||
/**
|
||||
* Function viewAssign()
|
||||
* Assigns the item to a given dynamic VIEW. Called internally by the VIEW.
|
||||
*
|
||||
* @param aView[]: dynamic VIEW instance the item is being added to.
|
||||
*/
|
||||
virtual void viewAssign( VIEW* aView )
|
||||
{
|
||||
// release the item from a previously assigned dynamic view (if there is any)
|
||||
ViewRelease();
|
||||
m_view = aView;
|
||||
deleteGroups();
|
||||
}
|
||||
|
||||
VIEW* m_view; ///< Current dynamic view the item is assigned to.
|
||||
int m_flags; ///< Visibility flags
|
||||
int m_requiredUpdate; ///< Flag required for updating
|
||||
|
||||
///* Helper for storing cached items group ids
|
||||
typedef std::pair<int, int> GroupPair;
|
||||
|
||||
///* Indexes of cached GAL display lists corresponding to the item (for every layer it occupies).
|
||||
///* (in the std::pair "first" stores layer number, "second" stores group id).
|
||||
GroupPair* m_groups;
|
||||
int m_groupsSize;
|
||||
|
||||
/**
|
||||
* Function getGroup()
|
||||
* Returns number of the group id for the given layer, or -1 in case it was not cached before.
|
||||
*
|
||||
* @param aLayer is the layer number for which group id is queried.
|
||||
* @return group id or -1 in case there is no group id (ie. item is not cached).
|
||||
*/
|
||||
virtual int getGroup( int aLayer ) const;
|
||||
|
||||
/**
|
||||
* Function getAllGroups()
|
||||
* Returns all group ids for the item (collected from all layers the item occupies).
|
||||
*
|
||||
* @return vector of group ids.
|
||||
*/
|
||||
virtual std::vector<int> getAllGroups() const;
|
||||
|
||||
/**
|
||||
* Function setGroup()
|
||||
* Sets a group id for the item and the layer combination.
|
||||
*
|
||||
* @param aLayer is the layer numbe.
|
||||
* @param aGroup is the group id.
|
||||
*/
|
||||
virtual void setGroup( int aLayer, int aGroup );
|
||||
|
||||
/**
|
||||
* Function deleteGroups()
|
||||
* Removes all of the stored group ids. Forces recaching of the item.
|
||||
*/
|
||||
virtual void deleteGroups();
|
||||
|
||||
/**
|
||||
* Function storesGroups()
|
||||
* Returns information if the item uses at least one group id (ie. if it is cached at all).
|
||||
*
|
||||
* @returns true in case it is cached at least for one layer.
|
||||
*/
|
||||
inline virtual bool storesGroups() const
|
||||
{
|
||||
return m_groupsSize > 0;
|
||||
}
|
||||
|
||||
/// Stores layer numbers used by the item.
|
||||
std::bitset<VIEW::VIEW_MAX_LAYERS> m_layers;
|
||||
|
||||
/**
|
||||
* Function saveLayers()
|
||||
* Saves layers used by the item.
|
||||
*
|
||||
* @param aLayers is an array containing layer numbers to be saved.
|
||||
* @param aCount is the size of the array.
|
||||
*/
|
||||
virtual void saveLayers( int* aLayers, int aCount )
|
||||
{
|
||||
m_layers.reset();
|
||||
|
||||
for( int i = 0; i < aCount; ++i )
|
||||
{
|
||||
// this fires on some eagle board after EAGLE_PLUGIN::Load()
|
||||
wxASSERT( unsigned( aLayers[i] ) <= unsigned( VIEW::VIEW_MAX_LAYERS ) );
|
||||
|
||||
m_layers.set( aLayers[i] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function viewRequiredUpdate()
|
||||
* Returns current update flag for an item.
|
||||
*/
|
||||
virtual int viewRequiredUpdate() const
|
||||
{
|
||||
return m_requiredUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function clearUpdateFlags()
|
||||
* Marks an item as already updated, so it is not going to be redrawn.
|
||||
*/
|
||||
void clearUpdateFlags()
|
||||
{
|
||||
m_requiredUpdate = NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function isRenderable()
|
||||
* Returns if the item should be drawn or not.
|
||||
*/
|
||||
bool isRenderable() const
|
||||
{
|
||||
return m_flags == VISIBLE;
|
||||
}
|
||||
VIEW_ITEM_DATA *m_viewPrivData;
|
||||
};
|
||||
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,6 +42,7 @@ class WS_DRAW_ITEM_TEXT;
|
|||
|
||||
namespace KIGFX
|
||||
{
|
||||
class VIEW;
|
||||
class GAL;
|
||||
|
||||
class WORKSHEET_VIEWITEM : public EDA_ITEM
|
||||
|
@ -58,7 +59,6 @@ public:
|
|||
void SetFileName( const std::string& aFileName )
|
||||
{
|
||||
m_fileName = aFileName;
|
||||
ViewUpdate( GEOMETRY );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +70,6 @@ public:
|
|||
void SetSheetName( const std::string& aSheetName )
|
||||
{
|
||||
m_sheetName = aSheetName;
|
||||
ViewUpdate( GEOMETRY );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,8 +97,6 @@ public:
|
|||
void SetSheetNumber( int aSheetNumber )
|
||||
{
|
||||
m_sheetNumber = aSheetNumber;
|
||||
ViewUpdate( GEOMETRY );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,17 +108,16 @@ public:
|
|||
void SetSheetCount( int aSheetCount )
|
||||
{
|
||||
m_sheetCount = aSheetCount;
|
||||
ViewUpdate( GEOMETRY );
|
||||
}
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewBBox()
|
||||
const BOX2I ViewBBox() const override;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewDraw()
|
||||
void ViewDraw( int aLayer, GAL* aGal ) const override;
|
||||
void ViewDraw( int aLayer, VIEW* aView ) const override;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewGetLayers()
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
#if defined(DEBUG)
|
||||
/// @copydoc EDA_ITEM::Show()
|
||||
|
|
|
@ -442,10 +442,9 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
|
|||
if( gal )
|
||||
{
|
||||
// Apply new display options to the GAL canvas
|
||||
KIGFX::PCB_PAINTER* painter =
|
||||
static_cast<KIGFX::PCB_PAINTER*> ( gal->GetView()->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
|
||||
auto view = gal->GetView();
|
||||
auto painter = static_cast<KIGFX::PCB_PAINTER*> ( view->GetPainter() );
|
||||
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
|
||||
settings->LoadDisplayOptions( displ_opts );
|
||||
|
||||
// Update pads
|
||||
|
@ -453,7 +452,7 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
|
|||
for( MODULE* module = board->m_Modules; module; module = module->Next() )
|
||||
{
|
||||
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
|
||||
pad->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->Update( pad, KIGFX::GEOMETRY );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -253,7 +253,13 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry)
|
|||
undoList.PushItem( itemWrapper );
|
||||
}
|
||||
|
||||
boardItem->ViewUpdate( KIGFX::VIEW_ITEM::ALL );
|
||||
if ( boardItem->Type() == PCB_MODULE_T )
|
||||
{
|
||||
MODULE* module = static_cast<MODULE*>( boardItem );
|
||||
module->RunOnChildren( boost::bind( &KIGFX::VIEW::Update, view, _1 ) );
|
||||
}
|
||||
|
||||
view->Update ( boardItem );
|
||||
ratsnest->Update( boardItem );
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include <class_edge_mod.h>
|
||||
#include <class_module.h>
|
||||
|
||||
#include <view/view.h>
|
||||
|
||||
MODULE::MODULE( BOARD* parent ) :
|
||||
BOARD_ITEM_CONTAINER( (BOARD_ITEM*) parent, PCB_MODULE_T ),
|
||||
|
@ -825,29 +826,6 @@ void MODULE::RunOnChildren( std::function<void (BOARD_ITEM*)> aFunction )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void MODULE::ViewUpdate( int aUpdateFlags )
|
||||
{
|
||||
if( !m_view )
|
||||
return;
|
||||
|
||||
// Update the module itself
|
||||
VIEW_ITEM::ViewUpdate( aUpdateFlags );
|
||||
|
||||
// Update pads
|
||||
for( D_PAD* pad = m_Pads.GetFirst(); pad; pad = pad->Next() )
|
||||
pad->ViewUpdate( aUpdateFlags );
|
||||
|
||||
// Update module's drawing (mostly silkscreen)
|
||||
for( BOARD_ITEM* drawing = m_Drawings.GetFirst(); drawing; drawing = drawing->Next() )
|
||||
drawing->ViewUpdate( aUpdateFlags );
|
||||
|
||||
// Update module's texts
|
||||
m_Reference->ViewUpdate( aUpdateFlags );
|
||||
m_Value->ViewUpdate( aUpdateFlags );
|
||||
}
|
||||
|
||||
|
||||
void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 2;
|
||||
|
@ -870,13 +848,13 @@ void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
|
|||
}
|
||||
|
||||
|
||||
unsigned int MODULE::ViewGetLOD( int aLayer ) const
|
||||
unsigned int MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW *aView ) const
|
||||
{
|
||||
int layer = ( m_Layer == F_Cu ) ? MOD_FR_VISIBLE :
|
||||
( m_Layer == B_Cu ) ? MOD_BK_VISIBLE : ANCHOR_VISIBLE;
|
||||
|
||||
// Currently it is only for anchor layer
|
||||
if( m_view->IsLayerVisible( ITEM_GAL_LAYER( layer ) ) )
|
||||
if( aView->IsLayerVisible( ITEM_GAL_LAYER( layer ) ) )
|
||||
return 30;
|
||||
|
||||
return std::numeric_limits<unsigned int>::max();
|
||||
|
|
|
@ -53,6 +53,10 @@ class D_PAD;
|
|||
class BOARD;
|
||||
class MSG_PANEL_ITEM;
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
class VIEW;
|
||||
};
|
||||
|
||||
enum INCLUDE_NPTH_T
|
||||
{
|
||||
|
@ -557,14 +561,12 @@ public:
|
|||
*/
|
||||
void RunOnChildren( std::function<void (BOARD_ITEM*)> aFunction );
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewUpdate()
|
||||
void ViewUpdate( int aUpdateFlags = KIGFX::VIEW_ITEM::ALL ) override;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewGetLayers()
|
||||
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewGetLOD()
|
||||
virtual unsigned int ViewGetLOD( int aLayer ) const override;
|
||||
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView );
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewBBox()
|
||||
virtual const BOX2I ViewBBox() const override;
|
||||
|
|
|
@ -959,7 +959,7 @@ void D_PAD::ViewGetLayers( int aLayers[], int& aCount ) const
|
|||
}
|
||||
|
||||
|
||||
unsigned int D_PAD::ViewGetLOD( int aLayer ) const
|
||||
unsigned int D_PAD::ViewGetLOD( int aLayer, KIGFX::VIEW *aView ) const
|
||||
{
|
||||
// Netnames will be shown only if zoom is appropriate
|
||||
if( IsNetnameLayer( aLayer ) )
|
||||
|
|
|
@ -46,6 +46,10 @@ class MODULE;
|
|||
class TRACK;
|
||||
class MSG_PANEL_INFO;
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
class VIEW;
|
||||
};
|
||||
|
||||
// Helper class to store parameters used to draw a pad
|
||||
class PAD_DRAWINFO
|
||||
|
@ -540,7 +544,7 @@ public:
|
|||
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewGetLOD()
|
||||
virtual unsigned int ViewGetLOD( int aLayer ) const override;
|
||||
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewBBox()
|
||||
virtual const BOX2I ViewBBox() const override;
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#include <class_board.h>
|
||||
#include <class_module.h>
|
||||
|
||||
#include <view/view.h>
|
||||
|
||||
#include <pcbnew.h>
|
||||
|
||||
|
||||
|
@ -419,25 +421,25 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
|
|||
}
|
||||
|
||||
|
||||
unsigned int TEXTE_MODULE::ViewGetLOD( int aLayer ) const
|
||||
unsigned int TEXTE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW *aView ) const
|
||||
{
|
||||
const int MAX = std::numeric_limits<unsigned int>::max();
|
||||
|
||||
if( !m_view )
|
||||
if( !aView )
|
||||
return 0;
|
||||
|
||||
if( m_Type == TEXT_is_VALUE && !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_VALUES_VISIBLE ) ) )
|
||||
if( m_Type == TEXT_is_VALUE && !aView->IsLayerVisible( ITEM_GAL_LAYER( MOD_VALUES_VISIBLE ) ) )
|
||||
return MAX;
|
||||
|
||||
if( m_Type == TEXT_is_REFERENCE && !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE ) ) )
|
||||
if( m_Type == TEXT_is_REFERENCE && !aView->IsLayerVisible( ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE ) ) )
|
||||
return MAX;
|
||||
|
||||
if( IsFrontLayer( m_Layer ) && ( !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ) ) ||
|
||||
!m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_FR_VISIBLE ) ) ) )
|
||||
if( IsFrontLayer( m_Layer ) && ( !aView->IsLayerVisible( ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ) ) ||
|
||||
!aView->IsLayerVisible( ITEM_GAL_LAYER( MOD_FR_VISIBLE ) ) ) )
|
||||
return MAX;
|
||||
|
||||
if( IsBackLayer( m_Layer ) && ( !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ) ) ||
|
||||
!m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_BK_VISIBLE ) ) ) )
|
||||
if( IsBackLayer( m_Layer ) && ( !aView->IsLayerVisible( ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ) ) ||
|
||||
!aView->IsLayerVisible( ITEM_GAL_LAYER( MOD_BK_VISIBLE ) ) ) )
|
||||
return MAX;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -184,7 +184,7 @@ public:
|
|||
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewGetLOD()
|
||||
virtual unsigned int ViewGetLOD( int aLayer ) const override;
|
||||
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
||||
|
||||
#if defined(DEBUG)
|
||||
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
|
|
|
@ -757,7 +757,7 @@ void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
|
|||
}
|
||||
|
||||
|
||||
unsigned int TRACK::ViewGetLOD( int aLayer ) const
|
||||
unsigned int TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW *aView ) const
|
||||
{
|
||||
// Netnames will be shown only if zoom is appropriate
|
||||
if( IsNetnameLayer( aLayer ) )
|
||||
|
|
|
@ -302,7 +302,7 @@ public:
|
|||
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewGetLOD()
|
||||
virtual unsigned int ViewGetLOD( int aLayer ) const override;
|
||||
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
||||
|
||||
#if defined (DEBUG)
|
||||
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
|
|
|
@ -742,7 +742,8 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK*
|
|||
aTrackRef->SetStart( aCandidate->GetEnd() );
|
||||
aTrackRef->start = aCandidate->end;
|
||||
aTrackRef->SetState( START_ON_PAD, aCandidate->GetState( END_ON_PAD ) );
|
||||
aTrackRef->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
// fixme: should be updated by the commit
|
||||
// aTrackRef->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
return aCandidate;
|
||||
}
|
||||
else
|
||||
|
@ -750,7 +751,7 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK*
|
|||
aTrackRef->SetStart( aCandidate->GetStart() );
|
||||
aTrackRef->start = aCandidate->start;
|
||||
aTrackRef->SetState( START_ON_PAD, aCandidate->GetState( START_ON_PAD ) );
|
||||
aTrackRef->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
// aTrackRef->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
return aCandidate;
|
||||
}
|
||||
}
|
||||
|
@ -767,7 +768,7 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK*
|
|||
aTrackRef->SetEnd( aCandidate->GetEnd() );
|
||||
aTrackRef->end = aCandidate->end;
|
||||
aTrackRef->SetState( END_ON_PAD, aCandidate->GetState( END_ON_PAD ) );
|
||||
aTrackRef->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
// aTrackRef->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
return aCandidate;
|
||||
}
|
||||
else
|
||||
|
@ -775,7 +776,7 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK*
|
|||
aTrackRef->SetEnd( aCandidate->GetStart() );
|
||||
aTrackRef->end = aCandidate->start;
|
||||
aTrackRef->SetState( END_ON_PAD, aCandidate->GetState( START_ON_PAD ) );
|
||||
aTrackRef->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
// aTrackRef->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
return aCandidate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <common.h>
|
||||
#include <macros.h>
|
||||
#include <wxBasePcbFrame.h>
|
||||
#include <view/view.h>
|
||||
|
||||
#include <pcbnew.h>
|
||||
|
||||
|
@ -942,9 +943,12 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode()
|
|||
}
|
||||
}
|
||||
|
||||
if ( IsGalCanvasActive() )
|
||||
{
|
||||
/// @todo LEGACY tracks might have changed their nets, so we need to refresh labels in GAL
|
||||
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
|
||||
track->ViewUpdate();
|
||||
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
|
||||
GetGalCanvas()->GetView()->Update( track );
|
||||
}
|
||||
|
||||
// Sort the track list by net codes:
|
||||
RebuildTrackChain( m_Pcb );
|
||||
|
|
|
@ -124,7 +124,6 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
|
|||
GetBoard()->Remove( aTrack );
|
||||
|
||||
GetBoard()->GetRatsnest()->Remove( aTrack );
|
||||
aTrack->ViewRelease();
|
||||
|
||||
// redraw the area where the track was
|
||||
m_canvas->RefreshDrawingRect( aTrack->GetBoundingBox() );
|
||||
|
@ -175,7 +174,6 @@ void PCB_EDIT_FRAME::Delete_net( wxDC* DC, TRACK* aTrack )
|
|||
break;
|
||||
|
||||
GetBoard()->GetRatsnest()->Remove( segm );
|
||||
segm->ViewRelease();
|
||||
GetBoard()->m_Track.Remove( segm );
|
||||
|
||||
// redraw the area where the track was
|
||||
|
@ -222,7 +220,6 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
|
|||
<< std::endl; )
|
||||
|
||||
GetBoard()->GetRatsnest()->Remove( tracksegment );
|
||||
tracksegment->ViewRelease();
|
||||
GetBoard()->m_Track.Remove( tracksegment );
|
||||
|
||||
// redraw the area where the track was
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <base_units.h>
|
||||
#include <class_board_design_settings.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <view/view.h>
|
||||
|
||||
/* class DIALOG_DRC_CONTROL: a dialog to set DRC parameters (clearance, min cooper size)
|
||||
* and run DRC tests
|
||||
|
@ -672,4 +673,3 @@ void DIALOG_DRC_CONTROL::UpdateDisplayedCounts()
|
|||
m_MarkerCount->SetLabelText( wxString::Format( "%d", marker_count ) );
|
||||
m_UnconnectedCount->SetLabelText( wxString::Format( "%d", unconnected_count ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -877,7 +877,7 @@ void DIALOG_PAD_PROPERTIES::redraw()
|
|||
{
|
||||
if( m_parent->IsGalCanvasActive() )
|
||||
{
|
||||
m_dummyPad->ViewUpdate();
|
||||
m_parent->GetGalCanvas()->GetView()->Update( m_dummyPad );
|
||||
|
||||
BOX2I bbox = m_dummyPad->ViewBBox();
|
||||
|
||||
|
|
|
@ -582,7 +582,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
int ret = dialog.ShowModal();
|
||||
GetScreen()->GetCurItem()->ClearFlags();
|
||||
GetBoard()->m_Modules.GetFirst()->ViewUpdate();
|
||||
//GetBoard()->m_Modules.GetFirst()->ViewUpdate();
|
||||
|
||||
if( ret > 0 )
|
||||
m_canvas->Refresh();
|
||||
|
@ -988,4 +988,3 @@ void FOOTPRINT_EDIT_FRAME::SetActiveLayer( LAYER_ID aLayer )
|
|||
if( IsGalCanvasActive() )
|
||||
GetGalCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ using namespace std::placeholders;
|
|||
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/common_actions.h>
|
||||
#include <view/view.h>
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
|
||||
|
@ -159,7 +160,6 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
|
|||
{
|
||||
module->RunOnChildren( std::bind( &KIGFX::VIEW::Add, view, _1 ) );
|
||||
view->Add( module );
|
||||
module->ViewUpdate();
|
||||
}
|
||||
|
||||
if( aDeleteUnconnectedTracks && board->m_Track )
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include <pcb_draw_panel_gal.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <class_board.h>
|
||||
#include <view/view.h>
|
||||
|
||||
|
||||
void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
|
||||
{
|
||||
|
|
|
@ -191,7 +191,7 @@ public:
|
|||
}
|
||||
|
||||
/// @copydoc PAINTER::GetSettings()
|
||||
virtual RENDER_SETTINGS* GetSettings() override
|
||||
virtual PCB_RENDER_SETTINGS* GetSettings() override
|
||||
{
|
||||
return &m_pcbSettings;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include <dialog_mask_clearance.h>
|
||||
#include <dialog_general_options.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <view/view.h>
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
||||
|
@ -186,7 +187,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
if( dlg.ShowModal() == 1 && IsGalCanvasActive() )
|
||||
{
|
||||
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
|
||||
module->ViewUpdate();
|
||||
GetGalCanvas()->GetView()->Update( module );
|
||||
|
||||
GetGalCanvas()->Refresh();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <pcb_painter.h>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
|
||||
#include <view/view.h>
|
||||
|
||||
namespace KIGFX {
|
||||
|
||||
|
@ -52,13 +53,14 @@ const BOX2I RATSNEST_VIEWITEM::ViewBBox() const
|
|||
}
|
||||
|
||||
|
||||
void RATSNEST_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const
|
||||
void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
||||
{
|
||||
aGal->SetIsStroke( true );
|
||||
aGal->SetIsFill( false );
|
||||
aGal->SetLineWidth( 1.0 );
|
||||
RENDER_SETTINGS* rs = m_view->GetPainter()->GetSettings();
|
||||
COLOR4D color = rs->GetColor( NULL, ITEM_GAL_LAYER( RATSNEST_VISIBLE ) );
|
||||
auto gal = aView->GetGAL();
|
||||
gal->SetIsStroke( true );
|
||||
gal->SetIsFill( false );
|
||||
gal->SetLineWidth( 1.0 );
|
||||
auto rs = aView->GetPainter()->GetSettings();
|
||||
auto color = rs->GetColor( NULL, ITEM_GAL_LAYER( RATSNEST_VISIBLE ) );
|
||||
int highlightedNet = rs->GetHighlightNetCode();
|
||||
|
||||
// Dynamic ratsnest (for e.g. dragged items)
|
||||
|
@ -70,7 +72,7 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const
|
|||
continue;
|
||||
|
||||
// Set brighter color for the temporary ratsnest
|
||||
aGal->SetStrokeColor( color.Brightened( 0.8 ) );
|
||||
gal->SetStrokeColor( color.Brightened( 0.8 ) );
|
||||
|
||||
// Draw the "dynamic" ratsnest (i.e. for objects that may be currently being moved)
|
||||
for( const RN_NODE_PTR& node : net.GetSimpleNodes() )
|
||||
|
@ -86,13 +88,13 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const
|
|||
VECTOR2D origin( node->GetX(), node->GetY() );
|
||||
VECTOR2D end( dest->GetX(), dest->GetY() );
|
||||
|
||||
aGal->DrawLine( origin, end );
|
||||
gal->DrawLine( origin, end );
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the "static" ratsnest
|
||||
if( i != highlightedNet )
|
||||
aGal->SetStrokeColor( color ); // using the default ratsnest color for not highlighted
|
||||
gal->SetStrokeColor( color ); // using the default ratsnest color for not highlighted
|
||||
|
||||
const std::vector<RN_EDGE_MST_PTR>* edges = net.GetUnconnected();
|
||||
|
||||
|
@ -106,7 +108,7 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const
|
|||
VECTOR2D source( sourceNode->GetX(), sourceNode->GetY() );
|
||||
VECTOR2D target( targetNode->GetX(), targetNode->GetY() );
|
||||
|
||||
aGal->DrawLine( source, target );
|
||||
gal->DrawLine( source, target );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
const BOX2I ViewBBox() const override;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewDraw()
|
||||
void ViewDraw( int aLayer, GAL* aGal ) const override;
|
||||
void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewGetLayers()
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
|
|
@ -326,6 +326,7 @@ public:
|
|||
~PNS_PCBNEW_DEBUG_DECORATOR()
|
||||
{
|
||||
Clear();
|
||||
m_view->Remove ( m_items );
|
||||
delete m_items;
|
||||
}
|
||||
|
||||
|
@ -342,7 +343,6 @@ public:
|
|||
m_items = new KIGFX::VIEW_GROUP( m_view );
|
||||
m_items->SetLayer( ITEM_GAL_LAYER( GP_OVERLAY ) );
|
||||
m_view->Add( m_items );
|
||||
m_items->ViewSetVisible( true );
|
||||
}
|
||||
|
||||
void AddPoint( VECTOR2I aP, int aColor ) override
|
||||
|
@ -404,12 +404,11 @@ public:
|
|||
|
||||
void AddLine( const SHAPE_LINE_CHAIN& aLine, int aType, int aWidth ) override
|
||||
{
|
||||
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( NULL, m_items );
|
||||
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( NULL, m_view );
|
||||
|
||||
pitem->Line( aLine, aWidth, aType );
|
||||
m_items->Add( pitem ); // Should not be needed, as m_items has been passed as a parent group in alloc;
|
||||
pitem->ViewSetVisible( true );
|
||||
m_items->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY | KIGFX::VIEW_ITEM::APPEARANCE );
|
||||
m_view->Update ( m_items );
|
||||
}
|
||||
|
||||
void Clear() override
|
||||
|
@ -417,7 +416,7 @@ public:
|
|||
if( m_view && m_items )
|
||||
{
|
||||
m_items->FreeItems();
|
||||
m_items->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update ( m_items );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -795,14 +794,14 @@ void PNS_KICAD_IFACE::SyncWorld( PNS::NODE *aWorld )
|
|||
void PNS_KICAD_IFACE::EraseView()
|
||||
{
|
||||
for( auto item : m_hiddenItems )
|
||||
item->ViewSetVisible( true );
|
||||
m_view->SetVisible( item, true );
|
||||
|
||||
m_hiddenItems.clear();
|
||||
|
||||
if( m_previewItems )
|
||||
{
|
||||
m_previewItems->FreeItems();
|
||||
m_previewItems->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( m_previewItems );
|
||||
}
|
||||
|
||||
if( m_debugDecorator )
|
||||
|
@ -814,7 +813,7 @@ void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClea
|
|||
{
|
||||
wxLogTrace( "PNS", "DisplayItem %p", aItem );
|
||||
|
||||
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_previewItems );
|
||||
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
|
||||
|
||||
if( aColor >= 0 )
|
||||
pitem->SetColor( KIGFX::COLOR4D( aColor ) );
|
||||
|
@ -824,8 +823,7 @@ void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClea
|
|||
|
||||
m_previewItems->Add( pitem );
|
||||
|
||||
pitem->ViewSetVisible( true );
|
||||
m_previewItems->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY | KIGFX::VIEW_ITEM::APPEARANCE );
|
||||
m_view->Update ( m_previewItems );
|
||||
}
|
||||
|
||||
|
||||
|
@ -835,11 +833,11 @@ void PNS_KICAD_IFACE::HideItem( PNS::ITEM* aItem )
|
|||
|
||||
if( parent )
|
||||
{
|
||||
if( parent->ViewIsVisible() )
|
||||
if( m_view->IsVisible ( parent ) )
|
||||
m_hiddenItems.insert( parent );
|
||||
|
||||
parent->ViewSetVisible( false );
|
||||
parent->ViewUpdate( KIGFX::VIEW_ITEM::APPEARANCE );
|
||||
m_view->SetVisible( parent, false );
|
||||
m_view->Update ( parent, KIGFX::APPEARANCE );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -906,6 +904,7 @@ void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem )
|
|||
|
||||
void PNS_KICAD_IFACE::Commit()
|
||||
{
|
||||
EraseView();
|
||||
m_commit->Push( wxT( "Added a track" ) );
|
||||
m_commit.reset( new BOARD_COMMIT ( m_frame ) );
|
||||
}
|
||||
|
@ -925,7 +924,6 @@ void PNS_KICAD_IFACE::SetView( KIGFX::VIEW *aView )
|
|||
m_previewItems = new KIGFX::VIEW_GROUP( m_view );
|
||||
m_previewItems->SetLayer( ITEM_GAL_LAYER( GP_OVERLAY ) );
|
||||
m_view->Add( m_previewItems );
|
||||
m_previewItems->ViewSetVisible( true );
|
||||
|
||||
delete m_debugDecorator;
|
||||
m_debugDecorator = new PNS_PCBNEW_DEBUG_DECORATOR();
|
||||
|
|
|
@ -56,6 +56,8 @@ using namespace std::placeholders;
|
|||
#include "pns_tune_status_popup.h"
|
||||
#include "pns_topology.h"
|
||||
|
||||
#include <view/view.h>
|
||||
|
||||
using namespace KIGFX;
|
||||
|
||||
namespace PNS {
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
|
||||
using namespace KIGFX;
|
||||
|
||||
ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem, VIEW_GROUP* aParent ) :
|
||||
ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem, KIGFX::VIEW* aView ) :
|
||||
EDA_ITEM( NOT_USED )
|
||||
{
|
||||
m_parent = aParent;
|
||||
m_view = aView;
|
||||
|
||||
m_shape = NULL;
|
||||
m_clearance = -1;
|
||||
|
@ -118,8 +118,6 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS::ITEM* aItem )
|
|||
|
||||
if( aItem->Marker() & PNS::MK_VIOLATION )
|
||||
m_color = COLOR4D( 0, 1, 0, 1 );
|
||||
|
||||
ViewSetVisible( true );
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,52 +144,53 @@ const BOX2I ROUTER_PREVIEW_ITEM::ViewBBox() const
|
|||
}
|
||||
|
||||
|
||||
void ROUTER_PREVIEW_ITEM::drawLineChain( const SHAPE_LINE_CHAIN& aL, KIGFX::GAL* aGal ) const
|
||||
void ROUTER_PREVIEW_ITEM::drawLineChain( const SHAPE_LINE_CHAIN& aL, KIGFX::GAL* gal ) const
|
||||
{
|
||||
for( int s = 0; s < aL.SegmentCount(); s++ )
|
||||
aGal->DrawLine( aL.CSegment( s ).A, aL.CSegment( s ).B );
|
||||
gal->DrawLine( aL.CSegment( s ).A, aL.CSegment( s ).B );
|
||||
|
||||
if( aL.IsClosed() )
|
||||
aGal->DrawLine( aL.CSegment( -1 ).B, aL.CSegment( 0 ).A );
|
||||
gal->DrawLine( aL.CSegment( -1 ).B, aL.CSegment( 0 ).A );
|
||||
}
|
||||
|
||||
|
||||
void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
|
||||
void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
||||
{
|
||||
auto gal = aView->GetGAL();
|
||||
//col.Brighten(0.7);
|
||||
aGal->SetLayerDepth( m_depth );
|
||||
gal->SetLayerDepth( m_depth );
|
||||
|
||||
if( m_type == PR_SHAPE )
|
||||
{
|
||||
if( !m_shape )
|
||||
return;
|
||||
|
||||
aGal->SetLineWidth( m_width );
|
||||
aGal->SetStrokeColor( m_color );
|
||||
aGal->SetFillColor( m_color );
|
||||
aGal->SetIsStroke( m_width ? true : false );
|
||||
aGal->SetIsFill( true );
|
||||
gal->SetLineWidth( m_width );
|
||||
gal->SetStrokeColor( m_color );
|
||||
gal->SetFillColor( m_color );
|
||||
gal->SetIsStroke( m_width ? true : false );
|
||||
gal->SetIsFill( true );
|
||||
|
||||
switch( m_shape->Type() )
|
||||
{
|
||||
case SH_LINE_CHAIN:
|
||||
{
|
||||
const SHAPE_LINE_CHAIN* l = (const SHAPE_LINE_CHAIN*) m_shape;
|
||||
drawLineChain( *l, aGal );
|
||||
drawLineChain( *l, gal );
|
||||
break;
|
||||
}
|
||||
|
||||
case SH_SEGMENT:
|
||||
{
|
||||
const SHAPE_SEGMENT* s = (const SHAPE_SEGMENT*) m_shape;
|
||||
aGal->DrawSegment( s->GetSeg().A, s->GetSeg().B, s->GetWidth() );
|
||||
gal->DrawSegment( s->GetSeg().A, s->GetSeg().B, s->GetWidth() );
|
||||
|
||||
if( m_clearance > 0 )
|
||||
{
|
||||
aGal->SetLayerDepth( ClearanceOverlayDepth );
|
||||
aGal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
|
||||
aGal->SetFillColor( COLOR4D( DARKDARKGRAY ) );
|
||||
aGal->DrawSegment( s->GetSeg().A, s->GetSeg().B, s->GetWidth() + 2 * m_clearance );
|
||||
gal->SetLayerDepth( ClearanceOverlayDepth );
|
||||
gal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
|
||||
gal->SetFillColor( COLOR4D( DARKDARKGRAY ) );
|
||||
gal->DrawSegment( s->GetSeg().A, s->GetSeg().B, s->GetWidth() + 2 * m_clearance );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -200,14 +199,14 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
|
|||
case SH_CIRCLE:
|
||||
{
|
||||
const SHAPE_CIRCLE* c = (const SHAPE_CIRCLE*) m_shape;
|
||||
aGal->DrawCircle( c->GetCenter(), c->GetRadius() );
|
||||
gal->DrawCircle( c->GetCenter(), c->GetRadius() );
|
||||
|
||||
if( m_clearance > 0 )
|
||||
{
|
||||
aGal->SetLayerDepth( ClearanceOverlayDepth );
|
||||
aGal->SetFillColor( COLOR4D( DARKDARKGRAY ) );
|
||||
aGal->SetIsStroke( false );
|
||||
aGal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance );
|
||||
gal->SetLayerDepth( ClearanceOverlayDepth );
|
||||
gal->SetFillColor( COLOR4D( DARKDARKGRAY ) );
|
||||
gal->SetIsStroke( false );
|
||||
gal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -216,19 +215,19 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
|
|||
case SH_RECT:
|
||||
{
|
||||
const SHAPE_RECT* r = (const SHAPE_RECT*) m_shape;
|
||||
aGal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
|
||||
gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
|
||||
|
||||
if( m_clearance > 0 )
|
||||
{
|
||||
aGal->SetLayerDepth( ClearanceOverlayDepth );
|
||||
gal->SetLayerDepth( ClearanceOverlayDepth );
|
||||
VECTOR2I p0( r->GetPosition() ), s( r->GetSize() );
|
||||
aGal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
|
||||
aGal->SetIsStroke( true );
|
||||
aGal->SetLineWidth( 2 * m_clearance );
|
||||
aGal->DrawLine( p0, VECTOR2I( p0.x + s.x, p0.y ) );
|
||||
aGal->DrawLine( p0, VECTOR2I( p0.x, p0.y + s.y ) );
|
||||
aGal->DrawLine( p0 + s , VECTOR2I( p0.x + s.x, p0.y ) );
|
||||
aGal->DrawLine( p0 + s, VECTOR2I( p0.x, p0.y + s.y ) );
|
||||
gal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
|
||||
gal->SetIsStroke( true );
|
||||
gal->SetLineWidth( 2 * m_clearance );
|
||||
gal->DrawLine( p0, VECTOR2I( p0.x + s.x, p0.y ) );
|
||||
gal->DrawLine( p0, VECTOR2I( p0.x, p0.y + s.y ) );
|
||||
gal->DrawLine( p0 + s , VECTOR2I( p0.x + s.x, p0.y ) );
|
||||
gal->DrawLine( p0 + s, VECTOR2I( p0.x, p0.y + s.y ) );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -242,17 +241,17 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
|
|||
{
|
||||
polygon.push_back( c->CDPoint( i ) );
|
||||
}
|
||||
aGal->DrawPolygon( polygon );
|
||||
gal->DrawPolygon( polygon );
|
||||
|
||||
if( m_clearance > 0 )
|
||||
{
|
||||
aGal->SetLayerDepth( ClearanceOverlayDepth );
|
||||
aGal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
|
||||
aGal->SetIsStroke( true );
|
||||
aGal->SetLineWidth( 2 * m_clearance );
|
||||
gal->SetLayerDepth( ClearanceOverlayDepth );
|
||||
gal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
|
||||
gal->SetIsStroke( true );
|
||||
gal->SetLineWidth( 2 * m_clearance );
|
||||
// need the implicit last segment to be explicit for DrawPolyline
|
||||
polygon.push_back( c->CDPoint( 0 ) );
|
||||
aGal->DrawPolyline( polygon );
|
||||
gal->DrawPolyline( polygon );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -273,8 +272,6 @@ void ROUTER_PREVIEW_ITEM::Line( const SHAPE_LINE_CHAIN& aLine, int aWidth, int a
|
|||
m_type = PR_SHAPE;
|
||||
m_depth = -1024; // TODO gal->GetMinDepth()
|
||||
m_shape = aLine.Clone();
|
||||
|
||||
ViewSetVisible( true );
|
||||
}
|
||||
|
||||
|
||||
|
@ -290,8 +287,7 @@ void ROUTER_PREVIEW_ITEM::Box( const BOX2I& aBox, int aStyle )
|
|||
|
||||
const COLOR4D ROUTER_PREVIEW_ITEM::getLayerColor( int aLayer ) const
|
||||
{
|
||||
PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<PCB_RENDER_SETTINGS*>( m_parent->GetView()->GetPainter()->GetSettings() );
|
||||
auto settings = static_cast<PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() );
|
||||
|
||||
return settings->GetLayerColor( aLayer );
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
PR_SHAPE
|
||||
};
|
||||
|
||||
ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem = NULL, KIGFX::VIEW_GROUP* aParent = NULL );
|
||||
ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem = NULL, KIGFX::VIEW* aView = NULL);
|
||||
~ROUTER_PREVIEW_ITEM();
|
||||
|
||||
void Update( const PNS::ITEM* aItem );
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
const BOX2I ViewBBox() const override;
|
||||
|
||||
virtual void ViewDraw( int aLayer, KIGFX::GAL* aGal ) const override;
|
||||
virtual void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override;
|
||||
|
||||
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ private:
|
|||
const KIGFX::COLOR4D assignColor( int aStyle ) const;
|
||||
const KIGFX::COLOR4D getLayerColor( int aLayer ) const;
|
||||
|
||||
KIGFX::VIEW_GROUP* m_parent;
|
||||
KIGFX::VIEW* m_view;
|
||||
|
||||
PNS::ROUTER* m_router;
|
||||
SHAPE* m_shape;
|
||||
|
|
|
@ -32,6 +32,7 @@ using namespace std::placeholders;
|
|||
#include <id.h>
|
||||
#include <macros.h>
|
||||
#include <pcbnew_id.h>
|
||||
#include <view/view.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <pcbcommon.h>
|
||||
#include <pcb_painter.h>
|
||||
|
|
|
@ -31,31 +31,43 @@ using namespace KIGFX;
|
|||
const double BRIGHT_BOX::LINE_WIDTH = 100000.0;
|
||||
const COLOR4D BRIGHT_BOX::BOX_COLOR = KIGFX::COLOR4D( 0.0, 1.0, 0.0, 1.0 );
|
||||
|
||||
BRIGHT_BOX::BRIGHT_BOX( BOARD_ITEM* aItem ) :
|
||||
BRIGHT_BOX::BRIGHT_BOX () :
|
||||
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
|
||||
m_item( aItem )
|
||||
m_item ( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BRIGHT_BOX::ViewDraw( int aLayer, GAL* aGal ) const
|
||||
void BRIGHT_BOX::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
||||
{
|
||||
aGal->SetIsStroke( true );
|
||||
aGal->SetIsFill( false );
|
||||
aGal->SetLineWidth( LINE_WIDTH );
|
||||
aGal->SetStrokeColor( BOX_COLOR );
|
||||
printf("DrawBB item %p\n", m_item);
|
||||
|
||||
if( !m_item )
|
||||
return;
|
||||
|
||||
auto gal = aView->GetGAL();
|
||||
|
||||
gal->SetIsStroke( true );
|
||||
gal->SetIsFill( false );
|
||||
gal->SetLineWidth( LINE_WIDTH );
|
||||
gal->SetStrokeColor( BOX_COLOR );
|
||||
|
||||
|
||||
if( m_item->Type() == PCB_TRACE_T )
|
||||
{
|
||||
const TRACK* track = static_cast<const TRACK*>( m_item );
|
||||
|
||||
aGal->DrawSegment( track->GetStart(), track->GetEnd(), track->GetWidth() );
|
||||
gal->DrawSegment( track->GetStart(), track->GetEnd(), track->GetWidth() );
|
||||
}
|
||||
else
|
||||
{
|
||||
BOX2I box = m_item->ViewBBox();
|
||||
|
||||
aGal->DrawRectangle( box.GetOrigin(), box.GetOrigin() + box.GetSize() );
|
||||
gal->DrawRectangle( box.GetOrigin(), box.GetOrigin() + box.GetSize() );
|
||||
}
|
||||
}
|
||||
|
||||
void BRIGHT_BOX::SetItem( BOARD_ITEM *aItem )
|
||||
{
|
||||
m_item = aItem;
|
||||
}
|
||||
|
|
|
@ -44,10 +44,17 @@ public:
|
|||
|
||||
virtual const BOX2I ViewBBox() const override
|
||||
{
|
||||
BOX2I bb; bb.SetMaximum();
|
||||
return bb;
|
||||
|
||||
if ( !m_item )
|
||||
return BOX2I();
|
||||
|
||||
return m_item->ViewBBox();
|
||||
|
||||
}
|
||||
|
||||
void ViewDraw( int aLayer, KIGFX::GAL* aGal ) const override;
|
||||
void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override;
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override
|
||||
{
|
||||
|
@ -69,6 +76,8 @@ public:
|
|||
return wxT( "BRIGHT_BOX" );
|
||||
}
|
||||
|
||||
void SetItem( BOARD_ITEM *aItem );
|
||||
|
||||
private:
|
||||
static const KIGFX::COLOR4D BOX_COLOR;
|
||||
static const double LINE_WIDTH;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <view/view_group.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <view/view.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <router/direction.h>
|
||||
|
@ -208,13 +209,13 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
|
||||
{
|
||||
text->Rotate( text->GetPosition(), m_frame->GetRotationAngle() );
|
||||
preview.ViewUpdate();
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
// TODO rotate CCW
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
||||
{
|
||||
text->Flip( text->GetPosition() );
|
||||
preview.ViewUpdate();
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,7 +305,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
text->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
|
||||
// Show a preview of the item
|
||||
preview.ViewUpdate();
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,7 +372,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) && step != SET_ORIGIN )
|
||||
{
|
||||
dimension->SetWidth( dimension->GetWidth() + WIDTH_STEP );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) && step != SET_ORIGIN )
|
||||
|
@ -381,7 +382,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
if( width > WIDTH_STEP )
|
||||
{
|
||||
dimension->SetWidth( width - WIDTH_STEP );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -480,7 +481,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
// Show a preview of the item
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -565,7 +566,7 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
|||
for ( auto item : preview )
|
||||
item->Move( wxPoint( delta.x, delta.y ) );
|
||||
|
||||
preview.ViewUpdate();
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
|
||||
else if( evt->Category() == TC_COMMAND )
|
||||
|
@ -577,14 +578,14 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
|||
item->Rotate( wxPoint( cursorPos.x, cursorPos.y ),
|
||||
m_frame->GetRotationAngle() );
|
||||
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
||||
{
|
||||
for ( auto item : preview )
|
||||
item->Flip( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
else if( evt->IsCancel() || evt->IsActivate() )
|
||||
{
|
||||
|
@ -901,7 +902,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
|
|||
}
|
||||
|
||||
if( updatePreview )
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
|
@ -1012,7 +1013,6 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
|
|||
assert( aGraphic->GetWidth() > 0 );
|
||||
|
||||
m_view->Add( aGraphic );
|
||||
aGraphic->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
|
||||
preview.Remove( aGraphic );
|
||||
preview.Remove( &helperLine );
|
||||
|
@ -1053,13 +1053,13 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
|
|||
}
|
||||
|
||||
// Show a preview of the item
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) )
|
||||
{
|
||||
aGraphic->SetWidth( aGraphic->GetWidth() + WIDTH_STEP );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) )
|
||||
|
@ -1069,7 +1069,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
|
|||
if( width > WIDTH_STEP )
|
||||
{
|
||||
aGraphic->SetWidth( width - WIDTH_STEP );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1081,7 +1081,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
|
|||
aGraphic->SetAngle( aGraphic->GetAngle() + 3600.0 );
|
||||
|
||||
clockwise = !clockwise;
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1291,7 +1291,7 @@ int DRAWING_TOOL::drawZone( bool aKeepout )
|
|||
}
|
||||
|
||||
if( updatePreview )
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
|
|
|
@ -42,9 +42,9 @@ EDIT_POINTS::EDIT_POINTS( EDA_ITEM* aParent ) :
|
|||
}
|
||||
|
||||
|
||||
EDIT_POINT* EDIT_POINTS::FindPoint( const VECTOR2I& aLocation )
|
||||
EDIT_POINT* EDIT_POINTS::FindPoint( const VECTOR2I& aLocation, KIGFX::VIEW *aView ) // fixme: ugly
|
||||
{
|
||||
float size = m_view->ToWorld( EDIT_POINT::POINT_SIZE );
|
||||
float size = aView->ToWorld( EDIT_POINT::POINT_SIZE );
|
||||
|
||||
std::deque<EDIT_POINT>::iterator pit, pitEnd;
|
||||
for( pit = m_points.begin(), pitEnd = m_points.end(); pit != pitEnd; ++pit )
|
||||
|
@ -203,23 +203,25 @@ EDIT_LINE* EDIT_POINTS::Next( const EDIT_LINE& aLine )
|
|||
}
|
||||
|
||||
|
||||
void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
|
||||
void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
||||
{
|
||||
aGal->SetFillColor( KIGFX::COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
||||
aGal->SetIsFill( true );
|
||||
aGal->SetIsStroke( false );
|
||||
aGal->PushDepth();
|
||||
aGal->SetLayerDepth( aGal->GetMinDepth() );
|
||||
auto gal = aView->GetGAL();
|
||||
|
||||
float size = m_view->ToWorld( EDIT_POINT::POINT_SIZE );
|
||||
gal->SetFillColor( KIGFX::COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
||||
gal->SetIsFill( true );
|
||||
gal->SetIsStroke( false );
|
||||
gal->PushDepth();
|
||||
gal->SetLayerDepth( gal->GetMinDepth() );
|
||||
|
||||
float size = aView->ToWorld( EDIT_POINT::POINT_SIZE );
|
||||
|
||||
for( const EDIT_POINT& point : m_points )
|
||||
aGal->DrawRectangle( point.GetPosition() - size / 2, point.GetPosition() + size / 2 );
|
||||
gal->DrawRectangle( point.GetPosition() - size / 2, point.GetPosition() + size / 2 );
|
||||
|
||||
for( const EDIT_LINE& line : m_lines )
|
||||
{
|
||||
aGal->DrawCircle( line.GetPosition(), size / 2 );
|
||||
gal->DrawCircle( line.GetPosition(), size / 2 );
|
||||
}
|
||||
|
||||
aGal->PopDepth();
|
||||
gal->PopDepth();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include <view/view.h>
|
||||
|
||||
/**
|
||||
* Class EDIT_POINT
|
||||
|
@ -317,7 +318,7 @@ public:
|
|||
* Returns a point that is at given coordinates or NULL if there is no such point.
|
||||
* @param aLocation is the location for searched point.
|
||||
*/
|
||||
EDIT_POINT* FindPoint( const VECTOR2I& aLocation );
|
||||
EDIT_POINT* FindPoint( const VECTOR2I& aLocation, KIGFX::VIEW *aView );
|
||||
|
||||
/**
|
||||
* Function GetParent()
|
||||
|
@ -498,7 +499,7 @@ public:
|
|||
}
|
||||
|
||||
///> @copydoc VIEW_ITEM::ViewDraw()
|
||||
virtual void ViewDraw( int aLayer, KIGFX::GAL* aGal ) const override;
|
||||
virtual void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override;
|
||||
|
||||
///> @copydoc VIEW_ITEM::ViewGetLayers()
|
||||
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include <tool/tool_manager.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <view/view.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <ratsnest_data.h>
|
||||
#include <confirm.h>
|
||||
|
@ -60,7 +61,7 @@ using namespace std::placeholders;
|
|||
|
||||
EDIT_TOOL::EDIT_TOOL() :
|
||||
PCB_TOOL( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ),
|
||||
m_dragging( false ), m_updateFlag( KIGFX::VIEW_ITEM::NONE )
|
||||
m_dragging( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -68,7 +69,6 @@ EDIT_TOOL::EDIT_TOOL() :
|
|||
void EDIT_TOOL::Reset( RESET_REASON aReason )
|
||||
{
|
||||
m_dragging = false;
|
||||
m_updateFlag = KIGFX::VIEW_ITEM::NONE;
|
||||
|
||||
if( aReason != RUN )
|
||||
m_commit.reset( new BOARD_COMMIT( this ) );
|
||||
|
@ -153,9 +153,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
bool restore = false; // Should items' state be restored when finishing the tool?
|
||||
bool lockOverride = false;
|
||||
|
||||
// By default, modified items need to update their geometry
|
||||
m_updateFlag = KIGFX::VIEW_ITEM::GEOMETRY;
|
||||
|
||||
controls->ShowCursor( true );
|
||||
|
||||
// cumulative translation
|
||||
|
@ -245,7 +242,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
selection.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
getView()->Update( &selection );
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::editModifiedSelection, true );
|
||||
}
|
||||
|
||||
|
@ -261,9 +258,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
||||
{
|
||||
Flip( aEvent );
|
||||
|
||||
// Flip causes change of layers
|
||||
enableUpdateFlag( KIGFX::VIEW_ITEM::LAYERS );
|
||||
}
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::remove ) )
|
||||
{
|
||||
|
@ -305,7 +299,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
// Update dragging offset (distance between cursor and the first dragged item)
|
||||
m_offset = selection.Front()->GetPosition() - modPoint;
|
||||
selection.ViewUpdate( KIGFX::VIEW_ITEM::ALL );
|
||||
getView()->Update( &selection );
|
||||
updateRatsnest( true );
|
||||
}
|
||||
}
|
||||
|
@ -502,7 +496,7 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
|
|||
item->Rotate( rotPoint, rotation );
|
||||
|
||||
if( !m_dragging )
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
getView()->Update( item, KIGFX::GEOMETRY );
|
||||
}
|
||||
|
||||
m_commit->Push( _( "Move exact" ) );
|
||||
|
|
|
@ -127,16 +127,6 @@ private:
|
|||
///> of edit reference point).
|
||||
VECTOR2I m_cursor;
|
||||
|
||||
///> The required update flag for modified items
|
||||
KIGFX::VIEW_ITEM::VIEW_UPDATE_FLAGS m_updateFlag;
|
||||
|
||||
///> Enables higher order update flag
|
||||
void enableUpdateFlag( KIGFX::VIEW_ITEM::VIEW_UPDATE_FLAGS aFlag )
|
||||
{
|
||||
if( m_updateFlag < aFlag )
|
||||
m_updateFlag = aFlag;
|
||||
}
|
||||
|
||||
///> Updates ratsnest for selected items.
|
||||
///> @param aRedraw says if selected items should be drawn using the simple mode (e.g. one line
|
||||
///> per item).
|
||||
|
|
|
@ -33,6 +33,7 @@ using namespace std::placeholders;
|
|||
#include <class_zone.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
|
||||
#include <view/view.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
|
||||
|
@ -196,12 +197,13 @@ std::set<BOARD_ITEM*> GRID_HELPER::queryVisible( const BOX2I& aArea ) const
|
|||
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
|
||||
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR>::iterator it, it_end;
|
||||
|
||||
m_frame->GetGalCanvas()->GetView()->Query( aArea, selectedItems ); // Get the list of selected items
|
||||
auto view = m_frame->GetGalCanvas()->GetView();
|
||||
view->Query( aArea, selectedItems ); // Get the list of selected items
|
||||
|
||||
for( it = selectedItems.begin(), it_end = selectedItems.end(); it != it_end; ++it )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first );
|
||||
if( item->ViewIsVisible() )
|
||||
if( view->IsVisible( item ) )
|
||||
items.insert ( item );
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ int MODULE_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
|||
if( evt->IsMotion() )
|
||||
{
|
||||
pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
preview.ViewUpdate();
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
|
||||
else if( evt->Category() == TC_COMMAND )
|
||||
|
@ -141,12 +141,12 @@ int MODULE_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
|||
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
|
||||
{
|
||||
pad->Rotate( pad->GetPosition(), m_frame->GetRotationAngle() );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
||||
{
|
||||
pad->Flip( pad->GetPosition() );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
else if( evt->IsCancel() || evt->IsActivate() )
|
||||
{
|
||||
|
@ -446,7 +446,7 @@ int MODULE_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
|||
if( evt->IsMotion() )
|
||||
{
|
||||
pastedModule->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
preview.ViewUpdate();
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
|
||||
else if( evt->Category() == TC_COMMAND )
|
||||
|
@ -454,12 +454,12 @@ int MODULE_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
|||
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
|
||||
{
|
||||
pastedModule->Rotate( pastedModule->GetPosition(), m_frame->GetRotationAngle() );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
||||
{
|
||||
pastedModule->Flip( pastedModule->GetPosition() );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_view->Update( &preview );
|
||||
}
|
||||
else if( evt->IsCancel() || evt->IsActivate() )
|
||||
{
|
||||
|
@ -542,11 +542,11 @@ int MODULE_TOOLS::ModuleTextOutlines( const TOOL_EVENT& aEvent )
|
|||
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item ->Next() )
|
||||
{
|
||||
if( item->Type() == PCB_MODULE_TEXT_T )
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
getView()->Update( item, KIGFX::GEOMETRY );
|
||||
}
|
||||
|
||||
module->Reference().ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
module->Value().ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
getView()->Update( &module->Reference(), KIGFX::GEOMETRY );
|
||||
getView()->Update( &module->Value(), KIGFX::GEOMETRY );
|
||||
}
|
||||
|
||||
m_frame->GetGalCanvas()->Refresh();
|
||||
|
@ -576,7 +576,7 @@ int MODULE_TOOLS::ModuleEdgeOutlines( const TOOL_EVENT& aEvent )
|
|||
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item ->Next() )
|
||||
{
|
||||
if( item->Type() == PCB_MODULE_EDGE_T )
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
getView()->Update( item, KIGFX::GEOMETRY );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
|
|||
|
||||
PCB_EDITOR_CONTROL::~PCB_EDITOR_CONTROL()
|
||||
{
|
||||
getView()->Remove( m_placeOrigin );
|
||||
|
||||
delete m_placeOrigin;
|
||||
delete m_zoneMenu;
|
||||
delete m_lockMenu;
|
||||
|
@ -270,12 +272,12 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
|
|||
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
|
||||
{
|
||||
module->Rotate( module->GetPosition(), m_frame->GetRotationAngle() );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->Update( &preview );
|
||||
}
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
||||
{
|
||||
module->Flip( module->GetPosition() );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->Update( &preview );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +324,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
|
|||
else if( module && evt->IsMotion() )
|
||||
{
|
||||
module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->Update( &preview );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,7 +435,7 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
|
|||
else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) )
|
||||
{
|
||||
target->SetWidth( target->GetWidth() + WIDTH_STEP );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->Update( &preview );
|
||||
}
|
||||
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) )
|
||||
|
@ -443,7 +445,7 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
|
|||
if( width > WIDTH_STEP )
|
||||
{
|
||||
target->SetWidth( width - WIDTH_STEP );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->Update( &preview );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,7 +468,7 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
|
|||
else if( evt->IsMotion() )
|
||||
{
|
||||
target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->Update( &preview );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,7 +498,7 @@ int PCB_EDITOR_CONTROL::ZoneFill( const TOOL_EVENT& aEvent )
|
|||
m_frame->Fill_Zone( zone );
|
||||
zone->SetIsFilled( true );
|
||||
ratsnest->Update( zone );
|
||||
zone->ViewUpdate();
|
||||
getView()->Update( zone );
|
||||
}
|
||||
|
||||
ratsnest->Recalculate();
|
||||
|
@ -516,7 +518,7 @@ int PCB_EDITOR_CONTROL::ZoneFillAll( const TOOL_EVENT& aEvent )
|
|||
m_frame->Fill_Zone( zone );
|
||||
zone->SetIsFilled( true );
|
||||
ratsnest->Update( zone );
|
||||
zone->ViewUpdate();
|
||||
getView()->Update( zone );
|
||||
}
|
||||
|
||||
ratsnest->Recalculate();
|
||||
|
@ -540,7 +542,7 @@ int PCB_EDITOR_CONTROL::ZoneUnfill( const TOOL_EVENT& aEvent )
|
|||
zone->SetIsFilled( false );
|
||||
zone->ClearFilledPolysList();
|
||||
ratsnest->Update( zone );
|
||||
zone->ViewUpdate();
|
||||
getView()->Update( zone );
|
||||
}
|
||||
|
||||
ratsnest->Recalculate();
|
||||
|
@ -560,7 +562,7 @@ int PCB_EDITOR_CONTROL::ZoneUnfillAll( const TOOL_EVENT& aEvent )
|
|||
zone->SetIsFilled( false );
|
||||
zone->ClearFilledPolysList();
|
||||
ratsnest->Update( zone );
|
||||
zone->ViewUpdate();
|
||||
getView()->Update( zone );
|
||||
}
|
||||
|
||||
ratsnest->Recalculate();
|
||||
|
|
|
@ -71,6 +71,7 @@ PCBNEW_CONTROL::PCBNEW_CONTROL() :
|
|||
|
||||
PCBNEW_CONTROL::~PCBNEW_CONTROL()
|
||||
{
|
||||
getView()->Remove( m_gridOrigin );
|
||||
delete m_gridOrigin;
|
||||
}
|
||||
|
||||
|
@ -203,10 +204,8 @@ int PCBNEW_CONTROL::ZoomPreset( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KIGFX::PCB_PAINTER* painter =
|
||||
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
|
||||
auto settings = painter->GetSettings();
|
||||
|
||||
// Apply new display options to the GAL canvas
|
||||
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
|
||||
|
@ -216,7 +215,7 @@ int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
|
|||
for( TRACK* track = getModel<BOARD>()->m_Track; track; track = track->Next() )
|
||||
{
|
||||
if( track->Type() == PCB_TRACE_T )
|
||||
track->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
getView()->Update( track, KIGFX::GEOMETRY );
|
||||
}
|
||||
|
||||
m_frame->GetGalCanvas()->Refresh();
|
||||
|
@ -227,10 +226,9 @@ int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KIGFX::PCB_PAINTER* painter =
|
||||
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
|
||||
auto settings = painter->GetSettings();
|
||||
|
||||
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
|
||||
|
||||
// Apply new display options to the GAL canvas
|
||||
|
@ -240,7 +238,7 @@ int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent )
|
|||
for( MODULE* module = getModel<BOARD>()->m_Modules; module; module = module->Next() )
|
||||
{
|
||||
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
|
||||
pad->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
getView()->Update( pad, KIGFX::GEOMETRY );
|
||||
}
|
||||
|
||||
m_frame->GetGalCanvas()->Refresh();
|
||||
|
@ -251,10 +249,8 @@ int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KIGFX::PCB_PAINTER* painter =
|
||||
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
|
||||
auto settings = painter->GetSettings();
|
||||
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
|
||||
|
||||
// Apply new display options to the GAL canvas
|
||||
|
@ -263,8 +259,8 @@ int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( TRACK* track = getModel<BOARD>()->m_Track; track; track = track->Next() )
|
||||
{
|
||||
if( track->Type() == PCB_VIA_T )
|
||||
track->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
if( track->Type() == PCB_TRACE_T )
|
||||
getView()->Update( track, KIGFX::GEOMETRY );
|
||||
}
|
||||
|
||||
m_frame->GetGalCanvas()->Refresh();
|
||||
|
@ -275,10 +271,8 @@ int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KIGFX::PCB_PAINTER* painter =
|
||||
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
|
||||
auto settings = painter->GetSettings();
|
||||
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
|
||||
|
||||
// Apply new display options to the GAL canvas
|
||||
|
@ -295,7 +289,7 @@ int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
|
|||
|
||||
BOARD* board = getModel<BOARD>();
|
||||
for( int i = 0; i < board->GetAreaCount(); ++i )
|
||||
board->GetArea( i )->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
getView()->Update( board->GetArea( i ), KIGFX::GEOMETRY );
|
||||
|
||||
m_frame->GetGalCanvas()->Refresh();
|
||||
|
||||
|
@ -305,10 +299,8 @@ int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KIGFX::PCB_PAINTER* painter =
|
||||
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
|
||||
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
|
||||
auto settings = painter->GetSettings();
|
||||
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
|
||||
|
||||
displ_opts->m_ContrastModeDisplay = !displ_opts->m_ContrastModeDisplay;
|
||||
|
@ -404,10 +396,8 @@ int PCBNEW_CONTROL::LayerToggle( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KIGFX::PCB_PAINTER* painter =
|
||||
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
|
||||
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
|
||||
auto settings = painter->GetSettings();
|
||||
|
||||
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
|
||||
KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
|
||||
|
@ -425,10 +415,8 @@ int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KIGFX::PCB_PAINTER* painter =
|
||||
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
|
||||
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
|
||||
auto settings = painter->GetSettings();
|
||||
|
||||
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
|
||||
KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
|
||||
|
|
|
@ -226,11 +226,11 @@ void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( aEvent.IsMotion() )
|
||||
{
|
||||
point = m_editPoints->FindPoint( aEvent.Position() );
|
||||
point = m_editPoints->FindPoint( aEvent.Position(), getView() );
|
||||
}
|
||||
else if( aEvent.IsDrag( BUT_LEFT ) )
|
||||
{
|
||||
point = m_editPoints->FindPoint( aEvent.DragOrigin() );
|
||||
point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
|
||||
}
|
||||
|
||||
if( m_editedPoint != point )
|
||||
|
@ -620,7 +620,7 @@ void POINT_EDITOR::updatePoints()
|
|||
break;
|
||||
}
|
||||
|
||||
m_editPoints->ViewUpdate();
|
||||
getView()->Update( m_editPoints.get() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <gal/color4d.h>
|
||||
|
||||
#include <view/view.h>
|
||||
|
||||
using namespace KIGFX;
|
||||
|
||||
const BOX2I SELECTION_AREA::ViewBBox() const
|
||||
|
@ -46,14 +48,15 @@ void SELECTION_AREA::ViewGetLayers( int aLayers[], int& aCount ) const
|
|||
}
|
||||
|
||||
|
||||
void SELECTION_AREA::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
|
||||
void SELECTION_AREA::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
||||
{
|
||||
aGal->SetLineWidth( 1.0 );
|
||||
aGal->SetStrokeColor( COLOR4D( 1.0, 1.0, 0.4, 1.0 ) );
|
||||
aGal->SetFillColor( COLOR4D( 0.3, 0.3, 0.5, 0.3 ) );
|
||||
aGal->SetIsStroke( true );
|
||||
aGal->SetIsFill( true );
|
||||
aGal->DrawRectangle( m_origin, m_end );
|
||||
auto gal = aView->GetGAL();
|
||||
gal->SetLineWidth( 1.0 );
|
||||
gal->SetStrokeColor( COLOR4D( 1.0, 1.0, 0.4, 1.0 ) );
|
||||
gal->SetFillColor( COLOR4D( 0.3, 0.3, 0.5, 0.3 ) );
|
||||
gal->SetIsStroke( true );
|
||||
gal->SetIsFill( true );
|
||||
gal->DrawRectangle( m_origin, m_end );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
virtual const BOX2I ViewBBox() const override;
|
||||
|
||||
void ViewDraw( int aLayer, KIGFX::GAL* aGal ) const override;
|
||||
void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override;
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
|
|
|
@ -80,6 +80,8 @@ SELECTION_TOOL::SELECTION_TOOL() :
|
|||
|
||||
SELECTION_TOOL::~SELECTION_TOOL()
|
||||
{
|
||||
getView()->Remove( &m_selection );
|
||||
|
||||
delete m_contextMenu;
|
||||
delete m_selectMenu;
|
||||
delete m_zoomMenu;
|
||||
|
@ -448,14 +450,14 @@ bool SELECTION_TOOL::selectMultiple()
|
|||
// Start drawing a selection box
|
||||
area.SetOrigin( evt->DragOrigin() );
|
||||
area.SetEnd( evt->Position() );
|
||||
area.ViewSetVisible( true );
|
||||
area.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->SetVisible( &area, true );
|
||||
view->Update( &area );
|
||||
}
|
||||
|
||||
if( evt->IsMouseUp( BUT_LEFT ) )
|
||||
{
|
||||
// End drawing the selection box
|
||||
area.ViewSetVisible( false );
|
||||
view->SetVisible( &area, false );
|
||||
|
||||
// Mark items within the selection box as selected
|
||||
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
|
||||
|
@ -490,7 +492,6 @@ bool SELECTION_TOOL::selectMultiple()
|
|||
}
|
||||
|
||||
// Stop drawing the selection box
|
||||
area.ViewSetVisible( false );
|
||||
view->Remove( &area );
|
||||
m_multiple = false; // Multiple selection mode is inactive
|
||||
getViewControls()->SetAutoPan( false );
|
||||
|
@ -742,6 +743,7 @@ int SELECTION_TOOL::findMove( const TOOL_EVENT& aEvent )
|
|||
|
||||
void SELECTION_TOOL::clearSelection()
|
||||
{
|
||||
printf("ClearSelection\n");
|
||||
if( m_selection.Empty() )
|
||||
return;
|
||||
|
||||
|
@ -761,9 +763,11 @@ void SELECTION_TOOL::clearSelection()
|
|||
BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
|
||||
{
|
||||
BOARD_ITEM* current = NULL;
|
||||
std::shared_ptr<BRIGHT_BOX> brightBox;
|
||||
BRIGHT_BOX brightBox;
|
||||
CONTEXT_MENU menu;
|
||||
|
||||
getView()->Add( &brightBox );
|
||||
|
||||
int limit = std::min( 10, aCollector->GetCount() );
|
||||
|
||||
for( int i = 0; i < limit; ++i )
|
||||
|
@ -813,12 +817,17 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
|
|||
// Draw a mark to show which item is available to be selected
|
||||
if( current && current->IsBrightened() )
|
||||
{
|
||||
brightBox.reset( new BRIGHT_BOX( current ) );
|
||||
getView()->Add( brightBox.get() );
|
||||
// BRIGHT_BOX is removed from view on destruction
|
||||
brightBox.SetItem ( current );
|
||||
getView()->SetVisible( &brightBox, true );
|
||||
// getView()->Hide( &brightBox, false );
|
||||
getView()->Update( &brightBox, KIGFX::GEOMETRY );
|
||||
// getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
|
||||
}
|
||||
}
|
||||
|
||||
getView()->Remove( &brightBox );
|
||||
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
@ -916,7 +925,7 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const
|
|||
if( m_multiple && !m_editModules )
|
||||
return false;
|
||||
|
||||
return aItem->ViewIsVisible() && board()->IsLayerVisible( aItem->GetLayer() );
|
||||
return view()->IsVisible( aItem ) && board()->IsLayerVisible( aItem->GetLayer() );
|
||||
|
||||
case PCB_MODULE_EDGE_T:
|
||||
case PCB_PAD_T:
|
||||
|
@ -1004,17 +1013,19 @@ void SELECTION_TOOL::unselect( BOARD_ITEM* aItem )
|
|||
void SELECTION_TOOL::selectVisually( BOARD_ITEM* aItem ) const
|
||||
{
|
||||
// Hide the original item, so it is shown only on overlay
|
||||
aItem->ViewHide( true );
|
||||
aItem->SetSelected();
|
||||
view()->Hide( aItem, true );
|
||||
view()->Update( aItem, KIGFX::GEOMETRY );
|
||||
|
||||
// Modules are treated in a special way - when they are selected, we have to
|
||||
// unselect all the parts that make the module, not the module itself
|
||||
|
||||
if( aItem->Type() == PCB_MODULE_T )
|
||||
{
|
||||
static_cast<MODULE*>( aItem )->RunOnChildren( [] ( BOARD_ITEM *item ) {
|
||||
item->ViewHide( true );
|
||||
static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM *item ) {
|
||||
item->SetSelected();
|
||||
view()->Hide( item, true );
|
||||
view()->Update( item, KIGFX::GEOMETRY );
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1022,22 +1033,31 @@ void SELECTION_TOOL::selectVisually( BOARD_ITEM* aItem ) const
|
|||
|
||||
void SELECTION_TOOL::unselectVisually( BOARD_ITEM* aItem ) const
|
||||
{
|
||||
printf("UnselectVisually %p\n", aItem);
|
||||
// Restore original item visibility
|
||||
aItem->ViewHide( false );
|
||||
aItem->ClearSelected();
|
||||
aItem->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view()->Hide( aItem, false );
|
||||
view()->Update( aItem, KIGFX::ALL );
|
||||
|
||||
printf("%d %d %d\n",
|
||||
!!aItem->IsSelected(),
|
||||
!!aItem->IsHighlighted(),
|
||||
!!aItem->IsBrightened() );
|
||||
|
||||
// Modules are treated in a special way - when they are selected, we have to
|
||||
// unselect all the parts that make the module, not the module itself
|
||||
|
||||
if( aItem->Type() == PCB_MODULE_T )
|
||||
{
|
||||
static_cast<MODULE*>( aItem )->RunOnChildren( [] ( BOARD_ITEM *item ) {
|
||||
item->ViewHide( false );
|
||||
static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM *item ) {
|
||||
item->ClearSelected();
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view()->Hide( item, false );
|
||||
view()->Update( item, KIGFX::ALL );
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//view()->RecacheAllItems();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <wxPcbStruct.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <view/view.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
#include "zoom_tool.h"
|
||||
|
@ -90,13 +91,13 @@ bool ZOOM_TOOL::selectRegion()
|
|||
{
|
||||
area.SetOrigin( evt->DragOrigin() );
|
||||
area.SetEnd( evt->Position() );
|
||||
area.ViewSetVisible( true );
|
||||
area.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->SetVisible( &area, true );
|
||||
view->Update( &area, KIGFX::GEOMETRY );
|
||||
}
|
||||
|
||||
if( evt->IsMouseUp( BUT_LEFT ) )
|
||||
{
|
||||
area.ViewSetVisible( false );
|
||||
view->SetVisible( &area, false );
|
||||
auto selectionBox = area.ViewBBox();
|
||||
|
||||
VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
|
||||
|
@ -118,7 +119,7 @@ bool ZOOM_TOOL::selectRegion()
|
|||
}
|
||||
}
|
||||
|
||||
area.ViewSetVisible( false );
|
||||
view->SetVisible( &area, false );
|
||||
view->Remove( &area );
|
||||
getViewControls()->SetAutoPan( false );
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ using namespace std::placeholders;
|
|||
#include <tools/selection_tool.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
#include <view/view.h>
|
||||
|
||||
/* Functions to undo and redo edit commands.
|
||||
* commands to undo are stored in CurrentScreen->m_UndoList
|
||||
* commands to redo are stored in CurrentScreen->m_RedoList
|
||||
|
@ -482,7 +484,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
|
|||
view->Add( item );
|
||||
ratsnest->Add( item );
|
||||
item->ClearFlags();
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS );
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -497,7 +499,6 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
|
|||
}
|
||||
|
||||
view->Remove( item );
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
break;
|
||||
|
||||
case UR_DELETED: /* deleted items are put in List, as new items */
|
||||
|
@ -511,33 +512,32 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
|
|||
}
|
||||
|
||||
view->Add( item );
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
build_item_list = true;
|
||||
break;
|
||||
|
||||
case UR_MOVED:
|
||||
item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->Update ( item, KIGFX::GEOMETRY );
|
||||
ratsnest->Update( item );
|
||||
break;
|
||||
|
||||
case UR_ROTATED:
|
||||
item->Rotate( aList->m_TransformPoint,
|
||||
aRedoCommand ? m_rotationAngle : -m_rotationAngle );
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->Update ( item, KIGFX::GEOMETRY );
|
||||
ratsnest->Update( item );
|
||||
break;
|
||||
|
||||
case UR_ROTATED_CLOCKWISE:
|
||||
item->Rotate( aList->m_TransformPoint,
|
||||
aRedoCommand ? -m_rotationAngle : m_rotationAngle );
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
view->Update ( item, KIGFX::GEOMETRY );
|
||||
ratsnest->Update( item );
|
||||
break;
|
||||
|
||||
case UR_FLIPPED:
|
||||
item->Flip( aList->m_TransformPoint );
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS );
|
||||
view->Update ( item, KIGFX::LAYERS );
|
||||
ratsnest->Update( item );
|
||||
break;
|
||||
|
||||
|
@ -663,4 +663,3 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
|
|||
delete curr_cmd; // Delete command
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#include <pcbnew.h>
|
||||
#include <zones.h>
|
||||
|
||||
#include <view/view.h>
|
||||
|
||||
#define FORMAT_STRING _( "Filling zone %d out of %d (net %s)..." )
|
||||
|
||||
|
||||
|
@ -115,7 +117,7 @@ int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* aZone )
|
|||
wxBusyCursor dummy; // Shows an hourglass cursor (removed by its destructor)
|
||||
|
||||
aZone->BuildFilledSolidAreasPolygons( GetBoard() );
|
||||
aZone->ViewUpdate( KIGFX::VIEW_ITEM::ALL );
|
||||
GetGalCanvas()->GetView()->Update( aZone, KIGFX::ALL );
|
||||
GetBoard()->GetRatsnest()->Update( aZone );
|
||||
|
||||
OnModify();
|
||||
|
|
Loading…
Reference in New Issue