test1::test1() {
setupUi(this);
connect(pushButton, SIGNAL(clicked()), this, SLOT(process()));
connect(horizontalSlider, SIGNAL(valueChangedRight(int)), this, SLOT(processRight(int)));
}
void test1::processRight(int pos) {
if(pos>prev_pos) {
polyItemA->scale(pos,1);
}
prev_pos = pos;
}
void test1::process() {
std::string string2 = "test.scf.scf";
ReadSFF sff(string2);
//int bases = sff.getNum();
//QString Q_bases = QString::number(bases);
//textEdit->append("Number of Bases: " + Q_bases);
uint_4 samples = sff.returnNumSamples();
//QString Q_samples = QString::number(samples);
//textEdit->append("Number of Samples: " + Q_samples);
uint_2 *sA = new uint_2[samples];
uint_2 *sC = new uint_2[samples];
uint_2 *sG = new uint_2[samples];
uint_2 *sT = new uint_2[samples];
const int size = samples;
int xScale = 10;
int yScale = 10;
for (int i=0; i<size; i++) {
sA[i] = sff.returnSamples_A(i);
sC[i] = sff.returnSamples_C(i);
sG[i] = sff.returnSamples_G(i);
sT[i] = sff.returnSamples_T(i);
if ((sA[i]/yScale) > 125) {
polygonA <<
QPointF(xScale
*i,
-125);
} else {
polygonA <<
QPointF(xScale
*i,
-(sA
[i
]/yScale
));
}
if ((sC[i]/yScale) > 125) {
polygonC <<
QPointF(xScale
*i,
-125);
} else {
polygonC <<
QPointF(xScale
*i,
-(sC
[i
]/yScale
));
}
if ((sG[i]/yScale) > 125) {
polygonG <<
QPointF(xScale
*i,
-125);
} else {
polygonG <<
QPointF(xScale
*i,
-(sG
[i
]/yScale
));
}
if ((sT[i]/yScale) > 125) {
polygonT <<
QPointF(xScale
*i,
-125);
} else {
polygonT <<
QPointF(xScale
*i,
-(sT
[i
]/yScale
));
}
}
segPath.lineTo(0,-5);
segPath.closeSubpath();
pathA.addPolygon(polygonA);
pathC.addPolygon(polygonC);
pathG.addPolygon(polygonG);
pathT.addPolygon(polygonT);
// QGraphicsPathItem *segPath1 = scene->addPath(segPath, QPen(Qt::gray), QBrush(Qt::green, Qt::NoBrush));
// QGraphicsPathItem *segPath2 = scene->addPath(segPath, QPen(Qt::gray), QBrush(Qt::green, Qt::NoBrush));
polyItemA->setPos(0,0);
polyItemC->setPos(0,0);
polyItemG->setPos(0,0);
polyItemT->setPos(0,0);
// segPath1->setPos(0,-20);
// segPath2->setPos(10,-20);
//polyItemA->scale(xSlide,1);
graphicsView->setScene(scene);
}
test1::test1() {
setupUi(this);
connect(pushButton, SIGNAL(clicked()), this, SLOT(process()));
connect(horizontalSlider, SIGNAL(valueChangedRight(int)), this, SLOT(processRight(int)));
}
void test1::processRight(int pos) {
if(pos>prev_pos) {
polyItemA->scale(pos,1);
}
prev_pos = pos;
}
void test1::process() {
std::string string2 = "test.scf.scf";
ReadSFF sff(string2);
//int bases = sff.getNum();
//QString Q_bases = QString::number(bases);
//textEdit->append("Number of Bases: " + Q_bases);
uint_4 samples = sff.returnNumSamples();
//QString Q_samples = QString::number(samples);
//textEdit->append("Number of Samples: " + Q_samples);
uint_2 *sA = new uint_2[samples];
uint_2 *sC = new uint_2[samples];
uint_2 *sG = new uint_2[samples];
uint_2 *sT = new uint_2[samples];
const int size = samples;
QPolygonF polygonA;
QPolygonF polygonC;
QPolygonF polygonG;
QPolygonF polygonT;
int xScale = 10;
int yScale = 10;
for (int i=0; i<size; i++) {
sA[i] = sff.returnSamples_A(i);
sC[i] = sff.returnSamples_C(i);
sG[i] = sff.returnSamples_G(i);
sT[i] = sff.returnSamples_T(i);
if ((sA[i]/yScale) > 125) {
polygonA << QPointF(xScale*i,-125);
} else {
polygonA << QPointF(xScale*i,-(sA[i]/yScale));
}
if ((sC[i]/yScale) > 125) {
polygonC << QPointF(xScale*i,-125);
} else {
polygonC << QPointF(xScale*i,-(sC[i]/yScale));
}
if ((sG[i]/yScale) > 125) {
polygonG << QPointF(xScale*i,-125);
} else {
polygonG << QPointF(xScale*i,-(sG[i]/yScale));
}
if ((sT[i]/yScale) > 125) {
polygonT << QPointF(xScale*i,-125);
} else {
polygonT << QPointF(xScale*i,-(sT[i]/yScale));
}
}
QGraphicsScene *scene = new QGraphicsScene(0,0,samples*10,-115);
QPainterPath segPath;
segPath.lineTo(0,-5);
segPath.closeSubpath();
QPainterPath pathA;
QPainterPath pathC;
QPainterPath pathG;
QPainterPath pathT;
pathA.addPolygon(polygonA);
pathC.addPolygon(polygonC);
pathG.addPolygon(polygonG);
pathT.addPolygon(polygonT);
QGraphicsPathItem *polyItemA = scene->addPath(pathA, QPen(Qt::green), QBrush(Qt::green, Qt::NoBrush));
QGraphicsPathItem *polyItemC = scene->addPath(pathC, QPen(Qt::blue), QBrush(Qt::green, Qt::NoBrush));
QGraphicsPathItem *polyItemG = scene->addPath(pathG, QPen(Qt::black), QBrush(Qt::green, Qt::NoBrush));
QGraphicsPathItem *polyItemT = scene->addPath(pathT, QPen(Qt::red), QBrush(Qt::green, Qt::NoBrush));
// QGraphicsPathItem *segPath1 = scene->addPath(segPath, QPen(Qt::gray), QBrush(Qt::green, Qt::NoBrush));
// QGraphicsPathItem *segPath2 = scene->addPath(segPath, QPen(Qt::gray), QBrush(Qt::green, Qt::NoBrush));
polyItemA->setPos(0,0);
polyItemC->setPos(0,0);
polyItemG->setPos(0,0);
polyItemT->setPos(0,0);
// segPath1->setPos(0,-20);
// segPath2->setPos(10,-20);
//polyItemA->scale(xSlide,1);
graphicsView->setScene(scene);
}
To copy to clipboard, switch view to plain text mode
Bookmarks