IRGraph *graph = docManager->GetIRGraph();
int nodeNum = graph->GetNodeNum();
int squareN = maxLevel + 1;
double x1 = 0.0;
double y1 = 0.0;
double x2 = 1.0;
double y2 = 1.0;
double w = (x2 - x1) / (double)squareN;
double h = y2 - y1;
int *nodeOrders = new int [nodeNum];
CalNodeOrder(nodeOrders);
double *posX = new double [nodeNum];
double *posY = new double [nodeNum];
CalDiagramSquareNodePos(w * 0.96, h, posX, posY);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
int level, i, member, colorIdx, len, nodeId;
// bool isCore;
double squareX, squareY;
float alpha;
// squareY = y1 + h * 0.05;
squareY = y1;
for (level=0; level<=maxLevel; level++)
{
// squareX = x1 + w * level + w * 0.05;
squareX = x1 + w * level + w * 0.02;
// Draw nodeNum nodes
for (i=0; i<nodeNum; i++)
{
nodeId = nodeOrders[i];
if (nodeId == -1)
continue;
member = graph->GetNodeMembership(nodeId);
// isCore = graph->IsClusterCore(nodeId);
len = graph->GetDistToFocus(nodeId, this->focusKey);
if ((level < maxLevel && len <= level) || (level == maxLevel && len >= level))
{
// glPointSize((float)(nodeSize*(this->GetIRGraph()->GetNodeCentrality(nodeId))));
glPointSize(graph->IsNodeSelected(nodeId) ? (float)(nodeSize + distortionFactor) : (float)nodeSize);
alpha = graph->IsNodeSelected(nodeId) ? 1.0f : 0.5f;
}
else
{
glPointSize(1.f);
alpha = 0.f;
}
glBegin(GL_POINTS);
colorIdx = member % IRGPixelDrawer::colorNum;
glColor4f(qualitativeColorTable[colorIdx][0]/255.f, qualitativeColorTable[colorIdx][1]/255.f, qualitativeColorTable[colorIdx][2]/255.f, alpha);
glVertex2d(squareX+posX[i], squareY+posY[i]);
glEnd();
}
// Draw a boundary rectangle
colorIdx = 9;
alpha = 1.0f - 0.8f/(float)maxLevel*(float)level;
glColor4f(qualitativeColorTable[colorIdx][0]/255.f, qualitativeColorTable[colorIdx][1]/255.f, qualitativeColorTable[colorIdx][2]/255.f, alpha);
glBegin(GL_LINE_LOOP);
glVertex2d(squareX, squareY);
glVertex2d(squareX + w * 0.96, squareY);
glVertex2d(squareX + w * 0.96, squareY + h);
glVertex2d(squareX, squareY + h);
glEnd();
}
glDisable(GL_BLEND);
delete [] nodeOrders;
delete [] posX;
delete [] posY;
IRGraph *graph = docManager->GetIRGraph();
int nodeNum = graph->GetNodeNum();
int squareN = maxLevel + 1;
double x1 = 0.0;
double y1 = 0.0;
double x2 = 1.0;
double y2 = 1.0;
double w = (x2 - x1) / (double)squareN;
double h = y2 - y1;
int *nodeOrders = new int [nodeNum];
CalNodeOrder(nodeOrders);
double *posX = new double [nodeNum];
double *posY = new double [nodeNum];
CalDiagramSquareNodePos(w * 0.96, h, posX, posY);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
int level, i, member, colorIdx, len, nodeId;
// bool isCore;
double squareX, squareY;
float alpha;
// squareY = y1 + h * 0.05;
squareY = y1;
for (level=0; level<=maxLevel; level++)
{
// squareX = x1 + w * level + w * 0.05;
squareX = x1 + w * level + w * 0.02;
// Draw nodeNum nodes
for (i=0; i<nodeNum; i++)
{
nodeId = nodeOrders[i];
if (nodeId == -1)
continue;
member = graph->GetNodeMembership(nodeId);
// isCore = graph->IsClusterCore(nodeId);
len = graph->GetDistToFocus(nodeId, this->focusKey);
if ((level < maxLevel && len <= level) || (level == maxLevel && len >= level))
{
// glPointSize((float)(nodeSize*(this->GetIRGraph()->GetNodeCentrality(nodeId))));
glPointSize(graph->IsNodeSelected(nodeId) ? (float)(nodeSize + distortionFactor) : (float)nodeSize);
alpha = graph->IsNodeSelected(nodeId) ? 1.0f : 0.5f;
}
else
{
glPointSize(1.f);
alpha = 0.f;
}
glBegin(GL_POINTS);
colorIdx = member % IRGPixelDrawer::colorNum;
glColor4f(qualitativeColorTable[colorIdx][0]/255.f, qualitativeColorTable[colorIdx][1]/255.f, qualitativeColorTable[colorIdx][2]/255.f, alpha);
glVertex2d(squareX+posX[i], squareY+posY[i]);
glEnd();
}
// Draw a boundary rectangle
colorIdx = 9;
alpha = 1.0f - 0.8f/(float)maxLevel*(float)level;
glColor4f(qualitativeColorTable[colorIdx][0]/255.f, qualitativeColorTable[colorIdx][1]/255.f, qualitativeColorTable[colorIdx][2]/255.f, alpha);
glBegin(GL_LINE_LOOP);
glVertex2d(squareX, squareY);
glVertex2d(squareX + w * 0.96, squareY);
glVertex2d(squareX + w * 0.96, squareY + h);
glVertex2d(squareX, squareY + h);
glEnd();
}
glDisable(GL_BLEND);
delete [] nodeOrders;
delete [] posX;
delete [] posY;
To copy to clipboard, switch view to plain text mode
Bookmarks