void QgsGeometryCheck::deleteFeatureGeometryPart( QgsFeature &feature, int partIdx, Changes &changes ) const { QgsAbstractGeometryV2* geom = feature.geometry()->geometry(); if ( dynamic_cast<QgsGeometryCollectionV2*>( geom ) ) { static_cast<QgsGeometryCollectionV2*>( geom )->removeGeometry( partIdx ); if ( static_cast<QgsGeometryCollectionV2*>( geom )->numGeometries() == 0 ) { mFeaturePool->deleteFeature( feature ); changes[feature.id()].append( Change( ChangeFeature, ChangeRemoved ) ); } else { mFeaturePool->updateFeature( feature ); changes[feature.id()].append( Change( ChangePart, ChangeRemoved, QgsVertexId( partIdx ) ) ); } } else { mFeaturePool->deleteFeature( feature ); changes[feature.id()].append( Change( ChangeFeature, ChangeRemoved ) ); } }
void Selection::remove(Tile* tile, Item* item) { ASSERT(subsession); ASSERT(tile); ASSERT(item); bool tmp = item->isSelected(); item->deselect(); Tile* new_tile = tile->deepCopy(editor.map); if(tmp) item->select(); if(item->isBorder() && g_settings.getInteger(Config::BORDER_IS_GROUND)) new_tile->deselectGround(); subsession->addChange(newd Change(new_tile)); }
int main(){ int Option=1, Value, i; while(Option){ printf("1) PUSH Stack\n2) POP Stack\n3) Print Stack\n4) Peep\n5) Change Stack\n0) Exit program\n"); scanf("%d", &Option); switch(Option){ case 1: do{ printf("Enter a +ve value: "); scanf("%d", &Value); }while(Value<0); Push(Value); /* allow possitive values */ printf("Stack PUSHed\n\n"); break; case 2: Pop(); printf("Stack POPed\n\n"); break; case 3: StackPrint(); break; case 4: printf("Enter a valid index: "); scanf("%d", &Value); Value = Peep(Value); if(Value) printf("Value at asked index: %d\n\n", Value); else printf("wrong index\n\n"); break; case 5: printf("Enter a valid index & value: "); scanf("%d %d", &i, &Value); Change(i,Value); printf("Value changed\n\n"); break; case 0: DeleteStack(); break; default: printf("Enter a valid choice\n\n"); break; } } return 1; }
int Copy(int copy, int index) { if (test[copy] > move_pos[index][copy]) if (copy > 0) return Change(copy - 1); else { No(); return 0; } test[copy] = move_pos[index][copy]; ++copy; while (copy < p) test[copy++] = 1; return 0; }
int ChangeById(mlink * h, id_tm who, mem_t sz, maddr_t * addr) { mlink *p = h; if (NULL == h || sz < 0) return -1; if (NULL == (p = FindById(p, who))) return -1; if (-1 == Change(p, sz, addr)) return -1; return 0; }
int main() { int i,j; for (i=0; i<3; i++) for (j=0; j<3; j++) scanf("%d",&a[i][j]); Change(a); for (i=0; i<3; i++) { for (j=0; j<3; j++) printf("%d ",a[i][j]); printf("\n"); } return 0; }
void Selection::add(Tile* tile, Spawn* spawn) { ASSERT(subsession); ASSERT(tile); ASSERT(spawn); if(spawn->isSelected()) return; // Make a copy of the tile with the item selected spawn->select(); Tile* new_tile = tile->deepCopy(editor.map); spawn->deselect(); subsession->addChange(newd Change(new_tile)); }
int ChangeByoff(mlink * h, offset_t off, mem_t sz, maddr_t * addr) { mlink *p = h; if (NULL == h || off > Count(h) || off < 0 || sz < 0) return -1; if (NULL == (p = FindByoff(p, off))) return -1; if (-1 == Change(p, sz, addr)) return -1; return 0; }
bool ScrollListShape::setSelectDown(ulen pos) // pos -> down , -> up , unchanged { ulen count=info->getLineCount(); Replace_min(pos,count); for(ulen i=pos; i<count ;i++) { if( info->getLine(i).type==ComboInfoText ) { return Change(select,i); } } for(ulen i=pos; i-- ;) { if( info->getLine(i).type==ComboInfoText ) { return Change(select,i); } } return false; }
void Selection::clear() { if(session) { for(TileVector::iterator it = tiles.begin(); it != tiles.end(); it++) { Tile* new_tile = (*it)->deepCopy(editor.map); new_tile->deselect(); subsession->addChange(newd Change(new_tile)); } } else { for(TileVector::iterator it = tiles.begin(); it != tiles.end(); it++) { (*it)->deselect(); } tiles.clear(); } }
void WhitespaceManager::breakToken(const FormatToken &Tok, unsigned Offset, unsigned ReplaceChars, StringRef PreviousPostfix, StringRef CurrentPrefix, bool InPPDirective, unsigned Spaces) { Changes.push_back(Change( true, SourceRange(Tok.getStartOfNonWhitespace().getLocWithOffset(Offset), Tok.getStartOfNonWhitespace().getLocWithOffset( Offset + ReplaceChars)), Spaces, Spaces, 1, PreviousPostfix, CurrentPrefix, // FIXME: Unify token adjustment, so we don't split it between // BreakableToken and the WhitespaceManager. That would also allow us to // correctly store a tok::TokenKind instead of rolling our own enum. tok::unknown, InPPDirective && !Tok.IsFirst)); }
int main() { freopen("name.in","r",stdin); freopen("name.out","w",stdout); scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i][0]); for(int i=1;i<=n;i++) scanf("%d",&a[i][1]); Build(1,n); scanf("%d",&m); for(int i=1,x,y,z;i<=m;i++) { scanf("%d%d%d",&x,&y,&z); Change(1,x,y,z); } printf("%lld\n",t[1].sum[0]); }
//перенос релиза серии на 7 дней void AnimeList::ModifySeries() { Date release; if(seriesDate.IsCursor()) { release = ~dateSeries; operator+=(release, 7); seriesDate.Set(1, release); series.number = seriesDate.Get(Series); series.release = release; SeriesEdit(); ModifyAnimeSeries(); } Change(); ChangeSeries(); }
void QQuickChangeSet::change(QVector<Change> *changes) { QVector<Insert>::iterator insert = m_inserts.begin(); QVector<Change>::iterator change = m_changes.begin(); for (QVector<Change>::iterator cit = changes->begin(); cit != changes->end(); ++cit) { for (; insert != m_inserts.end() && insert->end() < cit->index; ++insert) {} for (; insert != m_inserts.end() && insert->index < cit->end(); ++insert) { const int offset = insert->index - cit->index; const int count = cit->count + cit->index - insert->index - insert->count; if (offset == 0) { cit->index = insert->index + insert->count; cit->count = count; } else { cit = changes->insert(++cit, Change(insert->index + insert->count, count)); --cit; cit->count = offset; } } for (; change != m_changes.end() && change->index + change->count < cit->index; ++change) {} if (change == m_changes.end() || change->index > cit->index + cit->count) { if (cit->count > 0) { change = m_changes.insert(change, *cit); ++change; } } else { if (cit->index < change->index) { change->count += change->index - cit->index; change->index = cit->index; } if (cit->index + cit->count > change->index + change->count) { change->count = cit->index + cit->count - change->index; QVector<Change>::iterator cbegin = change; QVector<Change>::iterator cend = ++cbegin; for (; cend != m_changes.end() && cend->index <= change->index + change->count; ++cend) { if (cend->index + cend->count > change->index + change->count) change->count = cend->index + cend->count - change->index; } if (cbegin != cend) { change = m_changes.erase(cbegin, cend); --change; } } } } }
void QDeclarativeChangeSet::applyChanges(QVector<Change> &changes) { QVector<Insert>::iterator insert = m_inserts.begin(); QVector<Change>::iterator change = m_changes.begin(); for (QVector<Change>::iterator cit = changes.begin(); cit != changes.end(); ++cit) { for (; insert != m_inserts.end() && insert->end() < cit->index; ++insert) {} for (; insert != m_inserts.end() && insert->index < cit->end(); ++insert) { const int offset = insert->index - cit->index; const int count = cit->count + cit->index - insert->index - insert->count; if (offset == 0) { cit->index = insert->index + insert->count; cit->count = count; } else { cit = changes.insert(++cit, Change(insert->index + insert->count, count)); --cit; cit->count = offset; } } for (; change != m_changes.end() && change->index + change->count < cit->index; ++change) {} if (change == m_changes.end() || change->index > cit->index + cit->count) { if (cit->count > 0) { change = m_changes.insert(change, *cit); ++change; } } else { if (cit->index < change->index) { change->count += change->index - cit->index; change->index = cit->index; } if (cit->index + cit->count > change->index + change->count) { change->count = cit->index + cit->count - change->index; QVector<Change>::iterator rbegin = change; QVector<Change>::iterator rend = ++rbegin; for (; rend != m_changes.end() && rend->index <= change->index + change->count; ++rend) { if (rend->index + rend->count > change->index + change->count) change->count = rend->index + rend->count - change->index; } if (rbegin != rend) { change = m_changes.erase(rbegin, rend); --change; } } } } }
void WhitespaceManager::replaceWhitespaceInToken( const FormatToken &Tok, unsigned Offset, unsigned ReplaceChars, StringRef PreviousPostfix, StringRef CurrentPrefix, bool InPPDirective, unsigned Newlines, unsigned Spaces) { Changes.push_back(Change( true, SourceRange(Tok.getStartOfNonWhitespace().getLocWithOffset(Offset), Tok.getStartOfNonWhitespace().getLocWithOffset( Offset + ReplaceChars)), Spaces, Spaces, Newlines, PreviousPostfix, CurrentPrefix, // If we don't add a newline this change doesn't start a comment. Thus, // when we align line comments, we don't need to treat this change as one. // FIXME: We still need to take this change in account to properly // calculate the new length of the comment and to calculate the changes // for which to do the alignment when aligning comments. Tok.Type == TT_LineComment && Newlines > 0 ? tok::comment : tok::unknown, InPPDirective && !Tok.IsFirst)); }
void MeasuresTab::Init(ScatterCtrl& scatter) { CtrlLayout(*this); SizePos(); pscatter = &scatter; xMin <<= scatter.GetXMin(); xMax <<= scatter.GetXRange() + scatter.GetXMin(); yMin <<= scatter.GetYMin(); yMax <<= scatter.GetYRange() + scatter.GetYMin(); yMin2 <<= scatter.GetYMin2(); yMax2 <<= scatter.GetY2Range() + scatter.GetYMin2(); butUpdate.WhenAction = THISBACK(Change); Change(); }
void QgsGeometryContainedCheck::fixError( QgsGeometryCheckError *error, int method, const QMap<QString, int> & /*mergeAttributeIndices*/, Changes &changes ) const { QgsGeometryContainedCheckError *containerError = static_cast<QgsGeometryContainedCheckError *>( error ); QgsFeaturePool *featurePoolA = mContext->featurePools[ error->layerId() ]; QgsFeaturePool *featurePoolB = mContext->featurePools[ containerError->containingFeature().first ]; QgsFeature featureA; QgsFeature featureB; if ( !featurePoolA->get( error->featureId(), featureA ) || !featurePoolB->get( containerError->containingFeature().second, featureB ) ) { error->setObsolete(); return; } // Check if error still applies QgsGeometryCheckerUtils::LayerFeature layerFeatureA( featurePoolA, featureA, true ); QgsGeometryCheckerUtils::LayerFeature layerFeatureB( featurePoolB, featureB, true ); std::unique_ptr< QgsGeometryEngine > geomEngineA = QgsGeometryCheckerUtils::createGeomEngine( layerFeatureA.geometry(), mContext->tolerance ); std::unique_ptr< QgsGeometryEngine > geomEngineB = QgsGeometryCheckerUtils::createGeomEngine( layerFeatureB.geometry(), mContext->tolerance ); if ( !( geomEngineB->contains( layerFeatureA.geometry() ) && !geomEngineA->contains( layerFeatureB.geometry() ) ) ) { error->setObsolete(); return; } // Fix error if ( method == NoChange ) { error->setFixed( method ); } else if ( method == Delete ) { changes[error->layerId()][featureA.id()].append( Change( ChangeFeature, ChangeRemoved ) ); featurePoolA->deleteFeature( featureA.id() ); error->setFixed( method ); } else { error->setFixFailed( tr( "Unknown method" ) ); } }
size_t KeyBar::Change(const KeyBarTitles *Kbt) { size_t Result=0; if (!Kbt) return Result; static DWORD Groups[]= { 0,KBL_MAIN, KEY_SHIFT,KBL_SHIFT, KEY_CTRL,KBL_CTRL, KEY_ALT,KBL_ALT, KEY_CTRL|KEY_SHIFT,KBL_CTRLSHIFT, KEY_ALT|KEY_SHIFT,KBL_ALTSHIFT, KEY_CTRL|KEY_ALT,KBL_CTRLALT, KEY_CTRL|KEY_ALT|KEY_SHIFT,KBL_CTRLALTSHIFT, }; for (size_t I = 0; I < Kbt->CountLabels; ++I) { WORD Pos=Kbt->Labels[I].Key.VirtualKeyCode; DWORD Shift=0,Flags=Kbt->Labels[I].Key.ControlKeyState; if(Flags&(LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)) Shift|=KEY_CTRL; if(Flags&(LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)) Shift|=KEY_ALT; if(Flags&SHIFT_PRESSED) Shift|=KEY_SHIFT; if (Pos >= VK_F1 && Pos <= VK_F24) { for (unsigned J=0; J < ARRAYSIZE(Groups); J+=2) { if (Groups[J] == Shift) { Change(Groups[J+1],Kbt->Labels[I].Text,Pos-VK_F1); Result++; break; } } } } return Result; }
/*--------------------------------------------------------------------------- This function will update either the video texture, or depth texture, or both (if applicable). It may also recofigure the filter if the selected input has a different resolution. Returns true if either of the textures were updated. ---------------------------------------------------------------------------*/ bool Filter::Update(Buffers &Buffer) { if (!Ready()) {return false;} //Test for resolution change, if applicable Change(Buffer); bool Updated = false; if (Buffer.VideoUpdated(VideoUpdateID) && EnableVideo) { Texture &VideoFront = Buffer.GetVideo(); MutexControl Mutex(VideoFront.GetMutexHandle()); if (Mutex.LockRequest()) { Video.Bind(0); Video.Update(VideoFront); Video.Unbind(0); Mutex.Unlock(); Updated |= true; } } if (Buffer.DepthUpdated(DepthUpdateID) && EnableDepth) { Texture &DepthFront = Buffer.GetDepth(); MutexControl Mutex(DepthFront.GetMutexHandle()); if (Mutex.LockRequest()) { Depth.Bind(0); Depth.Update(DepthFront); Depth.Unbind(0); Mutex.Unlock(); Updated |= true; } } #if defined (DEBUG) GLenum Error = glGetError(); if (Error != GL_NO_ERROR) {throw dexception("OpenGL generated an error: %s", Debug::ErrorGL(Error));} #endif return Updated; }
void Properties::on_devicePathButton_clicked(int device, QLineEdit *line) { QString p=line->text(); if (p.length()==0) { p=QDir::homePath(); } ppl6::CString q=tr("Select directory with your files for device type: %s"); ppl6::CString Tmp; Tmp.Setf((const char*)q,(const char*)wm->GetDeviceName(device)); QString dir = QFileDialog::getExistingDirectory(this, Tmp, p, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if(dir.length()) { line->setText(dir); Change(); } }
void TheGame(int liveArray[BOARDH][BOARDW], int tempArray[BOARDH][BOARDW]) { int i = 1; /* Counter */ char generation = 'y'; /* Keep playing the game y/n variable */ do { Copier(liveArray, tempArray); Change(tempArray, liveArray); printf("Generation %d:\n", i); Printer(liveArray); printf("Print next generation? (y/n): "); scanf(" %c", &generation); i++; } while(generation == 'y'); }
void Selection::add(Tile* tile, Item* item) { ASSERT(subsession); ASSERT(tile); ASSERT(item); if(item->isSelected()) return; // Make a copy of the tile with the item selected item->select(); Tile* new_tile = tile->deepCopy(editor.map); item->deselect(); if(settings.getInteger(Config::BORDER_IS_GROUND)) if(item->isBorder()) new_tile->selectGround(); subsession->addChange(newd Change(new_tile)); }
void Properties::on_addDirectory_clicked() { QString p; if (LastHDSearchDir.isEmpty()) LastHDSearchDir=QDir::currentPath(); p=LastHDSearchDir; QString dir = QFileDialog::getExistingDirectory(this, tr("Select the directory you want to add to the harddisk search"), p, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if(dir.length()) { LastHDSearchDir=dir; // Sofern das Verzeichnis noch nicht in der Liste ist. fügen wir es hinzu QList<QListWidgetItem *> list; list=ui.directoryList->findItems (dir, Qt::MatchExactly); if (list.count()==0) { ui.directoryList->addItem(dir); Change(); } } }
int main() { int i,j,n,m,k,v,sum; scanf("%d",&n); getchar(); while(n--) { scanf("%s",a); m=strlen(a);k=0;j=0; memset(b,0,sizeof(b)); for(i=0;i<m;i++) { if(i%6!=0||i==0) b[k][j++]=(int)a[i]; else { k++;j=0; b[k][j++]=(int)a[i]; } } /*for(i=0;i<=k;i++) { for(j=0;j<6;j++) printf("%d ",b[i][j]); puts(""); }*/ v=0;sum=0; for(i=0;i<6;i++) { sum=0; for(j=0;j<=k;j++) sum+=b[j][i]; c[v++]=Change(sum); //printf("sum=%d\n",sum); } for(i=0;i<v;i++) printf("%d",c[i]); puts(""); } system("pause"); return 0; }
/******************************完成一次转换******************************** * 函 数:u16 One_Change(void); * 功 能:控制DS18B20完成一次温度转换 * 参 数:无 * 返回值:无 * 更 新:无 * 备 注:无 若要读出当前的温度数据我们需要执行两次工作周期, 第一个周期为复位、跳过ROM指令(0xCC)、 执行温度转换存储器操作指令(0x44)、 等待500uS温度转换时间。 紧接着执行第二个周期为复位、 跳过ROM指令(0xCC)、执行读RAM的存储器操作指令(0xBE)、 读数据(最多为9个字节,中途可停止,只读简单温度值则读前2个字节即可)。 ****************************************************************************/ extern u16 One_Change(void) { ErrorStatus i; do { i = Init_18B20(); }while(!i); Skip_ID();//跳过ROM指令 Change();//执行温度转换存储器操作指令 delay1ms(10); do { i = Init_18B20(); }while(!i); Skip_ID();//跳过ROM指令 Read_Ram(); return (Tmp_Get()); }
void QgsGeometryContainedCheck::fixError( QgsGeometryCheckError* error, int method, int /*mergeAttributeIndex*/, Changes &changes ) const { QgsGeometryContainedCheckError* coverError = static_cast<QgsGeometryContainedCheckError*>( error ); QgsFeature feature; QgsFeature otherFeature; if ( !mFeaturePool->get( error->featureId(), feature ) || !mFeaturePool->get( coverError->otherId(), otherFeature ) ) { error->setObsolete(); return; } // Check if error still applies QgsGeometry featureGeom = feature.geometry(); QgsGeometryEngine* geomEngine = QgsGeometryCheckerUtils::createGeomEngine( featureGeom.geometry(), QgsGeometryCheckPrecision::tolerance() ); if ( !geomEngine->within( *otherFeature.geometry().geometry() ) ) { delete geomEngine; error->setObsolete(); return; } delete geomEngine; // Fix error if ( method == NoChange ) { error->setFixed( method ); } else if ( method == Delete ) { changes[feature.id()].append( Change( ChangeFeature, ChangeRemoved ) ); mFeaturePool->deleteFeature( feature ); error->setFixed( method ); } else { error->setFixFailed( tr( "Unknown method" ) ); } }
void RageCompiledGeometry::Set( const vector<msMesh> &vMeshes, bool bNeedsNormals ) { m_bNeedsNormals = bNeedsNormals; size_t totalVerts = 0; size_t totalTriangles = 0; m_bAnyNeedsTextureMatrixScale = false; m_vMeshInfo.resize( vMeshes.size() ); for( unsigned i=0; i<vMeshes.size(); i++ ) { const msMesh& mesh = vMeshes[i]; const vector<RageModelVertex> &Vertices = mesh.Vertices; const vector<msTriangle> &Triangles = mesh.Triangles; MeshInfo& meshInfo = m_vMeshInfo[i]; meshInfo.m_bNeedsTextureMatrixScale = false; meshInfo.iVertexStart = totalVerts; meshInfo.iVertexCount = Vertices.size(); meshInfo.iTriangleStart = totalTriangles; meshInfo.iTriangleCount = Triangles.size(); totalVerts += Vertices.size(); totalTriangles += Triangles.size(); for( unsigned j = 0; j < Vertices.size(); ++j ) { if( Vertices[j].TextureMatrixScale.x != 1.0f || Vertices[j].TextureMatrixScale.y != 1.0f ) { meshInfo.m_bNeedsTextureMatrixScale = true; m_bAnyNeedsTextureMatrixScale = true; } } } this->Allocate( vMeshes ); Change( vMeshes ); }
// Handle spinners in the dialog box void AudioP3Dlg::SpinnerChange(int id,BOOL drag) { switch (id) { case IDC_AUDAMP_BASEXSPIN: cont->basePoint.x = dim->UnConvert(iBaseX->GetFVal()); Change(); break; case IDC_AUDAMP_BASEYSPIN: cont->basePoint.y = dim->UnConvert(iBaseY->GetFVal()); Change(); break; case IDC_AUDAMP_BASEZSPIN: cont->basePoint.z = dim->UnConvert(iBaseZ->GetFVal()); Change(); break; case IDC_AUDAMP_TARGETXSPIN: cont->targetPoint.x = dim->UnConvert(iTargetX->GetFVal()); Change(); break; case IDC_AUDAMP_TARGETYSPIN: cont->targetPoint.y = dim->UnConvert(iTargetY->GetFVal()); Change(); break; case IDC_AUDAMP_TARGETZSPIN: cont->targetPoint.z = dim->UnConvert(iTargetZ->GetFVal()); Change(); break; case IDC_AUDAMP_NUMSAMPLESSPIN: cont->numsamples = iSamples->GetIVal(); Change(); break; case IDC_AUDAMP_THRESHOLDSPIN: cont->threshold = iThreshold->GetFVal(); Change(); break; } ip->RedrawViews(ip->GetTime()); }
SButton::SButton( int nId, Win* parent, unicode_t* txt, int _group, bool _isSet, crect* rect ) : Win( Win::WT_CHILD, Win::WH_TABFOCUS | WH_CLICKFOCUS, parent, rect, nId ), isSet( _isSet ), text( txt ), group( _group ) { if ( !rect ) { GC gc( this ); gc.Set( GetFont() ); cpoint p = gc.GetTextExtents( txt ); if ( p.y < 16 ) { p.y = 16; } p.x += 17 + 4; p.y += 2; SetLSize( LSize( p ) ); } Change( isSet ); }