Skip to content

Commit

Permalink
Partial clearing now works, better turnaround on tabs. #118
Browse files Browse the repository at this point in the history
  • Loading branch information
travisgoodspeed committed Aug 4, 2024
1 parent 6281c85 commit 4511863
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fiilenames. GUI can now export a set of solved results with
File/Export/SolverSetBytes. Clearer selection rectangle. `R` and `C`
will now draw the correct line type when the user confuses them. `^H`
now sets the home position. Zooming and movement keys now work in the
second view. Perfectly duplicates lines are now culled during DRC by
second view. Perfectly duplicate lines are now culled during DRC by
the `V` key. Rows and columns are now stored as sorted lists intead
of sets. Rows and columns are now in a consistent order in the file
export. Performance boosts in bit marking, background bit marking
Expand Down
48 changes: 39 additions & 9 deletions maskromtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,8 @@ void MaskRomTool::nextMode(){
ui->actionBits->setChecked(bitsVisible);
ui->actionViolations->setChecked(bitsVisible);

//Mark the bits when bringing them back.
if(bitsVisible) markBits();
//Redraw the bits when bringing them back.
if(bitsVisible) markBits(false);
}

void MaskRomTool::on_actionPhotograph_triggered(){
Expand Down Expand Up @@ -1437,8 +1437,7 @@ void MaskRomTool::markLine(RomLineItem* line){
}

line->marked=true;

updateCrosshairAngle(line);
alignmentdirty=true;
}


Expand Down Expand Up @@ -1498,7 +1497,7 @@ void MaskRomTool::moveList(QList<QGraphicsItem*> list, QPointF offset){
*/


if(bitsVisible) clearBits(false);
clearBits(false);

//We ditch the bits and move all of their lines.
foreach(QGraphicsItem* selecteditem, list){
Expand All @@ -1519,6 +1518,17 @@ void MaskRomTool::moveList(QList<QGraphicsItem*> list, QPointF offset){
}
}

static bool colthroughrect(QLineF line, QRectF rect){
//Column through visible rectangle.
if( (line.x1() < rect.right() && line.x1() > rect.left())
|| (line.x2() < rect.right() && line.x2() > rect.left())
){

return true;
}
return false;
}

//Mark up all of the bits where rows and columns collide.
bool MaskRomTool::markBits(bool full){
bool bitswerevisible=bitsVisible;
Expand All @@ -1535,8 +1545,25 @@ bool MaskRomTool::markBits(bool full){
setLinesVisible(true);

setBitsVisible(false);
//Grab all those that are visible first.
auto rect=view->mapToScene(view->viewport()->rect()).boundingRect();
auto secondrect=second.view->mapToScene(second.view->viewport()->rect()).boundingRect();
if(!second.isVisible()) secondrect=rect;

//Mark the visible lines immediately.
if(!full){
foreach (RomLineItem* line, cols){

if(!line->marked
&& ( colthroughrect(line->globalline(),rect) || colthroughrect(line->globalline(),secondrect) )
){
markLine(line);
count++;
}
}
}

//Mark every line collision.
//Mark every line collision, but if not full, just one per pass.
foreach (RomLineItem* line, cols){
if(!line->marked && count++>50 && !full){
//Show the bits if--and only if--we've set that style.
Expand Down Expand Up @@ -1566,6 +1593,8 @@ bool MaskRomTool::markBits(bool full){
}


//Maximum number of bits that we might clear in one frame.
#define BITCLEARINGLIMIT 5000

//Mark up all of the bits where rows and columns collide.
void MaskRomTool::clearBits(bool full){
Expand All @@ -1590,12 +1619,13 @@ void MaskRomTool::clearBits(bool full){
foreach(QGraphicsItem* item,
//view->items(view->sceneRect().toRect())){
bits){
if(rect.contains(item->pos()) || secondrect.contains(item->pos())){
if( (rect.contains(item->pos()) || secondrect.contains(item->pos()))
&& count++<BITCLEARINGLIMIT
){
scene->removeItem(item);
delete item;
bits.removeOne(item);
bitcount--;
count++;
}
}
//Grab some more opportunistically.
Expand All @@ -1606,7 +1636,7 @@ void MaskRomTool::clearBits(bool full){
if(!full)
//For partial work, we need to remove the items.
bits.removeOne(item);
if(!full && count++>10000){
if(!full && count++>BITCLEARINGLIMIT){
//We'll finish this off later.
return;
}
Expand Down

0 comments on commit 4511863

Please sign in to comment.