コード例 #1
0
Task::ReportResult GTest_DNASequenceQualityValue::report() {

    GObject *obj = getContext<GObject>(this, objContextName);
    if(obj==NULL){
        stateInfo.setError(QString("wrong value: %1").arg(OBJ_ATTR));
        return ReportResult_Finished;
    }

    U2SequenceObject * mySequence = qobject_cast<U2SequenceObject*>(obj);
    if(mySequence==NULL){
        stateInfo.setError(QString("Can't cast to sequence from: %1").arg(obj->getGObjectName()));
        return ReportResult_Finished;
    }

    const DNAQuality& quality = mySequence->getQuality();
    if ( (pos < 0) || (pos > quality.qualCodes.count() - 1 )  ) {
        stateInfo.setError(QString("Quality scores doesn't have position %1").arg(pos));
        return ReportResult_Finished;
    }

    int val = quality.getValue(pos);

    if (val != expectedVal) {
        stateInfo.setError( QString("Quality score values do not match! The score is %1, expected %2").arg(val).arg(expectedVal));
        return ReportResult_Finished;
    }

    return ReportResult_Finished;
}
コード例 #2
0
Task::ReportResult GTest_DNASequenceQualityScores::report() {

    GObject *obj = getContext<GObject>(this, objContextName);
    if(obj==NULL){
        stateInfo.setError(QString("wrong value: %1").arg(OBJ_ATTR));
        return ReportResult_Finished;
    }

    U2SequenceObject * mySequence = qobject_cast<U2SequenceObject*>(obj);
    if(mySequence==NULL){
        stateInfo.setError(QString("Can't cast to sequence from: %1").arg(obj->getGObjectName()));
        return ReportResult_Finished;
    }

    const DNAQuality& quality = mySequence->getQuality();
    if (quality.isEmpty()) {
        stateInfo.setError("Sequence doesn't have quality scores");
        return ReportResult_Finished;
    }

    if (quality.qualCodes != qualityScores) {
        stateInfo.setError( QString("Quality scores are not valid! The score is %1, expected %2").arg(quality.qualCodes.constData()).arg(qualityScores.constData()));
        return ReportResult_Finished;
    }

    return ReportResult_Finished;
}
コード例 #3
0
Task::ReportResult GTest_DNASequencePart::report() {
    GObject *obj = getContext<GObject>(this,objContextName);
    if (obj==NULL) {
        stateInfo.setError(QString("wrong value: %1").arg(OBJ_ATTR));
        return ReportResult_Finished;
    }

    U2SequenceObject * objSequence = qobject_cast<U2SequenceObject*>(obj);
    if (objSequence==NULL) {
        stateInfo.setError(QString("can't cast to sequence from: %1").arg(obj->getGObjectName()));
        return ReportResult_Finished;
    }
    if (objSequence->getSequenceLength() < startPos + subseq.length()) {
        stateInfo.setError(QString("sequence size is less that region end: size=%1, region-end=%2, objectName=%3").arg(objSequence->getSequenceLength()).arg(startPos + subseq.length()).arg(obj->getGObjectName()));
        return ReportResult_Finished;
    }
    QByteArray objSubSeq = objSequence->getSequenceData(U2Region(startPos, subseq.length()));
    if (!objSequence->getAlphabet()->isCaseSensitive()) {
        subseq = subseq.toUpper();
    }
    if (objSubSeq != subseq){
        stateInfo.setError(QString("region not matched: %1, expected %2").arg(objSubSeq.constData()).arg(subseq.constData()));
        return ReportResult_Finished;
    }
    return ReportResult_Finished;
}
コード例 #4
0
void MafftAddToAlignmentTask::prepare() {
    algoLog.info(tr("Align sequences to an existing alignment by MAFFT started"));

    MSAUtils::removeColumnsWithGaps(inputMsa, inputMsa->getNumRows());

    tmpDirUrl = ExternalToolSupportUtils::createTmpDir("add_to_alignment", stateInfo);

    QString tmpAddedUrl = generateTmpFileUrl(tmpDirUrl + QDir::separator() + "XXXXXXXXXXXXXXXX_add.fa");;

    DocumentFormatRegistry *dfr = AppContext::getDocumentFormatRegistry();
    DocumentFormat *dfd = dfr->getFormatById(BaseDocumentFormats::FASTA);
    Document* tempDocument = dfd->createNewLoadedDocument(IOAdapterUtils::get(BaseIOAdapters::LOCAL_FILE), GUrl(tmpAddedUrl), stateInfo);

    QListIterator<QString> namesIterator(settings.addedSequencesNames);
    int currentRowNumber = inputMsa->getNumRows();
    foreach(const U2EntityRef& sequenceRef, settings.addedSequencesRefs) {
        uniqueIdsToNames[QString::number(currentRowNumber)] = namesIterator.next();
        U2SequenceObject seqObject(QString::number(currentRowNumber), sequenceRef);
        GObject* cloned = seqObject.clone(tempDocument->getDbiRef(), stateInfo);
        CHECK_OP(stateInfo, );
        cloned->setGObjectName(QString::number(currentRowNumber));
        tempDocument->addObject(cloned);
        currentRowNumber++;
    }

    saveSequencesDocumentTask = new SaveDocumentTask(tempDocument, tempDocument->getIOAdapterFactory(), tmpAddedUrl, SaveDocFlags(SaveDoc_Roll) | SaveDoc_DestroyAfter | SaveDoc_ReduceLoggingLevel);
    addSubTask(saveSequencesDocumentTask);

    QString tmpExistingAlignmentUrl = generateTmpFileUrl(tmpDirUrl + QDir::separator() + "XXXXXXXXXXXXXXXX.fa");

    saveAlignmentDocumentTask = new SaveMSA2SequencesTask(inputMsa, tmpExistingAlignmentUrl, false, BaseDocumentFormats::FASTA);
    addSubTask(saveAlignmentDocumentTask);
}
コード例 #5
0
Task::ReportResult GTest_DNAMulSequenceQuality::report() {
    GObject *obj = getContext<GObject>(this,objContextName);
    if (obj==NULL) {
        stateInfo.setError(QString("wrong object name: %1").arg(objContextName));
        return ReportResult_Finished;
    }

    MAlignmentObject* myMSequence= qobject_cast<MAlignmentObject*>(obj);
    if(myMSequence==NULL){
        stateInfo.setError(QString("Can not cast to alignment from: %1").arg(obj->getGObjectName()));
        return ReportResult_Finished;
    }

    bool ok_flag=false;
    foreach(const MAlignmentRow& myItem , myMSequence->getMAlignment().getRows()){
        if (myItem.getName() == seqName){
            ok_flag = true;
            //QByteArray qualityCodes = myItem.getCoreQuality().qualCodes;
            //if (qualityCodes != expectedQuality){
            //    stateInfo.setError(
            //        QString("Quality scores are not valid! The score is %1, expected %2").arg(qualityCodes.constData()).arg(expectedQuality.constData())
            //        );
            //    return ReportResult_Finished;
            //}
        }
    }
    if(!ok_flag){
        stateInfo.setError(QString("Sequence %1 is not found in the alignment").arg(seqName));
    }
    return ReportResult_Finished;

}
コード例 #6
0
ファイル: MaEditorTasks.cpp プロジェクト: ugeneunipro/ugene
void OpenMaEditorTask::open() {
    if (stateInfo.hasError() || (maObject.isNull() && documentsToLoad.isEmpty())) {
        return;
    }
    if (maObject.isNull()) {
        Document* doc = documentsToLoad.first();
        if(!doc){
            stateInfo.setError(tr("Documet removed from project"));
            return;
        }
        if (unloadedReference.isValid()) {
            GObject* obj = doc->findGObjectByName(unloadedReference.objName);
            if (obj!=NULL && obj->getGObjectType() == type) {
                maObject = qobject_cast<MultipleAlignmentObject*>(obj);
            }
        } else {
            QList<GObject*> objects = doc->findGObjectByType(type, UOF_LoadedAndUnloaded);
            maObject = objects.isEmpty() ? NULL : qobject_cast<MultipleAlignmentObject*>(objects.first());
        }
        if (maObject.isNull()) {
            stateInfo.setError(tr("Multiple alignment object not found"));
            return;
        }
    }
    viewName = GObjectViewUtils::genUniqueViewName(maObject->getDocument(), maObject);
    uiLog.details(tr("Opening MSA editor for object: %1").arg(maObject->getGObjectName()));

    MaEditor* v = getEditor(viewName, maObject);
    GObjectViewWindow* w = new GObjectViewWindow(v, viewName, false);
    MWMDIManager* mdiManager = AppContext::getMainWindow()->getMDIManager();
    mdiManager->addMDIWindow(w);

}
コード例 #7
0
ファイル: GRDummy.cpp プロジェクト: anttirt/guidolib
void GRDummy::tellPosition(GObject *caller,const NVPoint &newPosition)
{
	if (myptag)
	{	
		GObject * myobj = dynamic_cast<GObject *>(myptag);
		if (myobj)
			myobj->tellPosition(caller,newPosition);
	}
}
コード例 #8
0
ファイル: GRDummy.cpp プロジェクト: anttirt/guidolib
void GRDummy::OnDraw( VGDevice & hdc) const
{
	if (myptag && mDraw)
	{	
		GObject * myobj = dynamic_cast<GObject *>(myptag);
		if (myobj)
			myobj->OnDraw(hdc);
	}
}
コード例 #9
0
ファイル: gwindow.cpp プロジェクト: MoonighT/CS106B
GObject *GWindow::getGObjectAt(double x, double y) const {
    if (gwd && gwd->top) {
        int n = gwd->top->getElementCount();
        for (int i = n - 1; i >= 0; i--) {
            GObject *gobj = gwd->top->getElement(i);
            if (gobj->contains(x, y)) return gobj;
        }
    }
    return NULL;
}
コード例 #10
0
ファイル: ConvertFileTask.cpp プロジェクト: ggrekhov/ugene
QList<Task*> DefaultConvertFileTask::onSubTaskFinished(Task *subTask) {
    QList<Task*> result;
    CHECK(!subTask->hasError() && !subTask->isCanceled(), result);
    CHECK(!hasError() && !isCanceled(), result);

    if (saveTask == subTask) {
        return result;
    }
    SAFE_POINT_EXT(loadTask == subTask, setError("Unknown subtask"), result);

    bool mainThread = false;
    Document *srcDoc = loadTask->getDocument(mainThread);
    SAFE_POINT_EXT(NULL != srcDoc, setError("NULL document"), result);

    DocumentFormatRegistry *dfr = AppContext::getDocumentFormatRegistry();
    DocumentFormat *df = dfr->getFormatById(targetFormat);
    SAFE_POINT_EXT(NULL != df, setError("NULL document format"), result);

    QSet<GObjectType> selectedFormatObjectsTypes = df->getSupportedObjectTypes();
    QSet<GObjectType> inputFormatObjectTypes;
    QListIterator<GObject*> objectsIterator(srcDoc->getObjects());
    while (objectsIterator.hasNext()) {
        GObject *obj = objectsIterator.next();
        inputFormatObjectTypes << obj->getGObjectType();
    }
    inputFormatObjectTypes.intersect(selectedFormatObjectsTypes);
    if (inputFormatObjectTypes.empty()) {
        setError(tr("The formats are not compatible: %1 and %2").arg(srcDoc->getDocumentFormatId()).arg(targetFormat));
        return result;
    }

    QString ext = targetFormat;
    if (!df->getSupportedDocumentFileExtensions().isEmpty()) {
        ext = df->getSupportedDocumentFileExtensions().first();
    }

    if (targetUrl.isEmpty()) {
        QString fileName = srcDoc->getName() + "." + ext;
        targetUrl = GUrlUtils::rollFileName(workingDir + fileName, QSet<QString>());
    } else {
        if (QFileInfo(targetFormat).suffix() != ext) {
            targetUrl += "." + ext;
        }
        targetUrl = GUrlUtils::rollFileName(targetUrl, QSet<QString>());
    }

    IOAdapterFactory *iof = AppContext::getIOAdapterRegistry()->getIOAdapterFactoryById(IOAdapterUtils::url2io(srcDoc->getURL()));
    Document *dstDoc = srcDoc->getSimpleCopy(df, iof, srcDoc->getURL());

    saveTask = new SaveDocumentTask(dstDoc, iof, targetUrl);
    result << saveTask;
    return result;
}
コード例 #11
0
void GTest_CalculateTreeFromAligment::prepare() {

    GObject *obj = getContext<GObject>(this, objContextName);
    if(obj==NULL){
        stateInfo.setError(QString("wrong value: %1").arg(objContextName));
        return;
    }

    MultipleSequenceAlignmentObject* maObj = qobject_cast<MultipleSequenceAlignmentObject*>(obj);
    if(maObj==NULL){
        stateInfo.setError(QString("can't cast to multimple alignment object from: %1").arg(obj->getGObjectName()));
        return;
    }

    CreatePhyTreeSettings settings;
    settings.algorithmId = algName;
    settings.mb_ngen = 1000;
    settings.mrBayesSettingsScript = QString("Begin MrBayes;\n"
        "lset Nst=2 rates=gamma ngammacat=4;\n"
        "mcmc ngen=1000 samplefreq=100 printfreq=1000 nchains=4 temp=0.4 savebrlens=yes "
        "startingtree=random seed=10;\n"
        "sumt burnin=10;\n"
        "End;\n");

    task = new PhyTreeGeneratorLauncherTask(maObj->getMultipleAlignment(), settings);

    if (task == NULL) {
        stateInfo.setError(QString("Algorithm %1 not found").arg(algName));
        return;
    }
    addSubTask(task);
}
コード例 #12
0
ファイル: lcd.cpp プロジェクト: miro-kostadinov/tmos
void LCD_MODULE::invalidate (GObject* object, RECT_T area)						//goes through the window list and adjusts the area vertically
{

	if(!area.normalize(rect))
		return;

	GObject* tmp = object->nextObj;
	if(object == this)
	{
		for (tmp = children; tmp; tmp = tmp->nextObj)
			tmp->invalidate(tmp, tmp->rect);
		return;
	}
	while (tmp)
	{
		if ( (((GWindow*)tmp)->displays & display) && (tmp->flags & GO_FLG_SHOW) && !(tmp->flags & GO_FLG_TRANSPARENT) )
		{
			if (area.x0 >= tmp->rect.x0 && area.x1 <= tmp->rect.x1)
			{
				if (area.y0 < tmp->rect.y0)
				{
					if (area.y1 <= tmp->rect.y1 && area.y1 >= tmp->rect.y0)
						area.y1 = tmp->rect.y0 - 1;								//the whole bottom part of the area is covered
				}
				else
				{
					if (area.y1 <= tmp->rect.y1)
						return;													//the whole area is covered
					if (area.y1 > tmp->rect.y1 && area.y0 <= tmp->rect.y1)
						area.y0 = tmp->rect.y1 + 1;								//the whole upper part of the area is covered
				}
			}
		}
		tmp = tmp->nextObj;
	}
	adjust_for_screen(&object, area);											//change the area and object to desktop if the display draws only rows or columns
	for (tmp = object; tmp; tmp = tmp->nextObj)
	{
		if (((GWindow*)tmp)->displays & display)
		{
			if (tmp->flags & GO_FLG_SHOW)
			{
				tmp->draw(this, area);											//calls the adraw function (for the area) for every window after object in the Z-order
			}
		}
	}
}
コード例 #13
0
ファイル: PaintWidget.cpp プロジェクト: maratjob/MultiFusion
void PaintWidget::setFigureHideLines(int value)
{
	if(painter.selection.countSelected() == 1)
	{
		GContainer* c = GCONTAINER(painter.selection.getSelected());
		if(c!=0)
		{
			GObject* ob =c->object(0);
			if(!ob->isContainer())
			{
				GVectorFigure* v =GVECTORFIGURE(ob);
				v->setHideLines(value);
				painter.update();
			}
		}
	}
}
コード例 #14
0
ファイル: PaintWidget.cpp プロジェクト: maratjob/MultiFusion
int PaintWidget::getFigureHideLines()
{
	if(painter.selection.countSelected() == 1)
	{
		GContainer* c = GCONTAINER(painter.selection.getSelected());
		if(c!=0)
		{
			GObject* ob =c->object(0);
			if(!ob->isContainer())
			{
				GVectorFigure* v = GVECTORFIGURE(ob);
				return v->getHideLines();
			}
		}
	}
	return -1;
}
コード例 #15
0
ファイル: PaintWidget.cpp プロジェクト: maratjob/MultiFusion
int PaintWidget::FigureIsSpline()
{
	if(painter.selection.countSelected() == 1)
	{
		GContainer* c = GCONTAINER(painter.selection.getSelected());
		if(c!=0)
		{
			GObject* ob =c->object(0);
			if(!ob->isContainer())
			{
				GVectorFigure* v = GVECTORFIGURE(ob);
				return (v->isSpline())?1:0;
			}
		}
	}
	return -1;
}
コード例 #16
0
Task::ReportResult GTest_DNASequenceSize::report() {
    GObject *obj = getContext<GObject>(this, objContextName);
    if(obj==NULL){
        stateInfo.setError(QString("wrong value: %1").arg(OBJ_ATTR));
        return ReportResult_Finished;
    }

    U2SequenceObject * mySequence = qobject_cast<U2SequenceObject*>(obj);
    if(mySequence==NULL){
        stateInfo.setError(QString("can't cast to sequence from: %1").arg(obj->getGObjectName()));
        return ReportResult_Finished;
    }
    int tempLength=mySequence->getSequenceLength();
    if (tempLength != seqSize){
        stateInfo.setError(QString("sequence size not matched: %1, expected %2 ").arg(tempLength).arg(seqSize));
    }
    return ReportResult_Finished;
}
コード例 #17
0
Task::ReportResult GTest_DNAMulSequenceAlphabetId::report() {
    GObject *obj = getContext<GObject>(this, objContextName);
    if(obj==NULL){
        stateInfo.setError(QString("wrong value: %1").arg(OBJ_ATTR));
        return ReportResult_Finished;
    }

    MAlignmentObject* myMSequence= qobject_cast<MAlignmentObject*>(obj);
    if(myMSequence==NULL){
        stateInfo.setError(QString("can't cast to sequence from: %1").arg(obj->getGObjectName()));
        return ReportResult_Finished;
    }
    const DNAAlphabet *tempAlphabet = myMSequence->getAlphabet();
    if( tempAlphabet->getId() != alpId){
        stateInfo.setError(QString("Alphabet id not matched: %1 expected %2").arg(tempAlphabet->getId()).arg(alpId));
    }
    return ReportResult_Finished;
}
コード例 #18
0
Task::ReportResult GTest_DNASequencInMulSequence::report() {
    GObject *obj = getContext<GObject>(this, objContextName);
    if(obj==NULL){
        stateInfo.setError(QString("wrong value: %1").arg(OBJ_ATTR));
        return ReportResult_Finished;
    }

    MAlignmentObject* myMSequence= qobject_cast<MAlignmentObject*>(obj);
    if(myMSequence==NULL){
        stateInfo.setError(QString("can't cast to sequence from: %1").arg(obj->getGObjectName()));
        return ReportResult_Finished;
    }
    int tempSize=myMSequence->getNumRows();
    if (tempSize != seqInMSeq){
        stateInfo.setError(QString("numbers of Sequence not match: %1, expected %2 ").arg(tempSize).arg(seqInMSeq));
    }
    return ReportResult_Finished;
}
コード例 #19
0
ファイル: marblegraphics.cpp プロジェクト: MoonighT/CS106B
bool MarbleGraphics::getNextUserMove(Move& move) {
    GMouseEvent me;
    bool startClick = true;
    while (true) {
        me = getNextEvent(MOUSE_EVENT);
        if (me.getEventType() == MOUSE_CLICKED) {
            GObject* obj = getGObjectAt(me.getX(),me.getY());
            if (obj == NULL) {
                startClick = true;
                errorNotification();
            }
            // User clicked in SOLVE button
            else if (obj->getType() == "GRoundRect" || obj->getType() == "GLabel"){
                return false;
            }
            // User clicked in MARBLE
            else if (obj->getType() == "GImage") {
                // First click = starting location
                if (startClick) {
                    move.startRow = marbleCoords[(GImage*)obj].row;
                    move.startCol = marbleCoords[(GImage*)obj].col;
                    //If click on visible marble (Flash it to show selection detected)
                    if(((GImage*)obj)->isVisible()){
                        ((GImage*) obj)->setVisible(false);
                        pause(50);
                        ((GImage*) obj)->setVisible(true);
                    }
                    startClick = false;
                }
            }
            //User clicked in empty valid space on playing board
            else if (obj->getType() == "GOval"){
                // Second click = ending location
                if (!startClick) {
                    move.endRow = spaceCoords[(GOval*)obj].row;
                    move.endCol = spaceCoords[(GOval*)obj].col;
                    return true;
                }
            }
        }
    }
    return false;
}
コード例 #20
0
Task::ReportResult GTest_DNATranslation3to1Test::report() {
    GObject *obj = getContext<GObject>(this, objContextName);
    if (obj==NULL){
        stateInfo.setError(QString("wrong value: %1").arg(OBJ_ATTR));
        return ReportResult_Finished;
    }

    U2SequenceObject * mySequence = qobject_cast<U2SequenceObject*>(obj);
    if(mySequence==NULL){
        stateInfo.setError(QString("error can't cast to sequence from: %1").arg(obj->getGObjectName()));
        return ReportResult_Finished;
    }
    if(!(mySequence->getAlphabet()->isNucleic())){
        stateInfo.setError(QString("error Alphabet is not Nucleic: %1").arg(mySequence->getAlphabet()->getId()));
        return ReportResult_Finished;
    }

    DNATranslation* aminoTransl = 0;

    DNATranslationRegistry* tr = AppContext::getDNATranslationRegistry();

    QList<DNATranslation*> aminoTs = tr->lookupTranslation(mySequence->getAlphabet(), DNATranslationType_NUCL_2_AMINO);
    if (!aminoTs.empty()) {
        aminoTransl = tr->getStandardGeneticCodeTranslation(mySequence->getAlphabet());
    }
    int tempValue;
    if(strTo == -1){
        tempValue=-1;
    } else{
        tempValue=(strTo-strFrom+1);
    }
    QByteArray myByteArray = mySequence->getSequenceData(U2Region(strFrom,tempValue));
    QByteArray rezult(myByteArray.length() / 3, 0);
    int n = aminoTransl->translate(myByteArray, myByteArray.length(), rezult.data(), rezult.length());
    assert(n == rezult.length()); Q_UNUSED(n);

    if(rezult != stringValue.toLatin1()){
        stateInfo.setError(QString("translated sequence not matched: %1, expected %2 ").arg(rezult.data()).arg(stringValue));
        return ReportResult_Finished;
    }
    return ReportResult_Finished;
}
コード例 #21
0
ファイル: smcont.cpp プロジェクト: ExShini/ColonyControl
/************************************************
 * Func: finilizeProc
 * Desc: finalize loop. Clear mamory for all removed objects
 * Note: should be called at end of processing loop
 ***********************************************/
void SmCont::finilizeProc(bool freeMemory)
{
	iter* removedIt = nullptr;

	while(!m_toRemoved.isEmpty())
	{
		removedIt = m_toRemoved.front();
		GObject* removedObj = *(*removedIt);
		iter endIter = removedIt->operator +(1);
		m_list.erase(*removedIt, endIter);

		// deactivate if it still active
		removedObj->deactivate();
		if(freeMemory)
		{
			delete removedObj;
		}

		m_toRemoved.pop_front();
	}
}
コード例 #22
0
Task::ReportResult GTest_DNAMulSequencePart::report() {
    GObject *obj = getContext<GObject>(this,objContextName);
    if (obj==NULL) {
        stateInfo.setError(QString("wrong value: %1").arg(OBJ_ATTR));
        return ReportResult_Finished;
    }

    MAlignmentObject* myMSequence= qobject_cast<MAlignmentObject*>(obj);
    if(myMSequence==NULL){
        stateInfo.setError(QString("can't cast to sequence from: %1").arg(obj->getGObjectName()));
        return ReportResult_Finished;
    }

    if (myMSequence->getLength() < startPos + subseq.length()) {
        stateInfo.setError(QString("sequence size is less that region end: size=%1, region-end=%").arg(myMSequence->getLength(), startPos + subseq.length()));
        return ReportResult_Finished;
    }

    if (!myMSequence->getAlphabet()->isCaseSensitive()) {
        subseq = subseq.toUpper();
    }
    bool ok_flag=false;
    U2OpStatus2Log os;
    const MAlignment ma = myMSequence->getMAlignment();
    foreach(const MAlignmentRow& myItem , ma.getRows()){
        if (myItem.getName() == seqName){
            ok_flag=true;
            QByteArray objSubSeq = myItem.mid(startPos, subseq.length(), os).toByteArray(subseq.length(), os);
            if (objSubSeq != subseq){
                stateInfo.setError(QString("region not matched: %1, expected %2").arg(objSubSeq.constData()).arg(subseq.constData()));
                return ReportResult_Finished;
            }
        }
    }
    if(!ok_flag){
        stateInfo.setError(QString("no Sequence name: %1").arg(seqName));
    }
    return ReportResult_Finished;

}
コード例 #23
0
Task::ReportResult GTest_CompareTreesInTwoObjects::report() {
    Document* doc = getContext<Document>(this, docContextName);
    if (doc == NULL) {
        stateInfo.setError(QString("document not found %1").arg(docContextName));
        return ReportResult_Finished;
    }
    Document* doc2 = getContext<Document>(this, secondDocContextName);
    if (doc2 == NULL) {
        stateInfo.setError(QString("document not found %1").arg(secondDocContextName));
        return ReportResult_Finished;
    }

    const QList<GObject*>& objs = doc->getObjects();
    const QList<GObject*>& objs2 = doc2->getObjects();
    for (int i = 0; i < objs.size() && i < objs2.size(); ++i){
        GObject *obj = objs.at(i), *obj2 = objs2.at(i);
        PhyTreeObject *treeObj = NULL, *treeObj2 = NULL;
        if (obj->getGObjectType() == GObjectTypes::PHYLOGENETIC_TREE){
            treeObj = qobject_cast<PhyTreeObject*>(obj);
        }
        if (obj2->getGObjectType() == GObjectTypes::PHYLOGENETIC_TREE){
            treeObj2 = qobject_cast<PhyTreeObject*>(obj2);
        }
        if (treeObj == NULL){
            stateInfo.setError(QString("can't cast to tree from: %1 in position %2").arg(obj->getGObjectName()).arg(i));
            return ReportResult_Finished;
        }
        if (treeObj2 == NULL){
            stateInfo.setError(QString("can't cast to tree from: %1 in position %2").arg(obj2->getGObjectName()).arg(i));
            return ReportResult_Finished;
        }

        if (!PhyTreeObject::treesAreAlike(treeObj->getTree(), treeObj2->getTree())) {
            stateInfo.setError(QString("trees in position %1 are different").arg(i));
            return ReportResult_Finished;
        }
    }

    return ReportResult_Finished;
}
コード例 #24
0
ファイル: PaintWidget.cpp プロジェクト: maratjob/MultiFusion
void PaintWidget::FigureSetStyle(bool spline)
{
	if(painter.selection.countSelected() == 1)
	{
		GContainer* c = GCONTAINER(painter.selection.getSelected());
		if(c!=0)
		{
			GObject* ob =c->object(0);
			if(!ob->isContainer())
			{

				GVectorFigure* v = GVECTORFIGURE(ob);
				if(spline)
					v->toSpline();
				else
					v->toNormal();

				painter.update();
			}
		}
	}
}
コード例 #25
0
void Coin::CheckContainer(list<GObject*>* staObjs)
{
	if(isCheckedContainer==true) return;

	list<GObject*>::iterator i;
	GObject* obj;
	for(i=staObjs->begin();i!=staObjs->end();i++)
	{
		obj=*i;
		if(obj->ID==24||obj->ID==25)
			if(GCollision::RectVsRect(rect,obj->rect))
			{
				container=obj;
				state=IS_IDLE;
				if(obj->ID==24)			//Nếu tiền nằm trong gạch
				{
					numCoin=5;
					obj->SetVar("isContainCoin",true);
				}
			}
	}
	isCheckedContainer=true;
}
コード例 #26
0
bool RequestManagerTest::executeT4()
{
	bool status = true;

	RequestManager reqManager;

	GObject* obj = new GObject(nullptr);
	obj->setMapCoord(0,0);


	// add 10 CONSUME request
	for(int i = 0; i < 10 ; i++)
	{
		Request* req = new Request();
		req->resType = POPULATION;
		req->status = AWAITS;
		req->subject = obj;
		req->type = CONSUME;
		req->value = 100 + i;

		reqManager.addRequest(req);
	}

	// check requests
	for(int i = 0; i < 10; i++)
	{
		Request* req = reqManager.findRequest(POPULATION, PROVIDE, 16, 16);

		if(req != nullptr)
		{
			status = false;
			break;
		}
	}

	return status;
}
コード例 #27
0
ファイル: modulegenerator.cpp プロジェクト: ExShini/firstPro
/*************************************
FUNC: generateModule(ModuleType moduleType)
DESC: generate and return module by type
*************************************/
Module *moduleGenerator::generateModule(ModuleType moduleType)
{
    Module* module = new Module();

    for (int i = 0; i < GENERATED_MAP_WIDTH; i++)
    {
        for (int j = 0; j < GENERATED_MAP_HEIGHT; j++)
        {
            m_costMap[i][j] = new genMapField();
        }
    }

    //get rooms and plase it in map
    vector<room*>* rooms = getRooms(moduleType);
    vector<room*>::iterator iter = rooms->begin();

    bool possibility = false;
    for (; iter != rooms->end(); iter++)
    {
        room* croom = *iter;
        //try get valide coordinate for room
        int x, y;
        while (possibility != true)
        {
            x = (m_randGen->getRand()) % (GENERATED_MAP_WIDTH - croom->getWidth() - roomBorder * 2) + roomBorder;
            y = (m_randGen->getRand()) % (GENERATED_MAP_HEIGHT - croom->getHeight() - roomBorder * 2) + roomBorder;
            possibility = checkArea(x, y, croom);
        }
        //place room to cost map and floor to obj list
        placeRoom(croom, x, y);
        possibility = false;

    }


    //try buil corridors between rooms
    int size = rooms->size();
    for (int current = 0; current < size; current++)
    {
        for (int target = current + 1; target < size; target++)
        {
            room* curRomm = (*rooms).at(current);
            room* tarRomm = (*rooms).at(target);
            createCorridors(curRomm, tarRomm);
        }
    }


    //create objects to moduleList by m_costMap
    for (int i = 0; i < GENERATED_MAP_WIDTH; i++)
    {
        for (int j = 0; j < GENERATED_MAP_HEIGHT; j++)
        {

            genMapField* field = m_costMap[i][j];

            for (int ml = MLEVEL_0; ml < NUM_LEVELS; ml++)
            {
                //get object by type here!

                if (field->getObjType((ModuleObjLevel)ml) == t_MedBox)
                {
                    //debug
                    int a = 11;
                    int b = 33 + a;
                }

                GObject* obj = getGObjectByType(field->getObjType((ModuleObjLevel)ml),
                                                field->getObjDirect((ModuleObjLevel)ml));
                if (obj != NULL)
                {
                    obj->setX(i);
                    obj->setY(j);
                    //set objects to model
                    (*(module->objects[ml]))[ObjectController::getFieldKey(i, j)] = obj;
                }
                else if (ml == MLEVEL_0)
                {
                    //check near fields
                    bool isWall = false;

                    //right field
                    if (i < GENERATED_MAP_WIDTH - 1)
                    {
                        isWall |= (m_costMap[i + 1][j]->getObjType(MLEVEL_0) == t_Floor);
                        //right down field
                        if (j < GENERATED_MAP_HEIGHT - 1)
                            isWall |= (m_costMap[i + 1][j + 1]->getObjType(MLEVEL_0) == t_Floor);

                        //right top field
                        if (j > 0)
                            isWall |= (m_costMap[i + 1][j - 1]->getObjType(MLEVEL_0) == t_Floor);
                    }

                    //left field
                    if (i > 0)
                    {
                        isWall |= (m_costMap[i - 1][j]->getObjType(MLEVEL_0) == t_Floor);

                        //left down field
                        if (j < GENERATED_MAP_HEIGHT - 1)
                            isWall |= (m_costMap[i - 1][j + 1]->getObjType(MLEVEL_0) == t_Floor);

                        //left top field
                        if (j > 0)
                            isWall |= (m_costMap[i - 1][j - 1]->getObjType(MLEVEL_0) == t_Floor);
                    }
                    if (j < GENERATED_MAP_HEIGHT - 1)
                        isWall |= (m_costMap[i][j + 1]->getObjType(MLEVEL_0) == t_Floor);
                    if (j > 0)
                        isWall |= (m_costMap[i][j - 1]->getObjType(MLEVEL_0) == t_Floor);

                    if (isWall)
                    {
                        field->setObjType(t_Wall, MLEVEL_0);
                        obj = getGObjectByType(t_Wall, NODIR);
                        obj->setX(i);
                        obj->setY(j);
                        (*(module->objects[ml]))[ObjectController::getFieldKey(i, j)] = obj;
                    }
                }
            }
        }
    }


    //clean memory after using
    for (int i = 0; i < GENERATED_MAP_WIDTH; i++)
    {
        for (int j = 0; j < GENERATED_MAP_HEIGHT; j++)
        {
            if (m_costMap[i][j] != NULL)
                delete m_costMap[i][j];
        }
    }


    return module;
}
コード例 #28
0
bool RequestManagerTest::executeT1()
{
	bool status = true;

	RequestManager reqManager;

	GObject* obj = new GObject(nullptr);
	obj->setMapCoord(5,5);


	// add 10 CONSUME request
	for(int i = 0; i < 10 ; i++)
	{
		Request* req = new Request();
		req->resType = POPULATION;
		req->status = AWAITS;
		req->subject = obj;
		req->type = CONSUME;
		req->value = 100 + i;

		reqManager.addRequest(req);
	}

	// check requests
	for(int i = 0; i < 10; i++)
	{
		Request* req = reqManager.findRequest(POPULATION, CONSUME, 5, 5);

		if(req == nullptr)
		{
			status = false;
			break;
		}

		if(req->resType != POPULATION)
		{
			qDebug() << "Error! req->resType";
			status = false;
		}

		if(req->status != AWAITS)
		{
			qDebug() << "Error! req->status";
			status = false;
		}

		if(req->subject != obj)
		{
			qDebug() << "Error! req->subject";
			status = false;
		}

		if(req->type != CONSUME)
		{
			qDebug() << "Error! req->type";
			status = false;
		}

		if(req->value != 100 + i)
		{
			qDebug() << "Error! req->value";
			status = false;
		}
	}


	return status;
}
コード例 #29
0
void GDrawingSurface::draw(GObject& gobj, double x, double y) {
    gobj.setLocation(x, y);
    draw(&gobj);
}
コード例 #30
0
void test_contains_and_getBounds() {
    bool useCompounds = false;
    int x0 = 350;
    int y0 = 300;
    Map<string, GObject*> shapeMap;
    GOval *oval = new GOval(x0, y0, 200, 100);
    GRoundRect *roundRect = new GRoundRect(x0, y0, 200, 100, 300);
    roundRect->setLineWidth(20);
    G3DRect *rect3d = new G3DRect(x0, y0, 200, 100, true);
    //rect3d->setLineWidth(5);
    rect3d->setFillColor("green");
    rect3d->setFilled(true);
    GPolygon *poly = new GPolygon;
    poly->addVertex(0, 0);
    poly->addEdge(200, 100);
    poly->addEdge(-200, 0);
    poly->setLocation(x0, y0);
    GPolygon *cpoly = new GPolygon;
    cpoly->addVertex(0, 0);
    cpoly->addEdge(200, 100);
    cpoly->addEdge(0, -100);
    cpoly->addEdge(-200, 100);
    cpoly->setLocation(x0, y0);
    GRect *rect = new GRect(x0, y0, 200, 100);
    GLine *line = new GLine(x0, y0, x0 + 200, y0 + 100);
    GLabel *label = new GLabel("Ostromantus", x0, y0);
    GArc *arc = new GArc(x0, y0, 350, 350, 0, 90);
    //arc->setLineWidth(5);
    arc->setColor("#44000000");
    GArc *filledArc = new GArc(x0, y0, 350, 100, 45, 225);
    filledArc->setFillColor("#88e0e0e0");
    filledArc->setFilled(true);
    GCompound *comp1 = new GCompound;
    comp1->setLocation(x0, y0);
    comp1->add(new GLabel("compound", 0, 15));
    GRect *bgRect1 = new GRect(0, 0);
    gw->add(bgRect1);
    bgRect1->setFillColor("#55dddddd");
    bgRect1->setFilled(true);
    GImage *image = new GImage("homer-transparent.png");
    image->setLocation(x0, y0);
    GCompound *comp = new GCompound;
    comp->setLocation(x0, y0);
    GRect *compRect = new GRect(20, 20, 100, 100);
    GOval *compOval = new GOval(90, 90, 150, 70);
    comp->add(compRect);
    comp->add(compOval);
    GButton *button = new GButton("Testo");
    button->setSize(200, 100);
    button->setLocation(x0, y0);
    shapeMap.put("oval", oval);
    shapeMap.put("rounded rectangle", roundRect);
    shapeMap.put("3D rectangle", rect3d);
    shapeMap.put("polygon", poly);
    shapeMap.put("crazy polygon", cpoly);
    shapeMap.put("rectangle", rect);
    shapeMap.put("line", line);
    shapeMap.put("arc", arc);
    shapeMap.put("filled arc", filledArc);
    shapeMap.put("label", label);
    shapeMap.put("image", image);
    shapeMap.put("compound", comp);
    shapeMap.put("button", button);

    GObject *currObj;
    GChooser *ch = new GChooser;
    ch->setActionCommand("chooser");
    ch->addItem("oval");
    ch->addItem("rounded rectangle");
    ch->addItem(("3D rectangle"));
    ch->addItem("polygon");
    ch->addItem("crazy polygon");
    ch->addItem("rectangle");
    ch->addItem("line");
    ch->addItem("arc");
    ch->addItem("filled arc");
    ch->addItem("label");
    ch->addItem("image");
    ch->addItem("compound");
    ch->addItem("button");
    ch->setSelectedItem("rectangle");
    currObj = rect;

    GButton *endButton = new GButton("End test");
    GButton *fillButton = new GButton("Auto-fill");
    GButton *rotateButton = new GButton("Rotate");
    GButton *scaleButton = new GButton("Scale");

    GCheckBox *compCheckbox = new GCheckBox("compounds");
    compCheckbox->setActionCommand("compounds");
    gw->addToRegion(compCheckbox, "north");
    gw->addToRegion(ch, "north");
    gw->addToRegion(rotateButton, "north");
    gw->addToRegion(scaleButton, "north");
    gw->addToRegion(fillButton, "north");
    gw->addToRegion(endButton, "north");

    while (true) {
        GEvent e = waitForEvent(ACTION_EVENT | MOUSE_EVENT);
        if (!e.isValid())
            continue;
        if (e.getEventClass() == ACTION_EVENT) {
            if (((GActionEvent) e).getActionCommand() == "End test")
                break;
            if (((GActionEvent) e).getActionCommand() == "compounds") {
                bgRect1->setVisible(compCheckbox->isSelected());
                useCompounds = compCheckbox->isSelected();
            }
            if (((GActionEvent) e).getActionCommand() == "Testo") {
                GPoint pt = button->getLocation();
                button->setLocation(pt.getX()-button->getWidth()-10, pt.getY());
                pause(1000);
                button->setLocation(pt);
            }
            if (((GActionEvent) e).getActionCommand() == "Auto-fill") {
                GRectangle bds = currObj->getBounds();
                int xmin = bds.getX();
                int ymin = bds.getY();
                int xmax = bds.getX() + bds.getWidth();
                int ymax = bds.getY() + bds.getHeight();
                int dx = useCompounds ? comp1->getX(): 0;
                int dy = useCompounds ? comp1->getY(): 0;
                for (int y = ymin; y < ymax; y+=1)
                    for (int x = xmin; x < xmax; x+=1) {
                        if (currObj->contains(x, y)) {
                            gw->setColor("red");
                            gw->fillOval(x + dx, y + dy, 1, 1);
                        } else {
                            gw->setColor("green");
                            gw->fillOval(x + dx, y + dy, 1, 1);
                        }
                    }
            }

            if (((GActionEvent) e).getActionCommand() == "Rotate") {
                currObj->rotate(45);
                if (useCompounds) {
                    bgRect1->setBounds(comp1->getBounds());
                }
            }
            if (((GActionEvent) e).getActionCommand() == "Scale") {
                currObj->scale(1.2, 0.8);
                if (useCompounds) {
                    bgRect1->setBounds(comp1->getBounds());
                }
            }
            if (((GActionEvent) e).getActionCommand() == "chooser") {
                string shape = ch->getSelectedItem();
                if (useCompounds) {
                    comp1->remove(currObj);
                    gw->remove(comp1);
                } else {
                    gw->remove(currObj);
                }
                gw->setColor("white");
                gw->fillRect(0, 0, gw->getCanvasWidth(), gw->getCanvasHeight());
                //drawGrid();
                gw->setColor("black");
                currObj = shapeMap.get(shape);
                if (useCompounds) {
                    gw->add(comp1);
                    comp1->add(currObj, 50, 50);
                    bgRect1->setBounds(comp1->getBounds());
                } else {
                    gw->add(currObj);
                }
                gw->drawOval(currObj->getX()-2, currObj->getY()-2, 4, 4);
            }
        } else if (e.getEventType() == MOUSE_CLICKED) {
            double x = ((GMouseEvent) e).getX();
            double y = ((GMouseEvent) e).getY();
            if (currObj->contains(x, y)) {
                gw->setColor("red");
                gw->fillOval(x, y, 1, 1);
            }
        }
    }
}