void KoPathPointMoveCommand::redo() { QUndoCommand::redo(); if (! m_undoCalled) return; applyOffset( 1.0 ); m_undoCalled = false; }
void KoPathPointMoveCommand::undo() { QUndoCommand::undo(); if (m_undoCalled) return; applyOffset( -1.0 ); m_undoCalled = true; }
MojErr MojDbQuotaEngine::applyUsage(MojDbStorageTxn* txn) { MojLogTrace(s_log); for (OffsetMap::ConstIterator i = txn->m_offsetMap.begin(); i != txn->m_offsetMap.end(); ++i) { MojErr err = applyOffset(i.key(), i.value()->offset(), txn); MojErrCheck(err); } return MojErrNone; }
snlPoint snlCircularOffsetCurve::eval ( knot param ) const { // Eval curve at param. // -------------------- // param: Paramter to evaluate at. snlPoint retPoint = base_curve -> eval ( param ); applyOffset ( retPoint, chord_offsetCurve -> eval ( param ), angle_offsetCurve -> eval ( param ), tangent_offsetCurve -> eval ( param ) ); return retPoint; }
void InputToInputMix::apply() const { if (m_index != Input_None) { if (m_source != Input_None) { rc::setInput(m_index, apply(rc::getInput(m_source), rc::getInput(m_index))); } else { rc::setInput(m_index, applyOffset(rc::getInput(m_index))); } } }
MojErr MojDbQuotaEngine::applyUsage(MojDbStorageTxn* txn) { LOG_TRACE("Entering function %s", __FUNCTION__); for (OffsetMap::ConstIterator i = txn->m_offsetMap.begin(); i != txn->m_offsetMap.end(); ++i) { MojErr err = applyOffset(i.key(), i.value()->offset(), txn); MojErrCheck(err); if(!m_db->getQuotaAlert().isEmpty()) //optimization for empty list { err = informQuotaSubscribers(i.key()); MojErrCheck(err); } } return MojErrNone; }
void snlCircularOffsetCurve::vertexNetParam ( snlVertexNet* vNet, double tolerance ) { // Generate an approximation to curve using a parametric analysis. // --------------------------------------------------------------- // vNet: Vertex network to fill with data. // tolerance: Maximum error to curve. int size; snlPoint* pts = 0; if ( tolerance <= 0.0 ) { size = base_curve -> controlPointNet().size(); pts = new snlPoint [ size ]; double minParam = base_curve -> minParam(); double paramStep = ( base_curve -> maxParam() - minParam ) / (double) ( size - 1 ); for ( int index = 0; index < size; index ++ ) { double param = minParam + paramStep * (double) index; pts [ index ] = base_curve -> eval ( param ); applyOffset ( pts [ index ], chord_offsetCurve -> eval ( param ), angle_offsetCurve -> eval ( param ), tangent_offsetCurve -> eval ( param ) ); } } vNet -> vertexNet ( pts, size ); if ( pts ) delete[] pts; }
void snlCircularOffsetCurve::vertexNet ( snlVertexNet* vNet, double tolerance, bool parametric ) { // Return approximation to curve. // -------------------------------- // tolerance: Tolerance to approximate to. // parametric: Do a parametric analysis as opposed to knot refinement. // vNet: Vertex net to fill with data. if ( parametric ) { vertexNetParam ( vNet, tolerance ); return; } snlCtrlPointNetCurve* ctrlPtNet; int size; const snlCtrlPoint* chordOffsetPts; const snlCtrlPoint* angleOffsetPts; const snlCtrlPoint* tangentOffsetPts; // Get control point net to work with. snlCircularOffsetCurve* tmpCurve = 0; if ( tolerance > 0.0 ) { tmpCurve = new snlCircularOffsetCurve ( *this ); tmpCurve -> refine ( tolerance ); ctrlPtNet = new snlCtrlPointNetCurve ( ( tmpCurve -> base_curve ) -> controlPointNet() ); size = ctrlPtNet -> getNumPts(); chordOffsetPts = ( tmpCurve -> chord_offsetCurve ) -> controlPointNet().getCtrlPts(); angleOffsetPts = ( tmpCurve -> angle_offsetCurve ) -> controlPointNet().getCtrlPts(); tangentOffsetPts = ( tmpCurve -> tangent_offsetCurve ) -> controlPointNet().getCtrlPts(); } else { ctrlPtNet = new snlCtrlPointNetCurve ( base_curve -> controlPointNet() ); size = ctrlPtNet -> getNumPts(); chordOffsetPts = chord_offsetCurve -> controlPointNet().getCtrlPts(); angleOffsetPts = angle_offsetCurve -> controlPointNet().getCtrlPts(); tangentOffsetPts = tangent_offsetCurve -> controlPointNet().getCtrlPts(); } snlCtrlPoint* ctrlPts = ctrlPtNet -> getCtrlPtsPtr(); // Offset base curve control points. for ( int index = 0; index < size; index ++ ) applyOffset ( ctrlPts [ index ], chordOffsetPts [ index ], angleOffsetPts [ index ], tangentOffsetPts [ index ] ); // Generate vertex net. vNet -> vertexNet ( ctrlPts, size ); delete ctrlPtNet; if ( tmpCurve ) delete tmpCurve; }
void snlCircularOffsetCurve::refine ( double tolerance ) { // Refine control point net until tolerance is achieved. // ----------------------------------------------------- // // Notes: This is a little tricky because the offset_curve's control points // have to be evaluted relative to the base_curve to get the points to test // for flatness. bool tolOk = false; int deg = base_curve -> degree(); int numTestPts = deg + 1; snlPoint* testPoints = new snlPoint [ numTestPts ]; snlPoint** testPtPtrs = new snlPoint* [ numTestPts ]; for ( int index = 0; index < numTestPts; index ++ ) testPtPtrs [ index ] = testPoints + index; while ( ! tolOk ) { tolOk = true; for ( int index = 0; (unsigned) index < ( base_curve -> controlPointNet().size() ) - deg; index ++ ) { const snlCtrlPoint* basePts = base_curve -> controlPointNet().getCtrlPts(); const snlCtrlPoint* chordOffsetPts = chord_offsetCurve -> controlPointNet().getCtrlPts(); const snlCtrlPoint* angleOffsetPts = angle_offsetCurve -> controlPointNet().getCtrlPts(); const snlCtrlPoint* tangentOffsetPts = tangent_offsetCurve -> controlPointNet().getCtrlPts(); // Generate points to test for flatness. for ( int ptIndex = 0; ptIndex < numTestPts; ptIndex ++ ) { testPoints [ ptIndex ] = basePts [ index + ptIndex ]; applyOffset ( testPoints [ ptIndex ], chordOffsetPts [ index + ptIndex ], angleOffsetPts [ index + ptIndex ], tangentOffsetPts [ index + ptIndex ] ); } // Test for flatness double flatness = ( base_curve ->controlPointNet() ).snlCtrlPointNet::calcFlatness ( testPtPtrs, numTestPts ); if ( flatness > tolerance ) { // Insert knot into surface. Half way between existing knots. const snlKnotVector& knotVect = base_curve -> knotVector(); int insertIndex = index + deg; knot insertParam = ( ( knotVect.val ( insertIndex + 1 ) - knotVect.val ( insertIndex ) ) / 2 ) + knotVect.val ( insertIndex ); base_curve -> insertKnot ( insertParam, true ); chord_offsetCurve -> insertKnot ( insertParam, true ); angle_offsetCurve -> insertKnot ( insertParam, true ); tangent_offsetCurve -> insertKnot ( insertParam, true ); tolOk = false; index ++; // If this is not done then nothing converges if the curvature is too great. } } } delete[] testPoints; }
void QgsMapToolOffsetCurve::canvasReleaseEvent( QgsMapMouseEvent *e ) { mCtrlHeldOnFirstClick = false; if ( e->button() == Qt::RightButton ) { cancel(); return; } if ( mOriginalGeometry.isNull() ) { // first click, get feature to modify deleteRubberBandAndGeometry(); mGeometryModified = false; QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToCurrentLayer( e->pos(), QgsPointLocator::Types( QgsPointLocator::Edge | QgsPointLocator::Area ) ); if ( ( match.hasEdge() || match.hasArea() ) && match.layer() ) { mLayer = match.layer(); QgsFeature fet; if ( match.layer()->getFeatures( QgsFeatureRequest( match.featureId() ) ).nextFeature( fet ) ) { mCtrlHeldOnFirstClick = ( e->modifiers() & Qt::ControlModifier ); //no geometry modification if ctrl is pressed prepareGeometry( match, fet ); mRubberBand = createRubberBand(); if ( mRubberBand ) { mRubberBand->setToGeometry( mManipulatedGeometry, match.layer() ); } mModifiedFeature = fet.id(); createUserInputWidget(); bool hasZ = QgsWkbTypes::hasZ( mLayer->wkbType() ); bool hasM = QgsWkbTypes::hasZ( mLayer->wkbType() ); if ( hasZ || hasM ) { emit messageEmitted( QStringLiteral( "layer %1 has %2%3%4 geometry. %2%3%4 values be set to 0 when using offset tool." ) .arg( mLayer->name() ) .arg( hasZ ? "Z" : "" ) .arg( hasZ && hasM ? "/" : "" ) .arg( hasM ? "M" : "" ) , Qgis::Warning ); } } } if ( mOriginalGeometry.isNull() ) { emit messageEmitted( tr( "Could not find a nearby feature in any vector layer." ) ); cancel(); notifyNotVectorLayer(); } } else { // second click - apply changes double offset = calculateOffset( e->snapPoint() ); applyOffset( offset, e->modifiers() ); } }
void QgsMapToolOffsetCurve::canvasReleaseEvent( QgsMapMouseEvent* e ) { if ( !mCanvas ) { return; } QgsVectorLayer* layer = currentVectorLayer(); if ( !layer ) { deleteRubberBandAndGeometry(); notifyNotVectorLayer(); return; } if ( e->button() == Qt::RightButton ) { deleteRubberBandAndGeometry(); deleteDistanceWidget(); return; } if ( !mOriginalGeometry ) { deleteRubberBandAndGeometry(); mGeometryModified = false; mForceCopy = false; if ( e->button() == Qt::RightButton ) { return; } QgsSnappingUtils* snapping = mCanvas->snappingUtils(); // store previous settings int oldType; double oldSearchRadius; QgsTolerance::UnitType oldSearchRadiusUnit; QgsSnappingUtils::SnapToMapMode oldMode = snapping->snapToMapMode(); snapping->defaultSettings( oldType, oldSearchRadius, oldSearchRadiusUnit ); // setup new settings (temporary) QSettings settings; snapping->setSnapToMapMode( QgsSnappingUtils::SnapAllLayers ); snapping->setDefaultSettings( QgsPointLocator::Edge, settings.value( "/qgis/digitizing/search_radius_vertex_edit", 10 ).toDouble(), ( QgsTolerance::UnitType ) settings.value( "/qgis/digitizing/search_radius_vertex_edit_unit", QgsTolerance::Pixels ).toInt() ); QgsPointLocator::Match match = snapping->snapToMap( e->pos() ); // restore old settings snapping->setSnapToMapMode( oldMode ); snapping->setDefaultSettings( oldType, oldSearchRadius, oldSearchRadiusUnit ); if ( match.hasEdge() && match.layer() ) { mSourceLayerId = match.layer()->id(); QgsFeature fet; if ( match.layer()->getFeatures( QgsFeatureRequest( match.featureId() ) ).nextFeature( fet ) ) { mForceCopy = ( e->modifiers() & Qt::ControlModifier ); //no geometry modification if ctrl is pressed mOriginalGeometry = createOriginGeometry( match.layer(), match, fet ); mRubberBand = createRubberBand(); if ( mRubberBand ) { mRubberBand->setToGeometry( mOriginalGeometry, layer ); } mModifiedFeature = fet.id(); createDistanceWidget(); } } return; } applyOffset(); }