本文整理汇总了C++中GObject类的典型用法代码示例。如果您正苦于以下问题:C++ GObject类的具体用法?C++ GObject怎么用?C++ GObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: report
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: generateTmpFileUrl
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);
}
示例3: getEditor
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);
}
示例4: tellPosition
void GRDummy::tellPosition(GObject *caller,const NVPoint &newPosition)
{
if (myptag)
{
GObject * myobj = dynamic_cast<GObject *>(myptag);
if (myobj)
myobj->tellPosition(caller,newPosition);
}
}
示例5: OnDraw
void GRDummy::OnDraw( VGDevice & hdc) const
{
if (myptag && mDraw)
{
GObject * myobj = dynamic_cast<GObject *>(myptag);
if (myobj)
myobj->OnDraw(hdc);
}
}
示例6:
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;
}
示例7: CHECK
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;
}
示例8: prepare
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);
}
示例9: invalidate
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
}
}
}
}
示例10: GCONTAINER
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();
}
}
}
}
示例11: while
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;
}
示例12: rezult
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;
}
示例13: while
/************************************************
* 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();
}
}
示例14: report
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;
}
示例15: CheckContainer
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;
}