PDA

View Full Version : QgraphicsviewItem edge selection



vishalkaushik
13th January 2015, 22:59
Hello all,

I have a specific implementation of Qgraphicsview , i have sevveral QgraphicsItem which I am calling DeviceForCrownList(attachment one shows DeviceForCrownList as per below code ) inside the circle (ellipse in red is basically drawn, but it is an item that has x,y , each rectangle(diesize) has dimensions like x=597,y=838. I have a 0,0 coordinates in circle.
(attached is the pic of the Qgraphicsview , how it looks like , now i have some logic in place which draws the boundry/edges but it miss few cases for example (attachment two).

I am putting the code below which is used to find out the edge devicelist , can somebody point me out what i am doing wrong becuase of which (attachment two is not coming right)?

diesizeX = breadth of each rectangle
diesizeY = length of each rectangle


struct WMDeviceForCrown
{
double x, y;
double wrtShotX, wrtShotY;
int crownShotRow, crownShotCol;
WaferDevice *WaferDevicePointer;
};
std::vector<WMDeviceForCrown> DeviceForCrownList;

PBProductData *productData = static_cast<PBProductData*>(fData->Getparent()->Getparent());
double offsetX = productData->fOffsetX;
double offsetY = productData->fOffsetY;
double diesizeX = productData->fDieSizeX;
double diesizeY = productData->fDieSizeY;


/* Collect all devices within the edges, assign them coordinates of their first probe */
if(useUserSelectionForSubplugs )
{
qDebug()<<"inside if crown";
bool noSubplugSelected = true;
for(int i=0; i<pendingRevision->fShotList.size(); i++)
{
for(int j=0; j<pendingRevision->fShotList[i].fSubPlugList.size(); j++)
{
if(pendingRevision->fShotList[i].fSubPlugList[j].fIsSelected)
{
noSubplugSelected = false;
PBSubPlug *subPlug = fCurrentRevision->fShotList[i].fSubPlugList[j].fSubPlug;
for(int k=0; k<pendingRevision->fShotList[i].fDeviceList.size(); k++)
{
WaferDevice *dev = &(pendingRevision->fShotList[i].fDeviceList[k]);
if(!dev->fIsOutsideEE)
{
if(std::find(fSelectedDeviceList.begin(), fSelectedDeviceList.end(), dev->fDevice) != fSelectedDeviceList.end())
{
//double probeX = dev->fDevice->fDevice->fMPFProbeList->fProbeList.front()->fProbe_pos_x;
//double probeY = dev->fDevice->fDevice->fMPFProbeList->fProbeList.front()->fProbe_pos_y;
double probeX = dev->fDevice->fDevice->fMPFProbeList->fProbeList.back()->fProbe_pos_x;
double probeY = dev->fDevice->fDevice->fMPFProbeList->fProbeList.back()->fProbe_pos_y;
double x = subPlug->fSubplgx;
double y = subPlug->fSubplgy;
double w = subPlug->fSubplgwidth;
double h = subPlug->fSubplgheight;
if((probeX > x-kDoubleTolerence) && (probeX < x+w+kDoubleTolerence) && (probeY > y-kDoubleTolerence) && (probeY < y+h+kDoubleTolerence))
{
WMDeviceForCrown devForCrown;
devForCrown.WaferDevicePointer = dev;

double shotX = pendingRevision->fShotList[i].fShot->fShotX;
double shotY = pendingRevision->fShotList[i].fShot->fShotY;

devForCrown.wrtShotX = probeX;
devForCrown.wrtShotY = probeY;

if(dev->fDevice->fDevice->fMPFProbeList->fProbeList.empty()) return;
double probe1X = shotX + devForCrown.wrtShotX;
double probe1Y = shotY + devForCrown.wrtShotY;

devForCrown.x = probe1X;
devForCrown.y = probe1Y;

devForCrown.crownShotRow= pendingRevision->fShotList[i].fShot->fShotRow;
devForCrown.crownShotCol= pendingRevision->fShotList[i].fShot->fShotCol;

DeviceForCrownList.push_back(devForCrown);
//break;
}
}
}
}
}
}
}

}
else
{
qDebug()<<"inside else crown";
for(int i=0; i<pendingRevision->fShotList.size(); i++)
{
if(pendingRevision->fShotList[i].fShot->fShotName == "Std shots")
{
for(int j=0; j<pendingRevision->fShotList[i].fDeviceList.size(); j++)
{
WaferDevice *dev = &(pendingRevision->fShotList[i].fDeviceList[j]);
if(std::find(fSelectedDeviceList.begin(), fSelectedDeviceList.end(), dev->fDevice)==fSelectedDeviceList.end()) continue;
if(!dev->fIsOutsideEE)
{


WMDeviceForCrown devForCrown;
devForCrown.WaferDevicePointer = dev;

double shotX = pendingRevision->fShotList[i].fShot->fShotX;
double shotY = pendingRevision->fShotList[i].fShot->fShotY;

devForCrown.wrtShotX = dev->fDevice->fDevice->fMPFProbeList->fProbeList.front()->fProbe_pos_x;
devForCrown.wrtShotY = dev->fDevice->fDevice->fMPFProbeList->fProbeList.front()->fProbe_pos_y;

if(dev->fDevice->fDevice->fMPFProbeList->fProbeList.empty()) return;
double probe1X = shotX + devForCrown.wrtShotX;
double probe1Y = shotY + devForCrown.wrtShotY;

devForCrown.x = probe1X;
devForCrown.y = probe1Y;
devForCrown.crownShotRow= pendingRevision->fShotList[i].fShot->fShotRow;
devForCrown.crownShotCol= pendingRevision->fShotList[i].fShot->fShotCol;

DeviceForCrownList.push_back(devForCrown);
// break;

}
}
}
}
}

if(DeviceForCrownList.empty())
{
QMessageBox::warning(this, tr("Edge Crown Creation"), tr("No valid devices for the crown operation. \nNo device from selected devices list could be found in the selected subplugs."));
return;
}

std::vector<WMDeviceForCrown> DeviceOnEdgeList;
/* Find if an device is an edge device */
int x = 0;
for(int i=0; i<DeviceForCrownList.size(); i++)
{
WMDeviceForCrown dev = DeviceForCrownList[i];
bool quadrantEmpty;


/* Axes as thick as diesize */
//int xOffset = int(dev.wrtShotX)%int(diesizeX);
double xOffset = fmod(dev.wrtShotX,diesizeX);
double xReminder = diesizeX - xOffset;
double xmin = dev.x - xOffset;
double xmax = dev.x + xReminder;


//int yOffset = int(dev.wrtShotY)%int(diesizeY);
//int yReminder = diesizeY - yOffset;
double yOffset= fmod(dev.wrtShotY,diesizeY);
double yReminder= diesizeY - yOffset;
double ymin = dev.y - yOffset;
double ymax = dev.y + yReminder;






/* First Quadrant */
quadrantEmpty = true;
for(int j=0; j<DeviceForCrownList.size(); j++)
{
if(i!=j)
{
if(DeviceForCrownList[j].x>xmax && DeviceForCrownList[j].y>ymax)
{
//if(!(DeviceForCrownList[j].y>ymax && DeviceForCrownList[j].x>=xmin ))
{
qDebug()<<"xmin::"<<xmin;
qDebug()<<"xmax::"<<xmax;
qDebug()<<"ymin::"<<ymin;
qDebug()<<"ymax::"<<ymax;
quadrantEmpty = false;
break;
}
}
/*else
{
DeviceOnEdgeList.push_back(dev);
continue;
}*/
}
}
if(quadrantEmpty)
{
DeviceOnEdgeList.push_back(dev);
continue;
}


///* Second Quadrant */
quadrantEmpty = true;
for(int j=0; j<DeviceForCrownList.size(); j++)
{
if(i!=j)
{
if(DeviceForCrownList[j].x<xmin && DeviceForCrownList[j].y>ymax /*|| ( DeviceForCrownList[j].y>ymin && DeviceForCrownList[j].x>xmin )*/)
{
quadrantEmpty = false;
break;
}
}
}
if(quadrantEmpty)
{
DeviceOnEdgeList.push_back(dev);
continue;
}


///* Third Quadrant */
quadrantEmpty = true;
for(int j=0; j<DeviceForCrownList.size(); j++)
{
if(i!=j)
{
if(DeviceForCrownList[j].x<xmin && DeviceForCrownList[j].y<ymin)
{
quadrantEmpty = false;
break;
}
}
}
if(quadrantEmpty)
{
DeviceOnEdgeList.push_back(dev);
continue;
}


//


/////* Fourth Quadrant */
quadrantEmpty = true;
for(int j=0; j<DeviceForCrownList.size(); j++)
{
if(i!=j)
{
if((DeviceForCrownList[j].x>xmax && DeviceForCrownList[j].y<ymin) /*|| (DeviceForCrownList[j].x<xmax && DeviceForCrownList[j].y>ymin)*/)
{
quadrantEmpty = false;
break;
}
}
}
if(quadrantEmpty)
{
DeviceOnEdgeList.push_back(dev);
continue;
}



// /* Along X-Positive Axis */
quadrantEmpty = true;
for(int j=0; j<DeviceForCrownList.size(); j++)
{
if(i!=j)
{
if(DeviceForCrownList[j].x>xmax && DeviceForCrownList[j].y>=ymin && DeviceForCrownList[j].y<=ymax)
{
quadrantEmpty = false;
break;
}
}
}
if(quadrantEmpty)
{
DeviceOnEdgeList.push_back(dev);
continue;
}


// ///* Along Y-Positive Axis */
quadrantEmpty = true;
for(int j=0; j<DeviceForCrownList.size(); j++)
{
if(i!=j)
{
if((DeviceForCrownList[j].y>ymax && DeviceForCrownList[j].x>=xmin && DeviceForCrownList[j].x<=xmax) /*&& (DeviceForCrownList[j].x>xmax && DeviceForCrownList[j].y>=ymin && DeviceForCrownList[j].y<=ymax)*/ )
{
quadrantEmpty = false;
break;
}
}
}
if(quadrantEmpty)
{
DeviceOnEdgeList.push_back(dev);
continue;
}

//



// ///* Along X-Negative Axis */
quadrantEmpty = true;
for(int j=0; j<DeviceForCrownList.size(); j++)
{
if(i!=j)
{
if(DeviceForCrownList[j].x<xmin && DeviceForCrownList[j].y>=ymin && DeviceForCrownList[j].y<=ymax)
{
quadrantEmpty = false;
break;
}
}
}
if(quadrantEmpty)
{
DeviceOnEdgeList.push_back(dev);
continue;
}

///////* Along Y-Negative Axis */
quadrantEmpty = true;
for(int j=0; j<DeviceForCrownList.size(); j++)
{
if(i!=j)
{
if(DeviceForCrownList[j].y<ymin && DeviceForCrownList[j].x>=xmin && DeviceForCrownList[j].x<=xmax)
{
quadrantEmpty = false;
break;
}
}
}
if(quadrantEmpty)
{
DeviceOnEdgeList.push_back(dev);
continue;
}



}