bool ReadsLayout::checkLayout(size_t index) { if (getNext(index) != 0) { cerr << "next!=0" << endl; return false; } int lastPos = getPosition(index); lastIdentical[index] = 1000000000; //used as a flag while (getPrevious(index) != 0) { index = getPrevious(index); if (lastIdentical[index] == 1000000000) { cerr << "cycle!" << endl; return false; } else lastIdentical[index] = 1000000000; if (getPosition(index) > lastPos) { cerr << "posSorting!" << endl; return false; } else lastPos = getPosition(index); } return index; }
void GridModel::draw(const core::visual::VisualParams* vparams) { if (!isActive() || !((getNext()==NULL)?vparams->displayFlags().getShowCollisionModels():vparams->displayFlags().getShowBoundingCollisionModels())) return; glDisable(GL_LIGHTING); int level=0; CollisionModel* m = getPrevious(); float color = 1.0f; while (m!=NULL) { m = m->getPrevious(); ++level; color *= 0.5f; } if (isSimulated()) glColor4f(1.0f, 1.0f, 1.0f, color); else glColor4f(1.0f, 1.0f, 0.0f, color); if (color < 1.0f) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(0); } for (int i=0;i<size;i++) { draw(vparams,i); } if (color < 1.0f) { glDisable(GL_BLEND); glDepthMask(1); } if (getPrevious()!=NULL) getPrevious()->draw(vparams); }
void ArduRCT_GraphicsUITab::draw(ArduRCT_Graphics *graphics, int16_t uiX, int16_t uiY, uint16_t uiWidth) { uint16_t bgColor = graphics->getBackgroundColor(); uint16_t color = GRAPHICS_UI_COLOR_RELEASED; if (_value == GRAPHICS_UI_PRESSED) color = GRAPHICS_UI_COLOR_BACKGROUND; if (_state == GRAPHICS_UI_PRESSED) color = GRAPHICS_UI_COLOR_PRESSED; graphics->setBackgroundColor(color); int16_t xStart = 0; if ((getPrevious() == 0) || (getPrevious()->getGroup() != _group)) xStart = GRAPHICS_UI_TAB_LEFT_MARGIN; graphics->fillRectangle(xStart+uiX+x, uiY+y+1, width-xStart, height-1, color); uint16_t bColor = BLACK; if (_state == GRAPHICS_UI_SELECTED || _state == GRAPHICS_UI_RELEASED) bColor = GRAPHICS_UI_COLOR_HIGHLIGHTED; graphics->drawRectangle(xStart+uiX+x, uiY+y+1, width-xStart, height-1, bColor, 1); int16_t lineY = uiY+y+height-1; if (xStart != 0) graphics->drawLine(uiX+x, lineY, uiX+x+xStart, lineY, BLACK, 1); // for the last tab, go to the end of the ui if ((getNext() == 0) || (getNext()->getGroup() != _group)) graphics->drawLine(uiX+x+width, lineY, uiX+x+width+uiWidth, lineY, BLACK, 1); if (_value == GRAPHICS_UI_PRESSED) graphics->drawLine(uiX+x+xStart+1, lineY, uiX+x+width-2, lineY, WHITE, 1); if (_text) { uint8_t fontSize = getFontSize(_text); graphics->drawString(_text, uiX+x+_textX+xStart/2, uiY+y+_textY+1, BLACK, fontSize, GRAPHICS_UI_ELEMENT_FONT_IS_BOLD, false); } else if (_drawHandler) { (*_drawHandler)(_id, _state, _value, x+uiX, y+uiY, width, height); } graphics->setBackgroundColor(bgColor); }
void ArduRCT_GraphicsUITab::autoSize(ArduRCT_Graphics *graphics) { if (_text == 0) return; uint8_t fontSize = getFontSize(_text); height = graphics->getFontHeight(fontSize) + GRAPHICS_UI_TAB_TOP_MARGIN * 2; width = graphics->getStringWidth(_text, fontSize) + GRAPHICS_UI_TAB_LEFT_MARGIN * 2; if ((getPrevious() == 0) || (getPrevious()->getGroup() != _group)) width += GRAPHICS_UI_TAB_LEFT_MARGIN; }
void TetrahedronModel::draw(const core::visual::VisualParams* vparams) { #ifndef SOFA_NO_OPENGL if (mstate && _topology && vparams->displayFlags().getShowCollisionModels()) { if (vparams->displayFlags().getShowWireFrame()) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glEnable(GL_LIGHTING); //Enable<GL_BLEND> blending; //glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, getColor4f()); static const float emissive[4] = { 0.0f, 0.0f, 0.0f, 0.0f}; static const float specular[4] = { 1.0f, 1.0f, 1.0f, 1.0f}; glMaterialfv (GL_FRONT_AND_BACK, GL_EMISSION, emissive); glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, specular); glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 20); for (int i=0; i<size; i++) { draw(vparams,i); } glColor3f(1.0f, 1.0f, 1.0f); glDisable(GL_LIGHTING); if (vparams->displayFlags().getShowWireFrame()) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } if (getPrevious()!=NULL && vparams->displayFlags().getShowBoundingCollisionModels()) getPrevious()->draw(vparams); #endif /* SOFA_NO_OPENGL */ }
void CubeModel::draw(const core::visual::VisualParams* vparams) { if (!isActive() || !((getNext()==NULL)?vparams->displayFlags().getShowCollisionModels():vparams->displayFlags().getShowBoundingCollisionModels())) return; int level=0; CollisionModel* m = getPrevious(); float color = 1.0f; while (m!=NULL) { m = m->getPrevious(); ++level; color *= 0.5f; } Vec<4,float> c; if (isSimulated()) c=Vec<4,float>(1.0f, 1.0f, 1.0f, color); else c=Vec<4,float>(1.0f, 1.0f, 1.0f, color); std::vector< Vector3 > points; for (int i=0; i<size; i++) { const Vector3& vmin = elems[i].minBBox; const Vector3& vmax = elems[i].maxBBox; points.push_back(Vector3(vmin[0], vmin[1], vmin[2])); points.push_back(Vector3(vmin[0], vmin[1], vmax[2])); points.push_back(Vector3(vmin[0], vmax[1], vmin[2])); points.push_back(Vector3(vmin[0], vmax[1], vmax[2])); points.push_back(Vector3(vmax[0], vmin[1], vmin[2])); points.push_back(Vector3(vmax[0], vmin[1], vmax[2])); points.push_back(Vector3(vmax[0], vmax[1], vmin[2])); points.push_back(Vector3(vmax[0], vmax[1], vmax[2])); points.push_back(Vector3(vmin[0], vmin[1], vmin[2])); points.push_back(Vector3(vmin[0], vmax[1], vmin[2])); points.push_back(Vector3(vmin[0], vmin[1], vmax[2])); points.push_back(Vector3(vmin[0], vmax[1], vmax[2])); points.push_back(Vector3(vmax[0], vmin[1], vmin[2])); points.push_back(Vector3(vmax[0], vmax[1], vmin[2])); points.push_back(Vector3(vmax[0], vmin[1], vmax[2])); points.push_back(Vector3(vmax[0], vmax[1], vmax[2])); points.push_back(Vector3(vmin[0], vmin[1], vmin[2])); points.push_back(Vector3(vmax[0], vmin[1], vmin[2])); points.push_back(Vector3(vmin[0], vmax[1], vmin[2])); points.push_back(Vector3(vmax[0], vmax[1], vmin[2])); points.push_back(Vector3(vmin[0], vmin[1], vmax[2])); points.push_back(Vector3(vmax[0], vmin[1], vmax[2])); points.push_back(Vector3(vmin[0], vmax[1], vmax[2])); points.push_back(Vector3(vmax[0], vmax[1], vmax[2])); } vparams->drawTool()->drawLines(points, 1, Vec<4,float>(c)); if (getPrevious()!=NULL) getPrevious()->draw(vparams); }
size_t ReadsLayout::getBegin(size_t index) const { while (getPrevious(index) != 0) { index = getPrevious(index); } return index; }
vector<shared_ptr<LinkedState>> PathHandler::getPath(shared_ptr<LinkedState> end) { vector<shared_ptr<LinkedState>> path = vector<shared_ptr<LinkedState>>(); auto iterNode = end; do { path.push_back(iterNode); iterNode = iterNode->getPrevious(); } while (iterNode->getPrevious()); path.push_back(iterNode); reverse(path.begin(), path.end()); //abych mìl cestu od zaèátku do konce return path; }
size_t ReadsLayout::reverseComplement(size_t index) { if (getNext(index) != 0) { cout << "size_t ReadsLayout::reverseComplement(size_t index) problem\n"; sendBugReportPlease(cerr); } unsigned int reversePos = getPosition(index) + 1; size_t pTmp; size_t previous; do { setDirection(index, !getDirection(index)); setPosition(index, reversePos - getPosition(index)); //swap links pTmp = getNext(index); setNext(index, getPrevious(index)); setPrevious(index, pTmp); previous = index; index = getNext(index); } while (index != 0); return previous; }
int CMenu::onKey(int key) { switch(key){ case CKeypad::KEYPAD_SELECT: if(mdisplayedItem!=NULL) { if(mdisplayedItem->callback!=NULL) mdisplayedItem->callback(); mlastCmd = mdisplayedItem->cmd; return mlastCmd; } break; case CKeypad::KEYPAD_DOWN: mdisplayedItem = getNext(); draw(); break; case CKeypad::KEYPAD_UP: mdisplayedItem = getPrevious(); draw(); break; default: // do nothing break; } return 0; }
int meshOperation::getPrevious_bc( int center_index, int v, mesh& m ) { int prev = getPrevious(center_index,v,m); if(prev < 0){ return getLast(center_index,v,m); } return prev; }
void ReadsLayout::flagReads(size_t index, char state) { while (index!=0) { R->setFlag(index,state); index=getPrevious(index); } }
int meshOperation::getFirst( int center_index, int v, mesh& m ) { int actual = v, previous; while((previous =getPrevious(center_index,actual,m))>=0){ actual = previous; } return actual; }
unsigned int ReadsLayout::getNReads(size_t listIndex) const { //return the total number of bases in the layout if (getNext(listIndex) != 0) { cout << "size_t ReadsLayout::getCoverage(size_t listIndex) problem\n"; sendBugReportPlease(cerr); } unsigned int count = 1; while (getPrevious(listIndex) != 0) { count++; listIndex = getPrevious(listIndex); } return count; }
PathPoint Path::update(Vector3<float> refPos, Vector3<float> playerPos) { float D_val; PathPoint current = getCurrent(); PathPoint previous = getPrevious(); float diffX = refPos.x - current.getPosition().x; float diffY = refPos.y - current.getPosition().y; float diffZ = refPos.z - current.getPosition().z; float playerDistFromPlane = 0; float firstDistFromPlane = 0; Vector3<float> vect1 (current.getPosition().x - previous.getPosition().x, current.getPosition().y - previous.getPosition().y, current.getPosition().z - previous.getPosition().z); Vector3<float> vect2 (current.getPosition().x + current.getUp().x, current.getPosition().y + current.getUp().y, current.getPosition().z + current.getUp().z); Vector3<float> normal; float distance = sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ); PathPoint firstChoice = getAt(current.getFirstID()); if (distance < RANGE_CHECK) { if (current.getNumberOfIDs() == 1) { setChoice(current.getFirstID()); return getCurrent(); } normal = vect1.Cross(vect2).Normalized(); D_val = (current.getPosition().x * normal.x + current.getPosition().y * normal.y + current.getPosition().z * normal.z) * -1.0f; playerDistFromPlane = (normal.x * playerPos.x) + (normal.y * playerPos.y) + (normal.z * playerPos.z) + D_val; if (abs(playerDistFromPlane) < MID_BUFFER_WIDTH && current.getNumberOfIDs() == 3) { setChoice(current.getThirdID()); return getCurrent(); } firstDistFromPlane = normal.x * firstChoice.getPosition().x + normal.y * firstChoice.getPosition().y + normal.z * firstChoice.getPosition().z + D_val; if (playerDistFromPlane / abs(playerDistFromPlane) == firstDistFromPlane / abs(firstDistFromPlane)) { setChoice(current.getFirstID()); return getCurrent(); } else { setChoice(current.getSecondID()); return getCurrent(); } } return getCurrent(); }
void RayModel::draw(const core::visual::VisualParams* vparams) { #ifndef SOFA_NO_OPENGL if( !vparams->isSupported(core::visual::API_OpenGL) ) return; if (vparams->displayFlags().getShowCollisionModels()) { glDisable(GL_LIGHTING); glColor4fv(getColor4f()); for (int i=0; i<size; i++) { draw(vparams,i); } } if (getPrevious()!=NULL && vparams->displayFlags().getShowBoundingCollisionModels()) getPrevious()->draw(vparams); #endif /* SOFA_NO_OPENGL */ }
void nLight::unregisterNode() { if(!renderer) { return; } if(getNext()) { getNext()->setPrevious(getPrevious()); } if(getPrevious()) { getPrevious()->setNext(getNext()); } if(renderer->frontLight == this) { renderer->frontLight = dynamic_cast<nLight *>(getNext()); } if(renderer->tailLight == this) { renderer->tailLight = dynamic_cast<nLight *>(getPrevious()); } renderer = 0; }
double TimeStepFunctionNewtonAdaptive::suggestNext(double /*t_current*/) { double t=0.0; // the this is the first time step // then we use the minimum time step size if ( getStep() == 0 ) { t = getPrevious() + _min_ts; } else // not the first time step { double tmp_dt = 0.0; double tmp_multiplier; //double t_pre = getPrevious(); size_t i; // get the first multiplier by default if ( _multiplier_vector.size() > 0 ) tmp_multiplier = _multiplier_vector[0]; // number of iterations must be provided externally from the solver class int iter_times = this->_iter_times; // finding the right multiplier for ( i=0; i<_iter_times_vector.size(); i++ ) if ( iter_times > _iter_times_vector[i] ) tmp_multiplier = _multiplier_vector[i]; // multiply the the muliplier tmp_dt = _dt_pre * tmp_multiplier; // check whether out of the boundary if ( tmp_dt < _min_ts ) tmp_dt = _min_ts; else if ( tmp_dt > _max_ts ) tmp_dt = _max_ts; // getting the next time step point t = getPrevious() + tmp_dt; } if (t > getEnd()) return getEnd(); else return t; };
int test_getPrevious() { int valid = 0; int previous = 0; struct doublyLinkedListNode *root = NULL; addNode(&root, createNode(1)); addNode(&root, createNode(10)); addNode(&root, createNode(100)); addNode(&root, createNode(1000)); previous = getPrevious(root, 1); valid += assertTrue("test_getPrevious: The previous for 1 is 0 (does not exist)", previous == 0); previous = getPrevious(root, 100); valid += assertTrue("test_getPrevious: The previous for 100 is 10", previous == 10); deleteList(&root); return valid; }
int meshOperation::getPrevious_bc( int center_index, int v, mesh& m , bool * trueNeighbor) { int prev = getPrevious(center_index,v,m); if(trueNeighbor != NULL){ *trueNeighbor = prev >= 0; } if(prev < 0){ return getLast(center_index,v,m); } return prev; }
void ReadsLayout::writeReadsAsFasta(size_t index, ostream &out) { while (index!=0) { out << '@' << index << '\n'; out << getDirectRead(index) << endl; out << '+' << index << '\n'; for (int i=0; i<54; i++) //fastq out << 'C'; out << '\n'; index=getPrevious(index); } }
void ReadsLayout::setLayoutNodeId(size_t layout, unsigned int nodeId) { if (getNext(layout) != 0) { cout << "void ReadsLayout::setLayoutNodeId(size_t layout, unsigned int nodeId) problem\n"; sendBugReportPlease(cerr); } do { setNodeId(layout, nodeId); layout = getPrevious(layout); } while (layout != 0); }
void ReadsLayout::initLayout(size_t layout, int pos, bool dir, unsigned int nodeId) { if (getNext(layout) != 0 || getPrevious(layout) != 0) { cout << "void ReadsLayout::initLayout(size_t layout, int pos, bool dir, unsigned int nodeId) problem\n"; cout << "layout=" << layout << " next=" << getNext(layout) << " previous=" << getPrevious(layout) << endl; cout << "layout-1=" << layout-1 << " next=" << getNext(layout-1) << " previous=" << getPrevious(layout-1) << endl; cout << "layout+1=" << layout+1 << " next=" << getNext(layout+1) << " previous=" << getPrevious(layout+1) << endl; sendBugReportPlease(cerr); } setPosition(layout, pos, dir); setNodeId(layout, nodeId); }
void ReadsLayout::getVcoverage(size_t listIndex, bool direction, vector<unsigned int> &cov) { unsigned int pos; unsigned int sequenceLength=getSequenceLength(listIndex); int rl=R->getReadsLength(); size_t index; cov.clear(); cov.assign(sequenceLength,0); vector<unsigned int> tmp; tmp.assign(sequenceLength,0); if (direction) { index = getBegin(listIndex); while (index != 0) { pos = getPosition(index); cov[pos - 1]++; index = getNext(index); } } else { index = listIndex; sequenceLength-= (rl-1); while (index != 0) { pos = getPosition(index); pos=sequenceLength-pos; cov[pos]++; index = getPrevious(index); } } tmp[0]=cov[0]; for (size_t i=1; i<cov.size(); i++) { cov[i]=cov[i]+cov[i-1]; tmp[i]=cov[i]; } for (size_t i=rl; i<cov.size(); i++) cov[i]-=tmp[i-rl]; }
Angle Residue::getTorsionPhi() const { Angle result(0.0); if (hasTorsionPhi()) { const Residue* previous = getPrevious(RTTI::getDefault<Residue>()); if (previous != 0) { const Atom* C = 0; const Atom* N = 0; const Atom* CA = 0; AtomConstIterator it; for (it = beginAtom(); +it; ++it) { if (it->getName() == "C") C = &*it; if (it->getName() == "CA") CA = &*it; if (it->getName() == "N") N = &*it; } const Atom* last_C = 0; for (it = previous->beginAtom(); +it; ++it) { if (it->getName() == "C") { last_C = &*it; break; } } if ((N != 0) && (C != 0) && (CA != 0) && (last_C != 0)) { result = calculateTorsionAngle(*last_C, *N, *CA, *C); } else { Log.error() << "Atoms not found:" << last_C << "/" << N << "/" << CA << "/" << C << " in residue " << getFullName() << " " << getID() << endl; } } else { Log.error() << "No previous residue!" << endl; } } return result; }
/* * This tests all the retrieval functions for each type of object. */ static void testObjectRetrieval(CuTest* testCase, int64_t(*getObjectNumberFn)(Flower *flower), void *(*getFirstObjectFn)( Flower *flower), Name(*objectGetNameFn)(void *), void *(*getObjectFn)(Flower *flower, Name name), void *(*constructIterator)(Flower *flower), void(*destructIterator)( void *iterator), void *(*getNext)(void *iterator), void *(*getPrevious)(void *iterator), void *(*copyIterator)( void *iterator), void *object, void *object2) { /* * Test number function */ CuAssertTrue(testCase, getObjectNumberFn(flower) == 2); /* * Test get first function. */ CuAssertTrue(testCase, getFirstObjectFn(flower) == object); /* * Test get function */ if (objectGetNameFn != NULL) { CuAssertTrue(testCase, getObjectFn(flower, objectGetNameFn(object)) == object); CuAssertTrue(testCase, getObjectFn(flower, objectGetNameFn(object2)) == object2); } else { assert(getObjectFn == NULL); } /* * Test iterator. */ void *iterator = constructIterator(flower); CuAssertTrue(testCase, getNext(iterator) == object); CuAssertTrue(testCase, getNext(iterator) == object2); CuAssertTrue(testCase, getNext(iterator) == NULL); void *iterator2 = copyIterator(iterator); CuAssertTrue(testCase, getPrevious(iterator) == object2); CuAssertTrue(testCase, getPrevious(iterator) == object); CuAssertTrue(testCase, getPrevious(iterator) == NULL); destructIterator(iterator); CuAssertTrue(testCase, getPrevious(iterator2) == object2); CuAssertTrue(testCase, getPrevious(iterator2) == object); CuAssertTrue(testCase, getPrevious(iterator2) == NULL); destructIterator(iterator2); }
void noExplictparam() { printf("no file supplied\n"); DlList_T lst=dll_create(); int hasChanged=0; int looping=1; char buff[MAX_LINE]; while(looping) { fgets(buff,MAX_LINE, stdin); strtok(buff,"\n"); if(strcmp(buff,"Q")==0) { dll_destroy(lst); break; } else if(strcmp(buff,".")==0) { showCursor(lst); } else if(strcmp(buff,"a")==0) { int currentlooping=1; while(currentlooping) { fgets(buff,MAX_LINE, stdin); strtok(buff,"\n"); if(strcmp(buff,".")==0) { break; } else { void* input=malloc(sizeof(char)*(strlen(buff))); memcpy(input,buff,strlen(buff)); dll_append(lst, input); dll_move_to(lst,dll_size(lst)); hasChanged=1; //printf("SIZE %d\n",dll_size(lst) ); //showCursor(lst); //printList(lst); } } } else if(strcmp(buff, "\n")==0 || strcmp(buff,"+")==0) { if(getNext(lst)!=NULL) { dll_move_to(lst,getCursorNumber(lst) +1); } else { printf("?\n" ); } } else if(strcmp(buff,"-")==0) { if(getPrevious(lst)!=NULL) { dll_move_to(lst,getCursorNumber(lst) -1); } } else if(strcmp(buff,"$")==0) { if(getHead(lst)==NULL) { printf("?\n"); } else { dll_move_to(lst,dll_size(lst)); showCursor(lst); } } //NEEDS WORKS else if(isdigit(buff)) { printf("GOT HERE\n"); int newIndex=atoi(buff); if(newIndex>=1 && newIndex<=dll_size(lst)) { dll_move_to(lst,newIndex); } } else if(strcmp(buff,".=")==0) { printf("%d\n",getCursorNumber(lst)); } else if(strcmp(buff,"$=")==0) { printf("%d\n",dll_size(lst)); } else if(strcmp(buff,"p")==0) { printListForward(lst); dll_move_to(lst,dll_size(lst)); } else if(strcmp(buff,"q")==0) { if(hasChanged) { printf("? buffer dirty\n"); } else { dll_destroy(lst); printf("\n"); printf("Bye\n"); break; } } else if(strcmp(buff,"w")==0) { printf("?\n"); } else if(strcmp(buff,"wq")==0) { printf("?\n"); } else if(strcmp(buff,"i")==0) { int looping=1; while(looping) { fgets(buff,MAX_LINE, stdin); printf("%d\n",strcmp(buff,".") ); if(strcmp(buff,".")==10) { break; } else { dll_insert_at(lst,getCursorNumber(lst),(void *) buff); dll_move_to(lst,getCursorNumber(lst)); } } } else if(strcmp(buff,"d")==0) { dll_pop(lst,getCursorNumber(lst)); } else { } } }
unsigned int ReadsLayout::sampleOH(size_t listIndex, bool dir, unsigned int maxD, unsigned int maxN, unsigned int *distr) { unsigned int index; unsigned int pos; int nodeLength=getSequenceLength(listIndex); unsigned int rl=R->getReadsLength(); unsigned int nOverlap=0; unsigned int mult; int oh; //overhang if (dir) { index = getBegin(listIndex); pos = 1; index = getNext(index); while (index != 0) { if (pos > maxD && maxD!=0) break; if (nOverlap > maxN && nOverlap!=0) break; mult = 1; oh = getPosition(index) - pos; while (oh == 0) { mult++; index = getNext(index); if (index == 0) break; oh = getPosition(index) - pos; } if (mult > 1) { nOverlap += mult - 1; mult = (mult * mult) - mult; distr[0] += mult; if (index == 0) break; } distr[oh]++; nOverlap++; pos += oh; index = getNext(index); } } else { pos=nodeLength-rl+1; index = getPrevious(listIndex); while (index != 0) { if (nodeLength - (pos+rl-1) > maxD && maxD!=0) break; if (nOverlap > maxN && nOverlap!=0) break; mult = 1; oh = pos - getPosition(index); while (oh == 0) { mult++; index = getPrevious(index); if (index == 0) break; oh = pos - getPosition(index); } if (mult > 1) { nOverlap += mult - 1; mult = (mult * mult) - mult; distr[0] += mult; if (index == 0) break; } distr[oh]++; nOverlap++; pos -= oh; index = getPrevious(index); } } return nOverlap; }
void connectAll() { ForgeHandler::connect(start, SIGNAL(clicked()), this, SLOT(startForge())); ForgeHandler::connect(next, SIGNAL(clicked()), this, SLOT(setNextHeader())); ForgeHandler::connect(previous, SIGNAL(clicked()), this, SLOT(getPrevious())); ForgeHandler::connect(resetButton, SIGNAL(clicked()), this, SLOT(reset())); }
void startLookingforInput(DlList_T lst,const char * filename) { int hasChanged=0; int looping=1; char buff[MAX_LINE]; while(looping) { fgets(buff,MAX_LINE, stdin); strtok(buff,"\n"); if(strcmp(buff,"Q")==0) { dll_destroy(lst); break; } else if(strcmp(buff,".")==0) { showCursor(lst); } else if(strcmp(buff,"a")==0) { int currentlooping=1; while(currentlooping) { fgets(buff,MAX_LINE, stdin); strtok(buff,"\n"); if(strcmp(buff,".")==0) { break; } else { void* input=malloc(sizeof(char)*(strlen(buff))); memcpy(input,buff,strlen(buff)); dll_append(lst, input); dll_move_to(lst,dll_size(lst)); hasChanged=1; //printf("SIZE %d\n",dll_size(lst) ); //showCursor(lst); //printList(lst); } } } else if(strcmp(buff, "\n")==0 || strcmp(buff,"+")==0) { if(getNext(lst)!=NULL) { dll_move_to(lst,getCursorNumber(lst) +1); } else { printf("?\n" ); } } else if(strcmp(buff,"-")==0) { if(getPrevious(lst)!=NULL) { dll_move_to(lst,getCursorNumber(lst) -1); } } else if(strcmp(buff,"$")==0) { if(getHead(lst)==NULL) { printf("?\n"); } else { dll_move_to(lst,dll_size(lst)); showCursor(lst); } } //NEEDS WORKS else if(isdigit(buff)) { printf("GOT HERE\n"); int newIndex=atoi(buff); if(newIndex>=1 && newIndex<=dll_size(lst)) { dll_move_to(lst,newIndex); } } else if(strcmp(buff,".=")==0) { printf("%d\n",getCursorNumber(lst)); } else if(strcmp(buff,"$=")==0) { printf("%d\n",dll_size(lst)); } else if(strcmp(buff,"p")==0) { printListForward(lst); dll_move_to(lst,dll_size(lst)); } else if(strcmp(buff,"q")==0) { if(hasChanged) { printf("? buffer dirty\n"); } else { dll_destroy(lst); printf("\n"); printf("Bye\n"); break; } } else if(strcmp(buff,"w")==0) { FILE* pFile = fopen(filename, "w"); if (!pFile) { perror("The following error occurred:"); } else { struct node* headNode=getHead(lst); while(headNode!=NULL) { fprintf(pFile, strcat((char *) (getData(headNode)),"\n")); headNode=nextNode(headNode); } printf("%s:file\n",filename ); hasChanged=0; fclose(pFile); } } else if(strcmp(buff,"wq")==0) { FILE* pFile = fopen(filename, "w"); if (!pFile) { perror("The following error occurred:"); } else { struct node* headNode=getHead(lst); while(headNode!=NULL) { printf("%s\n", (char *) (getData(headNode)) ); fprintf(pFile, strcat((char *) (getData(headNode)),"\n")); headNode=nextNode(headNode); } printf("%s:file\n",filename ); hasChanged=0; fclose(pFile); dll_destroy(lst); printf("\n"); printf("Bye\n"); break; } } else if(strcmp(buff,"i")==0) { int looping=1; while(looping) { fgets(buff,MAX_LINE, stdin); printf("%d\n",strcmp(buff,".") ); if(strcmp(buff,".")==10) { break; } else { dll_insert_at(lst,getCursorNumber(lst),(void *) buff); dll_move_to(lst,getCursorNumber(lst)); } } } else if(strcmp(buff,"d")==0) { printf("HITIN\n"); dll_pop(lst,getCursorNumber(lst)); } else { } } }