void TransitionTerrain::addTransitionOnMap(Tiled::Map &tiledMap) { const unsigned int w=tiledMap.width(); const unsigned int h=tiledMap.height(); //list the layer name to parse QHash<QString,LoadMap::Terrain> transition; QStringList transitionList; for(int height=0;height<5;height++) for(int moisure=0;moisure<6;moisure++) { LoadMap::Terrain &terrain=LoadMap::terrainList[height][moisure]; if(!terrain.tmp_layerString.isEmpty()) { if(!transitionList.contains(terrain.terrainName)) { transition[terrain.terrainName]=terrain; transitionList << terrain.terrainName; } } } { Tiled::TileLayer * transitionLayerMask=LoadMap::searchTileLayerByName(tiledMap,"OnGrass"); Tiled::TileLayer * const colisionLayerMask=LoadMap::searchTileLayerByName(tiledMap,"Collisions"); unsigned int index=0; while(index<(unsigned int)transitionList.size()) { const LoadMap::Terrain &terrain=transition.value(transitionList.at(index)); Tiled::TileLayer * terrainLayer=terrain.tileLayer; Tiled::TileLayer * transitionLayer=NULL; uint16_t XORop; if(terrain.outsideBorder) { transitionLayer=terrainLayer; XORop=0x01ff; } else { const unsigned int index=LoadMap::searchTileIndexByName(tiledMap,terrain.tmp_layerString); Tiled::Layer * rawLayer=tiledMap.layerAt(index+1); if(!rawLayer->isTileLayer()) { std::cerr << "Next layer after " << terrain.tmp_layerString.toStdString() << "is not tile layer (abort)" << std::endl; abort(); } transitionLayer=static_cast<Tiled::TileLayer *>(rawLayer); transitionLayerMask=transitionLayer; XORop=0x0000; } unsigned int y=0; while(y<h) { unsigned int x=0; while(x<w) { const bool innerBool=!XORop && (terrainLayer->cellAt(x,y).tile==terrain.tile); const unsigned int &bitMask=x+y*w; const bool outerBool=XORop && terrainLayer->cellAt(x,y).tile!=terrain.tile && !(MapBrush::mapMask[bitMask/8] & (1<<(7-bitMask%8))); if( //inner innerBool || //outer outerBool ) { //check the near tile and determine what transition use const uint16_t to_type_match=layerMask(terrainLayer,x,y,terrain.tile,XORop); if(to_type_match>512) abort(); if(to_type_match!=0 && to_type_match!=16) { unsigned int indexTile=0; if(XORop) { const uint16_t to_type_match_collision=layerMask(colisionLayerMask,x,y,NULL,false); const bool onGrass=transitionLayerMask->cellAt(x,y).tile!=NULL; bool forceDisplay=false; //outer border if(to_type_match&2) { if(to_type_match&8) { indexTile=8; } else if(to_type_match&32) { indexTile=9; } else { indexTile=5; if(to_type_match_collision&8 && to_type_match_collision&32) forceDisplay=true; } } else if(to_type_match&128) { if(to_type_match&8) { indexTile=11; } else if(to_type_match&32) { indexTile=10; } else { indexTile=1; if(to_type_match_collision&8 && to_type_match_collision&32) forceDisplay=true; } } else if(to_type_match&8) { indexTile=3; if(to_type_match_collision&2 && to_type_match_collision&128) forceDisplay=true; } else if(to_type_match&32) { indexTile=7; if(to_type_match_collision&2 && to_type_match_collision&128) forceDisplay=true; } else if(to_type_match&256) { indexTile=0; if(!(to_type_match_collision&256)) { if(to_type_match_collision&32 && to_type_match_collision&128) forceDisplay=true; if(to_type_match_collision&8 && to_type_match_collision&32) forceDisplay=true; if(to_type_match_collision&2 && to_type_match_collision&128) forceDisplay=true; } } else if(to_type_match&64) { indexTile=2; if(!(to_type_match_collision&64)) { if(to_type_match_collision&8 && to_type_match_collision&128) forceDisplay=true; if(to_type_match_collision&8 && to_type_match_collision&32) forceDisplay=true; if(to_type_match_collision&2 && to_type_match_collision&128) forceDisplay=true; } } else if(to_type_match&1) { indexTile=4; if(!(to_type_match_collision&1)) { if(to_type_match_collision&2 && to_type_match_collision&8) forceDisplay=true; if(to_type_match_collision&8 && to_type_match_collision&32) forceDisplay=true; if(to_type_match_collision&2 && to_type_match_collision&128) forceDisplay=true; } } else if(to_type_match&4) { indexTile=6; if(!(to_type_match_collision&4)) { if(to_type_match_collision&2 && to_type_match_collision&32) forceDisplay=true; if(to_type_match_collision&8 && to_type_match_collision&32) forceDisplay=true; if(to_type_match_collision&2 && to_type_match_collision&128) forceDisplay=true; } } if(!onGrass || forceDisplay) { Tiled::Cell cell; cell.tile=terrain.transition_tile.at(indexTile); cell.flippedHorizontally=false; cell.flippedVertically=false; cell.flippedAntiDiagonally=false; transitionLayer->setCell(x,y,cell); } } else { //inner border if(to_type_match&2) { if(to_type_match&8) indexTile=0; else if(to_type_match&32) indexTile=2; else indexTile=1; } else if(to_type_match&128) { if(to_type_match&8) indexTile=6; else if(to_type_match&32) indexTile=4; else indexTile=5; } else if(to_type_match&8) indexTile=7; else if(to_type_match&32) indexTile=3; else if(to_type_match&256) indexTile=8; else if(to_type_match&64) indexTile=9; else if(to_type_match&1) indexTile=10; else if(to_type_match&4) indexTile=11; Tiled::Cell cell; cell.tile=terrain.transition_tile.at(indexTile); cell.flippedHorizontally=false; cell.flippedVertically=false; cell.flippedAntiDiagonally=false; transitionLayer->setCell(x,y,cell); } } } x++; } y++; } index++; } } }
void defiFill::print(FILE* f) const { int i, j; struct defiPoints points; if (hasLayer()) fprintf(f, "- LAYER %s", layerName()); if (layerMask()) fprintf(f, " + Mask %d", layerMask()); if (hasLayerOpc()) fprintf(f, " + OPC"); fprintf(f, "\n"); for (i = 0; i < numRectangles(); i++) { fprintf(f, " RECT %d %d %d %d\n", xl(i), yl(i), xh(i), yh(i)); } for (i = 0; i < numPolygons(); i++) { fprintf(f, " POLYGON "); points = getPolygon(i); for (j = 0; j < points.numPoints; j++) fprintf(f, "%d %d ", points.x[j], points.y[j]); fprintf(f, "\n"); } fprintf(f,"\n"); if (hasVia()) fprintf(f, "- VIA %s", viaName()); if (viaTopMask() || viaCutMask() || viaBottomMask()) { fprintf(f, " + MASK %d", viaTopMask(), viaCutMask(), viaBottomMask()); } if (hasViaOpc()) fprintf(f, " + OPC"); fprintf(f, "\n"); for (i = 0; i < numViaPts(); i++) { fprintf(f, " "); points = getViaPts(i); for (j = 0; j < points.numPoints; j++) fprintf(f, "%d %d ", points.x[j], points.y[j]); fprintf(f, "\n"); } fprintf(f,"\n"); }
void CStandardApertureViewStatic::setStandardApertureShape(CStandardApertureShape& standardApertureShape) { //m_standardApertureShape = &standardApertureShape; delete m_standardApertureShape; m_standardApertureShape = CStandardApertureShape::create(standardApertureShape); if (m_camCadFrame != NULL) { CCEtoODBDoc* doc = getCamCadDoc(); CCamCadDocGraph camCadDocGraph(doc); CCamCadLayerMask layerMask(*m_camCadDatabase); layerMask.addAll(); m_camCadDatabase->deleteEntitiesOnLayers(layerMask); LayerStruct* layer = m_camCadDatabase->getDefinedLayer(QBrightStencilPad); int layerIndex = layer->getLayerIndex(); DataStruct* polyStruct = m_camCadDatabase->newPolyStruct(layerIndex,0,false,graphicClassNormal); m_standardApertureShape->makeValid(); m_standardApertureShape->getAperturePoly(m_camCadDatabase->getCamCadData(),m_camCadFrame->getPcbBlock().getDataList(),polyStruct); m_camCadFrame->getPcbBlock().getDataList().AddTail(polyStruct); calcScaling(); } }
// Place a dragged (or moved) track segment or via bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) { int errdrc; if( Track == NULL ) return false; int current_net_code = Track->GetNetCode(); // DRC control: if( g_Drc_On ) { errdrc = m_drc->Drc( Track, GetBoard()->m_Track ); if( errdrc == BAD_DRC ) return false; // Redraw the dragged segments for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { errdrc = m_drc->Drc( g_DragSegmentList[ii].m_Track, GetBoard()->m_Track ); if( errdrc == BAD_DRC ) return false; } } // DRC Ok: place track segments Track->ClearFlags(); Track->SetState( IN_EDIT, false ); // Draw dragged tracks for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { Track = g_DragSegmentList[ii].m_Track; Track->SetState( IN_EDIT, false ); Track->ClearFlags(); /* Test the connections modified by the move * (only pad connection must be tested, track connection will be * tested by TestNetConnection() ) */ LSET layerMask( Track->GetLayer() ); Track->start = GetBoard()->GetPadFast( Track->GetStart(), layerMask ); if( Track->start ) Track->SetState( BEGIN_ONPAD, true ); else Track->SetState( BEGIN_ONPAD, false ); Track->end = GetBoard()->GetPadFast( Track->GetEnd(), layerMask ); if( Track->end ) Track->SetState( END_ONPAD, true ); else Track->SetState( END_ONPAD, false ); } EraseDragList(); SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED ); s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items GetBoard()->PopHighLight(); OnModify(); m_canvas->SetMouseCapture( NULL, NULL ); if( current_net_code > 0 ) TestNetConnection( DC, current_net_code ); m_canvas->Refresh(); return true; }
/* * This function starts a new track segment. * If a new track segment is in progress, ends this current new segment, * and created a new one. */ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) { TRACK* trackOnStartPoint = NULL; LSET layerMask( GetScreen()->m_Active_Layer ); wxPoint pos = GetCrossHairPosition(); BOARD_CONNECTED_ITEM* lockPoint; if( aTrack == NULL ) // Starting a new track segment { m_canvas->SetMouseCapture( ShowNewTrackWhenMovingCursor, Abort_Create_Track ); // Prepare the undo command info s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but... GetBoard()->PushHighLight(); // erase old highlight if( GetBoard()->IsHighLightNetON() ) HighLight( aDC ); g_CurrentTrackList.PushBack( new TRACK( GetBoard() ) ); g_CurrentTrackSegment->SetFlags( IS_NEW ); GetBoard()->SetHighLightNet( 0 ); // Search for a starting point of the new track, a track or pad lockPoint = GetBoard()->GetLockPoint( pos, layerMask ); D_PAD* pad = NULL; if( lockPoint ) // An item (pad or track) is found { if( lockPoint->Type() == PCB_PAD_T ) { pad = (D_PAD*) lockPoint; // A pad is found: put the starting point on pad center pos = pad->GetPosition(); GetBoard()->SetHighLightNet( pad->GetNetCode() ); } else // A track segment is found { trackOnStartPoint = (TRACK*) lockPoint; GetBoard()->SetHighLightNet( trackOnStartPoint->GetNetCode() ); GetBoard()->CreateLockPoint( pos, trackOnStartPoint, &s_ItemsListPicker ); } } else { // Not a starting point, but a filled zone area can exist. This is also a // good starting point. ZONE_CONTAINER* zone; zone = GetBoard()->HitTestForAnyFilledArea( pos, GetScreen()-> m_Active_Layer, GetScreen()-> m_Active_Layer, -1 ); if( zone ) GetBoard()->SetHighLightNet( zone->GetNetCode() ); } DBG( g_CurrentTrackList.VerifyListIntegrity() ); BuildAirWiresTargetsList( lockPoint, wxPoint( 0, 0 ), true ); DBG( g_CurrentTrackList.VerifyListIntegrity() ); GetBoard()->HighLightON(); GetBoard()->DrawHighLight( m_canvas, aDC, GetBoard()->GetHighLightNetCode() ); // Display info about track Net class, and init track and vias sizes: g_CurrentTrackSegment->SetNetCode( GetBoard()->GetHighLightNetCode() ); SetCurrentNetClass( g_CurrentTrackSegment->GetNetClassName() ); g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); g_CurrentTrackSegment->SetWidth( GetDesignSettings().GetCurrentTrackWidth() ); if( GetDesignSettings().m_UseConnectedTrackWidth ) { if( trackOnStartPoint && trackOnStartPoint->Type() == PCB_TRACE_T ) g_CurrentTrackSegment->SetWidth( trackOnStartPoint->GetWidth()); } g_CurrentTrackSegment->SetStart( pos ); g_CurrentTrackSegment->SetEnd( pos ); if( pad ) { g_CurrentTrackSegment->m_PadsConnected.push_back( pad ); // Useful to display track length, if the pad has a die length: g_CurrentTrackSegment->SetState( BEGIN_ONPAD, true ); g_CurrentTrackSegment->start = pad; } if( g_TwoSegmentTrackBuild ) { // Create 2nd segment g_CurrentTrackList.PushBack( (TRACK*)g_CurrentTrackSegment->Clone() ); DBG( g_CurrentTrackList.VerifyListIntegrity(); ); g_CurrentTrackSegment->start = g_FirstTrackSegment; g_FirstTrackSegment->end = g_CurrentTrackSegment; g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, false ); }