예제 #1
0
void kpTool::notifyModifierStateChanged ()
{
    if (careAboutModifierState ())
    {
        if (m_beganDraw)
            draw (m_currentPoint, m_lastPoint, QRect (m_startPoint, m_currentPoint).normalize ());
        else
        {
            m_currentPoint = currentPoint ();
            m_currentViewPoint = currentPoint (false/*view point*/);
            hover (m_currentPoint);
        }
    }
}
예제 #2
0
파일: ArcView.cpp 프로젝트: hlobit/SimPetri
BOOL CArcView::IntersectsWithRect(const Rect& rectangle)
{
	Point topLeft(rectangle.GetLeft(), rectangle.GetTop());
	Point topRight(rectangle.GetRight(), rectangle.GetTop());
	Point bottomLeft(rectangle.GetLeft(), rectangle.GetBottom());
	Point bottomRight(rectangle.GetRight(), rectangle.GetBottom());

	Point currentPoint(*pathPoints.begin());
	for(auto it=pathPoints.begin() + 1; it != pathPoints.end(); ++it)
	{
		if(rectangle.Contains(currentPoint))
			return TRUE;
		if(Geometry::LinesIntersect(topLeft, topRight, currentPoint, *it))
			return TRUE;
		if(Geometry::LinesIntersect(topLeft, bottomLeft, currentPoint, *it))
			return TRUE;
		if(Geometry::LinesIntersect(bottomLeft, bottomRight, currentPoint, *it))
			return TRUE;
		if(Geometry::LinesIntersect(topRight, bottomRight, currentPoint, *it))
			return TRUE;

		currentPoint = *it;
	}

	return FALSE;
}
예제 #3
0
파일: ArcView.cpp 프로젝트: hlobit/SimPetri
void CArcView::computeEnclosingRect(BOOL init)
{
	CRect unionRect;
	Point currentPoint(*pathPoints.begin());
	for(auto it=pathPoints.begin() + 1; it != pathPoints.end(); ++it)
	{
		//Union des rectangles.
		CRect toAddRect(currentPoint.X, currentPoint.Y, it->X, it->Y);
		toAddRect.NormalizeRect();
		if(toAddRect.Width() == 0) toAddRect.InflateRect(1,0);
		if(toAddRect.Height() == 0) toAddRect.InflateRect(0,1);
		unionRect.UnionRect(unionRect, toAddRect);

		currentPoint = *it;
	}

	if(init)
		enclosingRect = new Rect(unionRect.left, unionRect.top, unionRect.Width(), unionRect.Height());
	else
	{
		enclosingRect->X = unionRect.left;
		enclosingRect->Y = unionRect.top;
		enclosingRect->Width = unionRect.Width();
		enclosingRect->Height = unionRect.Height();
	}
}
예제 #4
0
void MeshFileManager::writeShape(const Grid3D &grid, const QString &path)
{
    QFile file(getRootPath() + path);
    if (!file.open(QIODevice::WriteOnly)) {
        return;
    }

    QTextStream stream(&file);
    stream  << "MeshVersionFormatted 1" << endl
            << "Dimension" << endl
            << "3" << endl;

    stream  << "Vertices" << endl
            <<  grid.getNx() * grid.getNy() * grid.getNz() << endl;

    for (int z = 0; z < grid.getNz(); ++z) {
        for (int y = 0; y < grid.getNy(); ++y) {
            for (int x = 0; x < grid.getNx(); ++x) {
                Point3D currentPoint(grid.getOrigin().getX() + x,
                                     grid.getOrigin().getY() + y,
                                     grid.getOrigin().getZ() + z);

                if (grid.getProperty(currentPoint.getX(), currentPoint.getY(), currentPoint.getZ()) < 0) {
                    stream << currentPoint.format()
                           << endl;
                }
            }
        }
    }

    stream << "End" << endl;
}
// protected
void kpToolText::handleLeftKeyPress (QKeyEvent *e,
    const QList <QString> &textLines, int cursorRow, int cursorCol)
{
#if DEBUG_KP_TOOL_TEXT
    qCDebug(kpLogTools) << "\tleft pressed";
#endif

    if (hasBegunShape ())
        endShape (currentPoint (), normalizedRect ());

    if (!textLines.isEmpty ())
    {
        if ((e->modifiers () & Qt::ControlModifier) == 0)
        {
        #if DEBUG_KP_TOOL_TEXT
            qCDebug(kpLogTools) << "\tmove single char";
        #endif
    
            MoveCursorLeft (textLines, &cursorRow, &cursorCol);
            viewManager ()->setTextCursorPosition (cursorRow, cursorCol);
        }
        else
        {
        #if DEBUG_KP_TOOL_TEXT
            qCDebug(kpLogTools) << "\tmove to start of word";
        #endif
    
            MoveCursorToWordStart (textLines, &cursorRow, &cursorCol);
            viewManager ()->setTextCursorPosition (cursorRow, cursorCol);
        }
    }

    e->accept ();
}
예제 #6
0
void PathDetect::FindLargest(cv::Mat& watershedImage) const
{
    int rows = watershedImage.rows;
    int cols = watershedImage.cols;

    cv::Mat image = watershedImage.clone();
    cv::Point bestPoint;
    int bestPixelCount = 0;
    int areaCount = 0;
    for (int r = 0; r < rows; ++r)
    {
        for (int c = 0; c < cols; ++c)
        {
            cv::Point currentPoint(c, r);
            if (image.at<unsigned char>(currentPoint) == PATH)
            {
                areaCount++;
                int pixelCount = FloodArea(image, currentPoint, 1);
                if (pixelCount > bestPixelCount)
                {
                    bestPixelCount = pixelCount;
                    bestPoint = currentPoint;
                }
            }
        }
    }

    FloodArea(watershedImage, bestPoint, 1);
    SetArea(watershedImage, 1, PATH);
}
예제 #7
0
void kpTool::endInternal ()
{
    if (m_began)
    {
        // before we can stop using the tool, we must stop the current drawing operation (if any)
        if (hasBegunShape ())
            endShapeInternal (m_currentPoint, QRect (m_startPoint, m_currentPoint).normalize ());

        // call user virtual func
        end ();

        // clear leftover statusbar messages
        setUserMessage ();
        setUserShapePoints (currentPoint ());

        // we've stopped using the tool...
        m_began = false;

        // and so we can't be drawing with it
        m_beganDraw = false;

        if (m_mainWindow)
        {
            kpToolToolBar *tb = m_mainWindow->toolToolBar ();
            if (tb)
            {
                tb->hideAllToolWidgets ();
            }
        }

    }
}
예제 #8
0
void ContactPointIterator::continueWith(NCPcutting cutting, ContinuationType continueType) {
    if(continueType != ContinuationType::StartAgain) {
        vec2 infrontOfCutting;
        if(cutting.location == IterationLocation::Ground)
            infrontOfCutting = cutting.ncp->points[cutting.placeBeforeCutting];
        else
            infrontOfCutting = forbiddenAreaEndPoint(cutting.ncp, cutting.placeBeforeCutting);

        vec2 testLineEndPoint;
        if(continueType == ContinuationType::HopOn)
            testLineEndPoint = previousNormalEnd();
        else
            testLineEndPoint = currentPoint();

        if(isOnNormalsSideOf(m_previousPoint, testLineEndPoint, infrontOfCutting)) {
            //"normal" walking direction, set new current point to point after cutting
            m_iterationDirection = IterationDirection::Normal;
            m_ncpPosition = cutting.placeBeforeCutting + 1;

        } else {
            //"reverse" walking direction, set new current point to point before cutting
            m_iterationDirection = IterationDirection::Reverse;
            m_ncpPosition = cutting.placeBeforeCutting;
        }
    } else { //ContinuationType::StartAgain
        if(((cutting.location == IterationLocation::Ground &&
                    isOnNormalsSideOf(m_previousPoint, currentPoint(), cutting.ncp->points[cutting.placeBeforeCutting])) ||
            (cutting.location == IterationLocation::Top &&
                        !isOnNormalsSideOf(m_previousPoint, currentPoint(), cutting.ncp->points[cutting.placeBeforeCutting]))))
                return; // inappropriate location with direction found

        if(cutting.placeBeforeCutting == 0)
            m_iterationDirection = IterationDirection::Normal;
        else if(cutting.placeBeforeCutting == cutting.ncp->points.size() - 1)
            m_iterationDirection = IterationDirection::Reverse;
        else
            return;
        m_ncpPosition = cutting.placeBeforeCutting;
    }

    m_iterationState = IterationState::NCP;
    m_iterationLocation = cutting.location;
    m_ncp = cutting.ncp;
    m_ncp->examinedIndex = m_ncpPosition;
    m_previousPoint = cutting.cuttingPoint;
}
예제 #9
0
void BezierSplineEditor::setSpline(const CubicBezierSpline& spline)
{
    m_spline = spline;
    m_currentPointIndex = -1;
    m_mode = ModeNormal;
    emit currentPoint(BPoint());
    emit modified();
    update();
}
예제 #10
0
void drvGCODE::show_path()
{
	Point currentPoint(0.0f, 0.0f);	
	const Point firstPoint = pathElement(0).getPoint(0);

	for (unsigned int n = 0; n < numberOfElementsInPath(); n++) {
		const basedrawingelement & elem = pathElement(n);

		switch (elem.getType()) {
		case moveto:{
				const Point & p = elem.getPoint(0);
				outf << "\nG00 Z#1000\n";
				outf << "G00 X[#1003*" << p.x_ << "] Y[#1004*" << p.y_ << "]\n";
				outf << "G01 Z#1002\n";
				currentPoint = p;
			}
			break;
		case lineto:{
				const Point & p = elem.getPoint(0);
				outf << "G01 X[#1003*" << p.x_ << "] Y[#1004*" << p.y_ << "]\n";
				currentPoint = p;
			}
			break;
		case closepath:
				outf << "G01 X[#1003*" << firstPoint.x_ << "] Y[#1004*" << firstPoint.y_ << "]\n";
			break;

		case curveto:{
			const Point & cp1 = elem.getPoint(0);
			const Point & cp2 = elem.getPoint(1);
			const Point & ep  = elem.getPoint(2);
			// curve is approximated with a variable number or linear segments.
			// fitpoints should be somewhere between 5 and 50 for reasonable page size plots
			// we compute distance between current point and endpoint and use that to help
			// pick the number of segments to use.
			const float dist = (float) pythagoras((float)(ep.x_ - currentPoint.x_),(float)(ep.y_ - currentPoint.y_)); 
			unsigned int fitpoints = (unsigned int)(dist / 10.0);
			if ( fitpoints < 5 ) fitpoints = 5;
			if ( fitpoints > 50 ) fitpoints = 50;

			for (unsigned int s = 1; s < fitpoints; s++) {
				const float t = 1.0f * s / (fitpoints - 1);
				const Point pt = PointOnBezier(t, currentPoint, cp1, cp2, ep);
				outf << " G01 X[#1003*" << pt.x_ << "] Y[#1004*" << pt.y_ << "]\n";
			}
			currentPoint = ep;

			}
			break;
		default:
			errf << "\t\tFatal: unexpected case in drvgcode " << endl;
			abort();
			break;
		}
	}
}
예제 #11
0
파일: ArcView.cpp 프로젝트: hlobit/SimPetri
void CArcView::Draw(CDC* pDC, const std::vector<CElement*>& selection, CElement* highlight)
{
	computeCollisionPoints(FALSE);
	computeEnclosingRect(FALSE);

	Graphics g = pDC->GetSafeHdc();
	g.SetSmoothingMode(SmoothingModeAntiAlias);
	Color theColor = ColorToDraw(selection, highlight);
	Pen pen(theColor, static_cast<Gdiplus::REAL>(penWidth));
	GraphicsPath arc;

	Point currentPoint(*pathPoints.begin());
	for(auto it=pathPoints.begin() + 1; it != pathPoints.end(); ++it)
	{
		arc.AddLine(currentPoint, *it);
		currentPoint = *it;
	}

	//Annotation de poids
	if(arcModel->getValuation() != 1)
	{
		//Déterminer le point de mi-chemin
		PointF pathAnnotationPoint = annotationPoint((double(valPosition))/100, valDistance);

		//Elements de dessin pour chaine de caracteres
		CString weight;
		weight.Format(_T("%d"), arcModel->getValuation());
		FontFamily fontFamily(L"Arial");
		Font maxfont(&fontFamily, 16, FontStyleRegular, UnitPixel);
		StringFormat stringFormat;
		SolidBrush brush(ColorToDraw(selection, highlight));

		//Décalage à effectuer
		//Peut-être aurait-il suffit de modifier le StringFormat ?
		RectF boundingBox;
		g.MeasureString(weight,-1,&maxfont,pathAnnotationPoint,&stringFormat,&boundingBox);
		pathAnnotationPoint.X -= boundingBox.Width/2;
		pathAnnotationPoint.Y += boundingBox.Height/2;

		//Translation + Symétrie axiale d'axe des abscisses
		g.TranslateTransform(0, pathAnnotationPoint.Y * 2);
		Matrix matrix;
		matrix.SetElements(1, 0, 0, -1, 0, 0);
		g.MultiplyTransform(&matrix);

		//Affichage du poids de l'arc
		g.DrawString(weight, -1, &maxfont, pathAnnotationPoint, &stringFormat, &brush);
		g.ResetTransform();
	}

	//Dessiner le chemin avec une flèche au bout
	pen.SetCustomEndCap(arrowCap);
	pen.SetLineJoin(LineJoinRound);
	g.DrawPath(&pen, &arc);
}
예제 #12
0
void KisColorSelectorRing::paintCache()
{
    QImage cache(m_cachedSize, m_cachedSize, QImage::Format_ARGB32_Premultiplied);

    Eigen::Vector2i center(cache.width()/2., cache.height()/2.);

    for(int x=0; x<cache.width(); x++) {
        for(int y=0; y<cache.height(); y++) {
            Eigen::Vector2i currentPoint((float)x, (float)y);
            Eigen::Vector2i relativeVector = currentPoint-center;

            qreal currentRadius = relativeVector.squaredNorm();
            currentRadius=sqrt(currentRadius);

            if(currentRadius < outerRadius()+1
               && currentRadius > innerRadius()-1)
            {

                float angle = std::atan2((float)relativeVector.y(), (float)relativeVector.x())+((float)M_PI);
                angle/=2*((float)M_PI);
                angle*=359.f;
                if(currentRadius < outerRadius()
                   && currentRadius > innerRadius()) {
                    cache.setPixel(x, y, m_cachedColors.at(angle));
                }
                else {
                    // draw antialiased border
                    qreal coef=1.;
                    if(currentRadius > outerRadius()) {
                        // outer border
                        coef-=currentRadius;
                        coef+=outerRadius();
                    }
                    else {
                        // inner border
                        coef+=currentRadius;
                        coef-=innerRadius();
                    }
                    coef=qBound(qreal(0.), coef, qreal(1.));
                    int red=qRed(m_cachedColors.at(angle));
                    int green=qGreen(m_cachedColors.at(angle));
                    int blue=qBlue(m_cachedColors.at(angle));

                    // the format is premultiplied, so we have to take care of that
                    QRgb color = qRgba(red*coef, green*coef, blue*coef, 255*coef);
                    cache.setPixel(x, y, color);
                }
            }
            else {
                cache.setPixel(x, y, qRgba(0,0,0,0));
            }
        }
    }
    m_pixelCache = cache;
}
예제 #13
0
void Display::draw(const Graphics::Drawable& object, const Graphics::Point2D<size_t>& origin){
	LOG_INFO("");
	for(size_t currentX =0; currentX < object.width(); ++currentX){
		for(size_t currentY=0; currentY < object.height(); ++currentY){
			Graphics::Point2D<size_t> currentPoint(currentX, currentY);
			if(object.at(currentPoint)){
				setPixel(currentX+origin.width(), currentY + origin.height());
			}
		}
	}
}
예제 #14
0
파일: ArcView.cpp 프로젝트: hlobit/SimPetri
PointF CArcView::annotationPoint(double percent, double orthoDistance)
{
	//Calculer les distances correspondantes à chaque point
	std::vector<double> travelledDistance;
	travelledDistance.push_back(0);
	Point currentPoint(*pathPoints.begin());
	for(auto it=pathPoints.begin() + 1; it != pathPoints.end(); ++it)
	{
		travelledDistance.push_back(
			travelledDistance.back()
			+ Geometry::Distance(currentPoint, *it));
		currentPoint = *it;
	}

	PointF annotationPoint;
	double travelLocation = percent*travelledDistance.back();
	for(unsigned i = 0; i < travelledDistance.size() - 1; ++i)
	{
		if(travelLocation >= travelledDistance.at(i)
			&& travelLocation < travelledDistance.at(i+1))
		{
			//Définir les points
			PointF pointA = PointF(
				static_cast<Gdiplus::REAL>(pathPoints.at(i).X),
				static_cast<Gdiplus::REAL>(pathPoints.at(i).Y)
				);
			PointF pointB = PointF(
				static_cast<Gdiplus::REAL>(pathPoints.at(i+1).X),
				static_cast<Gdiplus::REAL>(pathPoints.at(i+1).Y)
				);
			
			double dx = pointB.X - pointA.X;
			double dy = pointB.Y - pointA.Y;

			//Déterminer le point au pourcentage donné
			double segmentLocation = travelLocation - travelledDistance.at(i);
			double segmentSize = travelledDistance.at(i+1) - travelledDistance.at(i);
			double segmentPercent = segmentLocation/segmentSize;
			annotationPoint.X = pointA.X + static_cast<Gdiplus::REAL>(dx*segmentPercent);
			annotationPoint.Y = pointA.Y + static_cast<Gdiplus::REAL>(dy*segmentPercent);

			//Décaler le point orthogonalement par rapport au segment
			//Coefficient directeur
			annotationPoint.X += static_cast<Gdiplus::REAL>(orthoDistance*(-dy)/segmentSize);
			annotationPoint.Y += static_cast<Gdiplus::REAL>(orthoDistance*(dx)/segmentSize);

			break;
		}
	}

	//Retourner le point
	return annotationPoint;
}
예제 #15
0
파일: ArcView.cpp 프로젝트: hlobit/SimPetri
void CArcView::cleanDouble()
{
	Point currentPoint(*pathPoints.begin());
	for(auto it=pathPoints.begin()+1; it!=pathPoints.end(); ++it)
	{
		if(currentPoint.Equals(*it))
		{
			auto toRemove(it);
			--it;
			pathPoints.erase(it);
		}
	}
}
예제 #16
0
    void PointOnSphere::CalculateUpVector()
    {
        // Apply spherical coordinates
		Vertex3 currentPoint(cos(theta_) * sin(phi_), cos(phi_), sin(theta_) * sin(phi_));

		CHECK_ASSERT(Distance(center_ + radius_ * currentPoint, point_) < 9*PRECISION);

        // Reduce phi slightly to obtain another point on the same longitude line on the sphere.
        const float dt = 1;
        Vertex3 newUpPoint(cos(theta_) * sin(phi_ - dt), cos(phi_ - dt), sin(theta_) * sin(phi_ - dt));

		up_ = Normalize(newUpPoint - currentPoint);
    }
예제 #17
0
void kpTool::beginInternal ()
{
#if DEBUG_KP_TOOL
    kdDebug () << "kpTool::beginInternal()" << endl;
#endif

    if (!m_began)
    {
        // clear leftover statusbar messages
        setUserMessage ();
        m_currentPoint = currentPoint ();
        m_currentViewPoint = currentPoint (false/*view point*/);
        setUserShapePoints (m_currentPoint);

        // TODO: Audit all the code in this file - states like "m_began" &
        //       "m_beganDraw" should be set before calling user func.
        //       Also, m_currentPoint should be more frequently initialised.

        // call user virtual func
        begin ();

        // we've starting using the tool...
        m_began = true;

        // but we haven't started drawing with it
        m_beganDraw = false;


        uint keyState = KApplication::keyboardModifiers ();

        m_shiftPressed = (keyState & KApplication::ShiftModifier);
        m_controlPressed = (keyState & KApplication::ControlModifier);

        // TODO: Can't do much about ALT - unless it's always KApplication::Modifier1?
        //       Ditto for everywhere else where I set SHIFT & CTRL but not alt.
        m_altPressed = false;
    }
}
예제 #18
0
void Telemetry::drawAsGraph(sf::RenderWindow& window, const sf::FloatRect& position, const sf::Color& color) {

	if (dataPoints.size() < 2) {
		return;
	}

	float maxUp = position.top; //d
	float minUp = position.top + position.height; //c
	float leftSide = position.left;

	float maxData = maxBound; //b
	float minData = minBound; //a

   	if (automaticBoundsDetection) {
		minData = std::min_element(dataPoints.begin(), dataPoints.end(),
			[](const sf::Vector2f& lhs, const sf::Vector2f& rhs) { return lhs.y < rhs.y; })->y;
		maxData = std::max_element(dataPoints.begin(), dataPoints.end(),
			[](const sf::Vector2f& lhs, const sf::Vector2f& rhs) { return lhs.y < rhs.y; })->y;
	}

	if ( minData - maxData == 0.0 ) {
		return;
	}

	auto it = dataPoints.begin();

	if (scrolling) {
		auto firstPositionToDraw = dataPoints.back().x - position.width / horizontalScaling;
		it = std::find_if(dataPoints.begin(), dataPoints.end(),
				[firstPositionToDraw](const sf::Vector2f& value)
				{ return value.x >= firstPositionToDraw; });
		if (it == dataPoints.end()) {
			// this should never happen
			return;
		}
	}

	auto startingPoint = it->x;

	sf::Vector2f lastPoint(leftSide,
			(-maxData*minUp + minData*maxUp + (minUp - maxUp)*it->y) / (minData - maxData));

	for ( ++it; it != dataPoints.end(); ++it ) {
		sf::Vector2f currentPoint(
				leftSide + (it->x - startingPoint) * horizontalScaling,
				(-maxData*minUp + minData*maxUp + (minUp - maxUp)*it->y) / (minData - maxData));
		drawLine(window, lastPoint, currentPoint, color);
		lastPoint = currentPoint;
	}
}
예제 #19
0
QVector<QPoint> ImageProcessor::findOcculsionSlower(QImage input) {
    QVector<QPoint> returnMe;

    int radius = (int) (.1 * input.height());
    //qDebug()<<"radius: " <<radius;

    //left side
    int bestLeftY=0;
    int bestLeftYval=INT_MAX;
    for(int currentY=radius;currentY<input.height()-radius;currentY++) {
        int sum =0;
        foreach(int x,ImageProcessor::regionVals(0,currentY,radius,input)) {
            sum+=x;
        }

        if(sum < bestLeftYval) {
            bestLeftY = currentY;
            bestLeftYval = sum;
        }
    }

    QPoint currentPoint(0,bestLeftY);
    returnMe.append(currentPoint);
    for(int lookX =0;lookX<input.width();lookX++) {
        qreal bestAngle=0;
        qreal bestAngleValue=1024;
        for(int angle=-89;angle<90;angle++) {
            qreal angleValue = vectorSum(input,currentPoint,angle);
            if(angleValue < bestAngleValue) {
                bestAngle = angle;
                bestAngleValue = angleValue;
            }
        }
        qDebug()<<"Best angle was: " << bestAngle << " with "<< bestAngleValue;
        if(bestAngle > 15) {
            QPoint nextPoint(currentPoint.x() +1, currentPoint.y() +1);
            currentPoint = nextPoint;
        } else if(bestAngle < -15) {
            QPoint nextPoint(currentPoint.x() +1, currentPoint.y() - 1);
            currentPoint = nextPoint;
        } else {
            QPoint nextPoint(currentPoint.x() +1, currentPoint.y());
            currentPoint = nextPoint;
        }
        returnMe.append(currentPoint);
    }

    return returnMe;
}
예제 #20
0
void TriangleBrush::updateCanvas(Timeline *timeline, ofFbo *fbo, float x, float y, float pressure, ofColor col){
            ofVec2f currentPoint(x,y);
            if (history.size() < 4) addPoint(history, currentPoint);
            if (history.size() > 3){
                vector<ofVec2f> points;
                points = sortClosest(currentPoint, history);   // sort array: last point in array is closest
                setTrianglePoints(points, currentPoint);
                int index = points.size()-1;
                ofVec2f a = points[index];
                ofVec2f b = currentPoint;
                float dist = dotDistance*pressure;
                if(isDistanceBigger(a, b, dist)){
                    addPoint(history, currentPoint);
                    drawToCanvas(fbo, col);
                }
            }
}
예제 #21
0
ContactPointIterator& ContactPointIterator::operator++() {
    m_previousPoint = currentPoint();

    if(m_iterationState == IterationState::CP) {
        if(m_iterationDirection == IterationDirection::Normal)
            ++m_cpIterator;
        else
            --m_cpIterator;

    } else { //IterationState::NCP
        if(m_iterationDirection == IterationDirection::Normal)
            ++m_ncpPosition;
        else
            --m_ncpPosition;
        m_ncp->examinedIndex = m_ncpPosition;
    }
    return (*this);
}
예제 #22
0
// protected
void kpToolText::changeTextStyle (const QString &name,
                                  const kpTextStyle &newTextStyle,
                                  const kpTextStyle &oldTextStyle)
{
#if DEBUG_KP_TOOL_TEXT
    qCDebug(kpLogTools) << "kpToolText::changeTextStyle(" << name << ")";
#endif

    if (hasBegunShape ())
        endShape (currentPoint (), normalizedRect ());

    commandHistory ()->addCommand (
        new kpToolTextChangeStyleCommand (
            name,
            newTextStyle,
            oldTextStyle,
            environ ()->commandEnvironment ()));
}
예제 #23
0
void PathDetect::SetArea(cv::Mat& areaImage, unsigned char areaId, unsigned char areaValue) const
{
    int rows = areaImage.rows;
    int cols = areaImage.cols;

    for (int r = 0; r < rows; ++r)
    {
        for (int c = 0; c < cols; ++c)
        {
            unsigned char value = 0;
            cv::Point currentPoint(c, r);
            if (areaImage.at<unsigned char>(currentPoint) == areaId )
            {
                value = areaValue;
            }
            areaImage.at<unsigned char>(currentPoint) = value;
        }
    }
}
// protected
void kpToolText::handleDownKeyPress (QKeyEvent *e,
    const QList <QString> &textLines, int cursorRow, int cursorCol)
{
#if DEBUG_KP_TOOL_TEXT
    qCDebug(kpLogTools) << "\tdown pressed";
#endif

    if (hasBegunShape ())
        endShape (currentPoint (), normalizedRect ());

    if (!textLines.isEmpty () && cursorRow < (int) textLines.size () - 1)
    {
        cursorRow++;
        cursorCol = qMin (cursorCol, (int) textLines [cursorRow].length ());
        viewManager ()->setTextCursorPosition (cursorRow, cursorCol);
    }

    e->accept ();
}
// private
void kpAbstractSelectionTool::beginDrawMove ()
{
    d->startMoveDragFromSelectionTopLeft =
        currentPoint () - document ()->selection ()->topLeft ();

    if (mouseButton () == 0)
    {
        /*virtual*/setSelectionBorderForBeginDrawMove ();
    }
    else
    {
        // Don't hide sel border momentarily if user is just
        // right _clicking_ selection.
        // (single shot timer)
        d->RMBMoveUpdateGUITimer->start (100/*ms*/);
    }

    setUserMessage (cancelUserMessage ());
}
예제 #26
0
// Support function for finding collided nodes using a subset of nodes in the scene
// recursive method for going through all scene nodes and testing them against a point
bool getNodePointBB(ISceneNode* root,
                    vector3df point,
                    s32 bits,
                    bool recurse,
                    ISceneNode*& outbestnode)
{
    core::vector3df edges[8];

    const core::list<ISceneNode*>& children = root->getChildren();

    core::list<ISceneNode*>::ConstIterator it = children.begin();
    for (; it != children.end(); ++it)
    {
        ISceneNode* current = *it;

        if (current->isVisible() &&
        //          (bNoDebugObjects ? !current->isDebugObject() : true) &&
        (bits==0 || (bits != 0 && (current->getID() & bits))))
        {
            // get world to object space transform
            core::matrix4 mat;
            if (!current->getAbsoluteTransformation().getInverse(mat))
                continue;

            // transform vector from world space to object space
            vector3df currentPoint( point );
            mat.transformVect(currentPoint);

            const core::aabbox3df& box = current->getBoundingBox();

            // do intersection test in object space
            if (box.isPointInside( currentPoint ))
            {
                outbestnode = current;
                return true;
            }
        }
        if ( recurse )
            if ( getNodePointBB(current, point, bits, recurse, outbestnode))
                return true;
    }
    return false;
}
예제 #27
0
파일: ArcView.cpp 프로젝트: hlobit/SimPetri
BOOL CArcView::IsHighlighted(const Point& cursorPoint)
{
	Point currentPoint(*pathPoints.begin());
	for(auto it=pathPoints.begin() + 1; it != pathPoints.end(); ++it)
	{
		CRect lineRect(currentPoint.X, currentPoint.Y, it->X, it->Y);
		lineRect.NormalizeRect();
		if(lineRect.Width() == 0) lineRect.InflateRect(5,0);
		if(lineRect.Height() == 0) lineRect.InflateRect(0,5);

		//La distance du curseur à la droite est-elle acceptable ?
		//Le curseur se trouve-t-il dans enclosingRect ?
		double distance = Geometry::LinePointDistance(currentPoint, *it, cursorPoint);
		if(distance < penWidth/2 + 5 && lineRect.PtInRect(CPoint(cursorPoint.X, cursorPoint.Y)))
			return TRUE;

		currentPoint = *it;
	}

	return FALSE;
}
// private
QVariant kpAbstractSelectionTool::operationMove (Operation op,
        const QVariant &data1, const QVariant &data2)
{
    (void) data1;
    (void) data2;


    switch (op)
    {
    case HaventBegunDrawUserMessage:
        return /*virtual*/haventBegunDrawUserMessageMove ();

    case SetCursor:
        setCursorMove ();
        break;

    case BeginDraw:
        beginDrawMove ();
        break;

    case Draw:
        drawMove (currentPoint (), normalizedRect ());
        break;

    case Cancel:
        cancelMove ();
        break;

    case EndDraw:
        endDrawMove ();
        break;

    default:
        Q_ASSERT (!"Unhandled operation");
        break;
    }

    return QVariant ();
}
예제 #29
0
void ContactPointIterator::continueWith(CPcutting cutting, ContinuationType continueType) {
    if(continueType != ContinuationType::StartAgain) {
        vec2 infrontOfCutting;
        if(cutting.location == IterationLocation::Ground)
            infrontOfCutting = (*(cutting.placeBeforeCutting))->point;
        else
            infrontOfCutting = (*(cutting.placeBeforeCutting))->forbiddenAreaEndPoint;

        vec2 testLineEndPoint;
        if(continueType == ContinuationType::HopOn)
            testLineEndPoint = previousNormalEnd();
        else
            testLineEndPoint = currentPoint();

        if(isOnNormalsSideOf(m_previousPoint, testLineEndPoint, infrontOfCutting)) {
            //"normal" walking direction, set new current point to point after cutting
            m_iterationDirection = IterationDirection::Normal;
            m_cpIterator = (cutting.placeBeforeCutting + 1);

        } else {
            //"reverse" walking direction, set new current point to point before cutting
            m_iterationDirection = IterationDirection::Reverse;
            m_cpIterator = cutting.placeBeforeCutting;
        }
    } else { //ContinuationType::StartAgain
        if(cutting.placeBeforeCutting == cutting.list->begin())
            m_iterationDirection = IterationDirection::Normal;
        else if(cutting.placeBeforeCutting == --(cutting.list->end()))
            m_iterationDirection = IterationDirection::Reverse;
        else
            return;
        m_cpIterator = cutting.placeBeforeCutting;
    }

    m_iterationState = IterationState::CP;
    m_iterationLocation = cutting.location;
    m_cpList = cutting.list;
    m_previousPoint = cutting.cuttingPoint;
}
// protected
void kpToolText::handleEndKeyPress (QKeyEvent *e,
    const QList <QString> &textLines, int cursorRow, int cursorCol)
{
#if DEBUG_KP_TOOL_TEXT
    qCDebug(kpLogTools) << "\tend pressed";
#endif

    if (hasBegunShape ())
        endShape (currentPoint (), normalizedRect ());

    if (!textLines.isEmpty ())
    {
        if (e->modifiers () & Qt::ControlModifier)
            cursorRow = textLines.size () - 1;
    
        cursorCol = textLines [cursorRow].length ();
    
        viewManager ()->setTextCursorPosition (cursorRow, cursorCol);
    }

    e->accept ();
}