[qet] [3502] Modification du calcul d'intersection ( a revoir ) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3502
Author: runsys
Date: 2014-11-22 10:22:46 +0100 (Sat, 22 Nov 2014)
Log Message:
-----------
Modification du calcul d'intersection ( a revoir )
Modified Paths:
--------------
branches/conductor2/sources/diagram.cpp
branches/conductor2/sources/qetgraphicsitem/conductor.cpp
Modified: branches/conductor2/sources/diagram.cpp
===================================================================
--- branches/conductor2/sources/diagram.cpp 2014-11-22 09:22:41 UTC (rev 3501)
+++ branches/conductor2/sources/diagram.cpp 2014-11-22 09:22:46 UTC (rev 3502)
@@ -196,6 +196,7 @@
// detecte le relachement d'une touche de direction ( = deplacement d'elements)
if ( e -> key() == Qt::Key_G) {
Conductor::bDebugGrid= !Conductor::bDebugGrid;
+ Conductor::reBuild();
update();
}
else if ( e -> key() == Qt::Key_P) {
Modified: branches/conductor2/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- branches/conductor2/sources/qetgraphicsitem/conductor.cpp 2014-11-22 09:22:41 UTC (rev 3501)
+++ branches/conductor2/sources/qetgraphicsitem/conductor.cpp 2014-11-22 09:22:46 UTC (rev 3502)
@@ -563,50 +563,25 @@
void Conductor::computeIntersection( vec2d orig, vec2d& dest, vec2d topLeft, vec2d bottomRight ) {
-
- vec2d orientation;
-
-
vec2d vDir = vec2d( orig, dest ).vnormalize();
- double sign = vDir.addCoord();
- if ( vDir.dot(south) == 0.0 ) orientation = east;
- else orientation = south;
-
- if ( bDebug ) {
- printVec2d( " orig : ", orig );
- printVec2d( " dest : ", orig );
- printVec2d( " dir : ", orientation);
+ vec2d newPt = orig + 10.0 * vDir;
+ dest = orig;
+ int n = 0;
+ while( !isInsideRect( newPt, topLeft, bottomRight) ) {
+ dest += +10.0 * vDir;
+ newPt+= +10.0 * vDir;
+ n++;
+ if ( n == 200 ) {
+ qDebug()<< "****** TIMEOUT ********";
+ dest = orig + 10.0 * vDir;
+ break;
+ }
}
-
- vec2d vOL = vec2d( orig, topLeft ).mul(orientation);
- vec2d vOR = vec2d( orig, bottomRight).mul(orientation);
-
- double dOL = vOL.addCoord() * sign;
- double dOR = vOR.addCoord() * sign;
-
- if ( bDebug ) {
- printDoubl( " dOL : ", dOL );
- printDoubl( " dOR : ", dOR );
+ // if error
+ if ( dest == orig ) {
+ dest = orig + 10.0 * vDir;
}
-
- double res;
- if ( dOL < dOR ) {
- res = dOL;
- res -= 10.0;
- }
- else {
- res = dOR;
- res += 10.0;
- }
-
-
- dest = orig + res * vDir;
- snapOnGrid(dest);
- if ( bDebug ) {
- printVec2d( " dest : ", dest);
- }
-
}
@@ -627,14 +602,16 @@
if ( bDebug ) {
qDebug() << " test intersection avec : "<< element -> name();
- printVec2d( " topLeft : ", topLeft );
- printVec2d( " bottomRgiht : ", bottomRight );
}
if ( isInsideRect( ori, pt, topLeft, bottomRight ) ) {
if ( bDebug ) {
qDebug() <<" *** Intersection ";
+ printVec2d(" ori : ", ori );
+ printVec2d(" pt : ", pt );
+ printVec2d(" topLeft : ", topLeft );
+ printVec2d(" bottomRgiht : ", bottomRight );
qDebug() <<" *** computeInstersection";
}
computeIntersection( ori, pt, topLeft, bottomRight );
@@ -642,7 +619,7 @@
}
else {
if ( bDebug ) {
- qDebug() <<" Pas d'intersection ";
+ qDebug() <<" Pas d'intersection ";
//intersection( pt, ori, topLeft, bottomRight );
}
}
@@ -1377,7 +1354,7 @@
// Texte
QString text;
if ( Conductor::bAffCoord )
- text = QString::number(i,10) +":"+ QString::number( (int)pt.x ) +", "+ QString::number( (int)pt.y );
+ text = QString::number(i,10) +":"+ QString::number( (int)(pt.x+scenePos().x()) ) +", "+ QString::number( (int)(pt.y+scenePos().y()) );
else
text = QString::number(i,10);
qp -> drawText( coordText, text );