Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Choose a Base Repository
daodaoliang/LibreCAD
LibreCAD/LibreCAD
0825732889/LibreCAD
ADVALAIN596/LibreCAD
ASF-inhambane/LibreCAD
Alpha-Kand/LibreCAD
BEINAR/LibreCAD
CERobertson/LibreCAD
CNClaus/LibreCAD
Cantar4/LibreCAD
DINKIN/LibreCAD
DevinderKaur/LibreCAD-1
DraftSouls/LibreCAD
Equoda/LibreCAD
FsCad/LibreCAD
GreatDevelopers/LibreCAD
HUANGMENGDI/LibreCAD
Harpalus/LibreCAD
HelloArsenal/LibreCAD
JGabriel85/LibreCAD
Jameslai54/LibreCAD
Joeycc/LibreCAD
JohnCC330/LibreCAD
Leboudin/LibreCAD
MichaelTaylor3D/LibreCAD
NHellFire/LibreCAD
Ngassa/LibreCAD
OnlyMe2/LibreCAD
OskarLinde/LibreCAD
Osndok/LibreCAD
Palmitoxico/LibreCAD
PlastecProfiles/LibreCAD
Rallaz/LibreCAD
Regmos/LibreCAD
RobertvonKnobloch/LibreCAD
RoboMod/LibreCAD
RoyOnWheels/LibreCAD
Rupicapra-rupicapra/LibreCAD
Salmista-94/LibreCAD
Samsagax/LibreCAD
SkipUFO/LibreCAD
Solvoj/LibreCAD
StafJacobs/LibreCAD
TNick/LibreCAD
TNick2/LibreCAD
Windyztree/LibreCAD
YChuan1115/LibreCAD
absorb-it/LibreCAD
aisq2008/LibreCAD
aitolos/LibreCAD
alexmpcb/LibreCAD
alice23/LibreCAD
ankush1995/LibreCAD
aromis/LibreCAD
bdube/LibreCAD
beginner1/LibreCAD
bert/LibreCAD
bgoodr/LibreCAD
bgpiraja/LibreCAD
bhabanism/LibreCAD
borneq/LibreCAD
boundaryfree/LibreCAD
bshyf/LibreCAD
bygreencn/LibreCAD
cbirla/LibreCAD
cgrzemba/LibreCAD
chenchizhao/LibreCAD
ckvk/LibreCAD
coryjc190/LibreCAD
darrelo2/LibreCAD
dbenamy/LibreCAD
diegoroman17/LibreCAD
dinkel/LibreCAD
dongzk/LibreCAD
drjolo/LibreCAD
dstrev/LibreCAD
duk3luk3/LibreCAD
dvstrom/LibreCAD
dxli/LibreCAD
effad/LibreCAD
emagdalena/LibreCAD
enfreeworld/LibreCAD
epagel/LibreCAD
erburrell/LibreCAD
ezhangle/LibreCAD
fhchina/LibreCAD
fitorec/LibreCAD
frankhardy/LibreCAD
gbonnema/LibreCAD
github20150101/LibreCAD
gitter-badger/LibreCAD
gonboy/LibreCAD
gordonc64/LibreCAD
gracie89/LibreCAD
h4ck3rm1k3/LibreCAD
halftanolger/LibreCAD
hatindera/LibreCAD
hcarsten/LibreCAD
hekaiyuany/LibreCAD
hemanshupa/LibreCAD
hulu1528/LibreCAD
hwwh1999/LibreCAD
iborrell/LibreCAD
ilkos90/SEdit
inderpreetsingh/LibreCAD
inkscaper/LibreCAD
isdsi/LibreCAD
isili/LibreCAD
izikhuang/LibreCAD
jacklibj/LibreCAD
jasleenkaur/LibreCAD
jmundry/LibreCAD
joseph-oc/LibreCAD
juilyoon/LibreCAD
kevincox/LibreCAD
kfoltman/LibreCAD
kk4728/LibreCAD
kleopatra999/LibreCAD
korhadris/LibreCAD
korval937/LibreCAD
kosnick/LibreCAD
kromanenko/LibreCAD
kumans/LibreCAD
lentin/LibreCAD
leogargu/LibreCAD
liangcheng/LibreCAD
liberostelios/LibreCAD
liqingchao/LibreCAD
ljx0305/LibreCAD
locke314/LibreCAD
lordofbikes/LibreCAD
louemusic/LibreCAD
lovlyFarhan/LibreCAD
luisivan/LibreCAD
lukeandrew/LibreCAD
luzhongtong/LibreCAD
lxb66666/LibreCAD
lzhang1106/LibreCAD
mandeepsimak/LibreCAD
maqifrnswa/LibreCAD
mbornoz/LibreCAD
mcanthony/LibreCAD
mcvsama/LibreCAD
meantaipan/LibreCAD
midzer/LibreCAD
miguelramosfdz/LibreCAD
mojadita/LibreCAD
mszczygiel/LibreCAD
myutwo/LibreCAD
n89nanda/LibreCAD
navyzhao/LibreCAD
noselhq/LibreCAD
oktay454/LibreCAD
oskardolch/LibreCAD
p-friedrich/LibreCAD
paul-kennedy/LibreCAD
peizhan/LibreCAD
perepujal/LibreCAD
petroleo/LibreCAD
priyankacool10/LibreCAD
qiujiejia/LibreCAD-1
qtonthat/LibreCAD
r-a-v-a-s/LibreCAD
ranky2009/LibreCAD
rbarraud/LibreCAD
rbuj/LibreCAD
rmamba/LibreCAD
rmdz76/LibreCAD
rubdos/LibreCAD
rvt/LibreCAD
sambar-fgfs/LibreCAD
seasonsfx/LibreCAD
secretgenes342/LibreCAD
seem-sky/LibreCAD
shainline/LibreCAD
silerya/LibreCAD
smallfix/LibreCAD
tarun112/LibreCAD
theking0/LibreCAD
tianqizi/LibreCAD
tin-pot/LibreCAD
tripas/LibreCAD
trojohn5/LibreCAD
turboic/LibreCAD
tytower/LibreCAD
viewsat/LibreCAD
vinayan/LibreCAD
vlachoudis/LibreCAD
wangchenxicool/LibreCAD
wdmchaft/LibreCAD
wiesiwies/LibreCAD
xdiosdev/LibreCAD
xiaomailong/LibreCAD
xnakos/LibreCAD
xyuan/LibreCAD
yadvirkaur/LibreCAD-1
yekose/LibreCAD
yoc3/LibreCAD
zhmzhgis/LibreCAD
zhongxingzhi/LibreCAD
Nothing to show
...
Choose a Head Repository
daodaoliang/LibreCAD
LibreCAD/LibreCAD
0825732889/LibreCAD
ADVALAIN596/LibreCAD
ASF-inhambane/LibreCAD
Alpha-Kand/LibreCAD
BEINAR/LibreCAD
CERobertson/LibreCAD
CNClaus/LibreCAD
Cantar4/LibreCAD
DINKIN/LibreCAD
DevinderKaur/LibreCAD-1
DraftSouls/LibreCAD
Equoda/LibreCAD
FsCad/LibreCAD
GreatDevelopers/LibreCAD
HUANGMENGDI/LibreCAD
Harpalus/LibreCAD
HelloArsenal/LibreCAD
JGabriel85/LibreCAD
Jameslai54/LibreCAD
Joeycc/LibreCAD
JohnCC330/LibreCAD
Leboudin/LibreCAD
MichaelTaylor3D/LibreCAD
NHellFire/LibreCAD
Ngassa/LibreCAD
OnlyMe2/LibreCAD
OskarLinde/LibreCAD
Osndok/LibreCAD
Palmitoxico/LibreCAD
PlastecProfiles/LibreCAD
Rallaz/LibreCAD
Regmos/LibreCAD
RobertvonKnobloch/LibreCAD
RoboMod/LibreCAD
RoyOnWheels/LibreCAD
Rupicapra-rupicapra/LibreCAD
Salmista-94/LibreCAD
Samsagax/LibreCAD
SkipUFO/LibreCAD
Solvoj/LibreCAD
StafJacobs/LibreCAD
TNick/LibreCAD
TNick2/LibreCAD
Windyztree/LibreCAD
YChuan1115/LibreCAD
absorb-it/LibreCAD
aisq2008/LibreCAD
aitolos/LibreCAD
alexmpcb/LibreCAD
alice23/LibreCAD
ankush1995/LibreCAD
aromis/LibreCAD
bdube/LibreCAD
beginner1/LibreCAD
bert/LibreCAD
bgoodr/LibreCAD
bgpiraja/LibreCAD
bhabanism/LibreCAD
borneq/LibreCAD
boundaryfree/LibreCAD
bshyf/LibreCAD
bygreencn/LibreCAD
cbirla/LibreCAD
cgrzemba/LibreCAD
chenchizhao/LibreCAD
ckvk/LibreCAD
coryjc190/LibreCAD
darrelo2/LibreCAD
dbenamy/LibreCAD
diegoroman17/LibreCAD
dinkel/LibreCAD
dongzk/LibreCAD
drjolo/LibreCAD
dstrev/LibreCAD
duk3luk3/LibreCAD
dvstrom/LibreCAD
dxli/LibreCAD
effad/LibreCAD
emagdalena/LibreCAD
enfreeworld/LibreCAD
epagel/LibreCAD
erburrell/LibreCAD
ezhangle/LibreCAD
fhchina/LibreCAD
fitorec/LibreCAD
frankhardy/LibreCAD
gbonnema/LibreCAD
github20150101/LibreCAD
gitter-badger/LibreCAD
gonboy/LibreCAD
gordonc64/LibreCAD
gracie89/LibreCAD
h4ck3rm1k3/LibreCAD
halftanolger/LibreCAD
hatindera/LibreCAD
hcarsten/LibreCAD
hekaiyuany/LibreCAD
hemanshupa/LibreCAD
hulu1528/LibreCAD
hwwh1999/LibreCAD
iborrell/LibreCAD
ilkos90/SEdit
inderpreetsingh/LibreCAD
inkscaper/LibreCAD
isdsi/LibreCAD
isili/LibreCAD
izikhuang/LibreCAD
jacklibj/LibreCAD
jasleenkaur/LibreCAD
jmundry/LibreCAD
joseph-oc/LibreCAD
juilyoon/LibreCAD
kevincox/LibreCAD
kfoltman/LibreCAD
kk4728/LibreCAD
kleopatra999/LibreCAD
korhadris/LibreCAD
korval937/LibreCAD
kosnick/LibreCAD
kromanenko/LibreCAD
kumans/LibreCAD
lentin/LibreCAD
leogargu/LibreCAD
liangcheng/LibreCAD
liberostelios/LibreCAD
liqingchao/LibreCAD
ljx0305/LibreCAD
locke314/LibreCAD
lordofbikes/LibreCAD
louemusic/LibreCAD
lovlyFarhan/LibreCAD
luisivan/LibreCAD
lukeandrew/LibreCAD
luzhongtong/LibreCAD
lxb66666/LibreCAD
lzhang1106/LibreCAD
mandeepsimak/LibreCAD
maqifrnswa/LibreCAD
mbornoz/LibreCAD
mcanthony/LibreCAD
mcvsama/LibreCAD
meantaipan/LibreCAD
midzer/LibreCAD
miguelramosfdz/LibreCAD
mojadita/LibreCAD
mszczygiel/LibreCAD
myutwo/LibreCAD
n89nanda/LibreCAD
navyzhao/LibreCAD
noselhq/LibreCAD
oktay454/LibreCAD
oskardolch/LibreCAD
p-friedrich/LibreCAD
paul-kennedy/LibreCAD
peizhan/LibreCAD
perepujal/LibreCAD
petroleo/LibreCAD
priyankacool10/LibreCAD
qiujiejia/LibreCAD-1
qtonthat/LibreCAD
r-a-v-a-s/LibreCAD
ranky2009/LibreCAD
rbarraud/LibreCAD
rbuj/LibreCAD
rmamba/LibreCAD
rmdz76/LibreCAD
rubdos/LibreCAD
rvt/LibreCAD
sambar-fgfs/LibreCAD
seasonsfx/LibreCAD
secretgenes342/LibreCAD
seem-sky/LibreCAD
shainline/LibreCAD
silerya/LibreCAD
smallfix/LibreCAD
tarun112/LibreCAD
theking0/LibreCAD
tianqizi/LibreCAD
tin-pot/LibreCAD
tripas/LibreCAD
trojohn5/LibreCAD
turboic/LibreCAD
tytower/LibreCAD
viewsat/LibreCAD
vinayan/LibreCAD
vlachoudis/LibreCAD
wangchenxicool/LibreCAD
wdmchaft/LibreCAD
wiesiwies/LibreCAD
xdiosdev/LibreCAD
xiaomailong/LibreCAD
xnakos/LibreCAD
xyuan/LibreCAD
yadvirkaur/LibreCAD-1
yekose/LibreCAD
yoc3/LibreCAD
zhmzhgis/LibreCAD
zhongxingzhi/LibreCAD
Nothing to show
  • 4 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 09, 2015
Dongxu Li cli: event filter 7483c98
Dongxu Li cli: fixed keyboard enter 47d6f20
Commits on Mar 12, 2015
Dongxu Li file cleanup d188dae
Commits on Mar 13, 2015
Dongxu Li inscribe ellipse: degenerence troubleshooting 828ced5
@@ -117,17 +117,7 @@ void RS_ActionDrawEllipseInscribe::mouseMoveEvent(QMouseEvent* e) {
if(en->getId() == lines[i]->getId()) return; //do not pull in the same line again
}
if(en->getParent() != NULL) {
- if ( en->getParent()->rtti() == RS2::EntityInsert /**Insert*/
- || en->getParent()->rtti() == RS2::EntitySpline
- || en->getParent()->rtti() == RS2::EntityMText /**< Text 15*/
- || en->getParent()->rtti() == RS2::EntityText /**< Text 15*/
- || en->getParent()->rtti() == RS2::EntityDimAligned /**< Aligned Dimension */
- || en->getParent()->rtti() == RS2::EntityDimLinear /**< Linear Dimension */
- || en->getParent()->rtti() == RS2::EntityDimRadial /**< Radial Dimension */
- || en->getParent()->rtti() == RS2::EntityDimDiametric /**< Diametric Dimension */
- || en->getParent()->rtti() == RS2::EntityDimAngular /**< Angular Dimension */
- || en->getParent()->rtti() == RS2::EntityDimLeader /**< Leader Dimension */
- ){
+ if ( en->getParent()->ignoredOnModification()){
return;
}
}
@@ -173,19 +163,7 @@ void RS_ActionDrawEllipseInscribe::mouseReleaseEvent(QMouseEvent* e) {
if(en->getId() == lines[i]->getId()) return; //do not pull in the same line again
}
if(en->getParent() != NULL) {
- if ( en->getParent()->rtti() == RS2::EntityInsert /**Insert*/
- || en->getParent()->rtti() == RS2::EntitySpline
- || en->getParent()->rtti() == RS2::EntityMText /**< Text 15*/
- || en->getParent()->rtti() == RS2::EntityText /**< Text 15*/
- || en->getParent()->rtti() == RS2::EntityDimAligned /**< Aligned Dimension */
- || en->getParent()->rtti() == RS2::EntityDimLinear /**< Linear Dimension */
- || en->getParent()->rtti() == RS2::EntityDimRadial /**< Radial Dimension */
- || en->getParent()->rtti() == RS2::EntityDimDiametric /**< Diametric Dimension */
- || en->getParent()->rtti() == RS2::EntityDimAngular /**< Angular Dimension */
- || en->getParent()->rtti() == RS2::EntityDimLeader /**< Leader Dimension */
- ){
- return;
- }
+ if ( en->getParent()->ignoredOnModification()) return;
}
lines.resize(getStatus());
lines.push_back(static_cast<RS_Line*>(en));
@@ -671,23 +671,36 @@ bool RS_Ellipse::createFromCenter3Points(const RS_VectorSolutions& sol) {
*@Author: Dongxu Li
*/
bool RS_Ellipse::createFromQuadratic(const QVector<double>& dn){
+ if(dn.size()<3) return false;
if(fabs(dn[0]) <RS_TOLERANCE2 || fabs(dn[2])<RS_TOLERANCE2) return false; //invalid quadratic form
- //eigenvalue and eigen vectors of quadratic form
+ qDebug()<<"Quadratic: ";
+ for(auto& f: dn){
+ qDebug()<<"dn: "<<f;
+ }
+ //eigenvalue and eigen vectors of quadratic form
// (dn[0] 0.5*dn[1])
// (0.5*dn[1] dn[2])
- double d(dn[0]-dn[2]);
+ double d(dn[0]-dn[2]);
+ bool rotated=false;
+ if(d<0.f && fabs(dn[1])<=10.*RS_TOLERANCE15) {
+ rotated = true;
+ d=fabs(d);
+ }
double s(sqrt(d*d+dn[1]*dn[1]));
// std::cout<<"d="<<d<<std::endl;
// std::cout<<"s="<<s<<std::endl;
double lambda1(0.5*(s+dn[0]+dn[2]));
double lambda2(0.5*(-s+dn[0]+dn[2]));
-// std::cout<<"lambda1="<<lambda1<<"\tlambda2="<<lambda2<<std::endl;
+// std::cout<<"lambda1="<<lambda1<<"\tlambda2="<<lambda2<<std::endl;
if(lambda1<RS_TOLERANCE15 || lambda2<RS_TOLERANCE15) return false;
- RS_Vector majorP(-dn[1]/(s+d),1.);
- majorP /= sqrt(majorP.squared()*lambda2);
+ RS_Vector mP(-dn[1]/(s+d),1.);
+ std::cout<<"mP="<<mP<<std::endl;
+ mP /= sqrt(mP.squared()*lambda2);
+ std::cout<<"mP="<<mP<<std::endl;
// ratio=sqrt(lambda2/lambda1);
// setCenter(center);
- setMajorP(majorP);
+ if(rotated) mP.rotate(RS_Vector(0., 1.));
+ setMajorP(mP);
setRatio(sqrt(lambda2/lambda1));
setAngle1(0.);
setAngle2(0.);
@@ -709,10 +722,11 @@ bool RS_Ellipse::createFromQuadratic(const QVector<double>& dn){
bool RS_Ellipse::createInscribeQuadrilateral(const QVector<RS_Line*>& lines)
{
if(lines.size() != 4) return false; //only do 4 lines
-
+RS_EntityContainer container(NULL, false);
QVector<RS_Line*> quad;
for(int i=0;i<lines.size();i++){//copy the line pointers
quad.push_back(lines[i]);
+ container.addEntity(lines[i]);
}
// std::cout<<"0\n";
for(int i=0;i<lines.size()*2;i++){//move parallel lines to opposite
@@ -730,15 +744,15 @@ bool RS_Ellipse::createInscribeQuadrilateral(const QVector<RS_Line*>& lines)
// std::cout<<"========1========\n";
QVector<RS_Line> ip;
- for(int i=1;i<4;i++){//find intersections
+ for(int i=1;i<4;++i){//find intersections
//(0,i)
// std::cout<<"(0,"<<i<<")\n";
RS_VectorSolutions sol0=RS_Information::getIntersectionLineLine(quad[0],quad[i]);
if(sol0.getNumber()==0) continue;
int l(1);
- if( l==i) l++;
+ if( l==i) ++l;
int m(l+1);
- if( m==i) m++;
+ if( m==i) ++m;
// lines in two pairs: (0, i) and (l,m)
// std::cout<<"(0,"<<i<<"):("<<l<<","<<m<<")\n";
RS_VectorSolutions sol1=RS_Information::getIntersectionLineLine(quad[l],quad[m]);
@@ -750,10 +764,9 @@ bool RS_Ellipse::createInscribeQuadrilateral(const QVector<RS_Line*>& lines)
// std::cout<<"20 ip.size()="<<ip.size()<<"\n";
if(ip.size()<2) return false; //not enough connecting lines, so, no quadrilateral defined
// std::cout<<"22\n";
- RS_VectorSolutions sol2=RS_Information::getIntersection( & ip[0],& ip[1],true);
if(ip.size() == 3) {//find intersecting pair
// RS_VectorSolutions sol0=RS_Information::getIntersection(line0,line1,true);
- RS_VectorSolutions sol1=RS_Information::getIntersection(&ip[2],&ip[1],true);
+ RS_VectorSolutions sol1=RS_Information::getIntersection(&ip[2],&ip[1],true);
if(sol1.getNumber()) {
ip[0]=ip[2];
}else{
@@ -772,14 +785,23 @@ bool RS_Ellipse::createInscribeQuadrilateral(const QVector<RS_Line*>& lines)
RS_Vector centerProjection(sol.get(0));
// std::cout<<"RS_Ellipse::createInscribe(): centerProjection="<<centerProjection<<std::endl;
- QVector<RS_Line> edge; //form the closed quadrilateral with ordered edges
- edge.push_back(RS_Line(ip[0].getStartpoint(),ip[1].getStartpoint()));
- edge.push_back(RS_Line(ip[1].getStartpoint(),ip[0].getEndpoint()));
- edge.push_back(RS_Line(ip[0].getEndpoint(),ip[1].getEndpoint()));
- edge.push_back(RS_Line(ip[1].getEndpoint(),ip[0].getStartpoint()));
- QVector<RS_Vector> tangent;//holds the tangential points on edges, in the order of edges: 1 3 2 0
- for(int i=0;i<=1;i++) {
- RS_VectorSolutions sol1=RS_Information::getIntersection(& edge[i],& edge[(i+2)%edge.size()],false);
+ std::vector<RS_Line> edge; //form the closed quadrilateral with ordered edges
+ edge.push_back(RS_Line(
+ container.getNearestEndpoint(ip[0].getStartpoint()),
+ container.getNearestEndpoint(ip[1].getStartpoint())));
+ edge.push_back(RS_Line(
+ container.getNearestEndpoint(ip[1].getStartpoint()),
+ container.getNearestEndpoint(ip[0].getEndpoint())));
+ edge.push_back(RS_Line(
+ container.getNearestEndpoint(ip[0].getEndpoint()),
+ container.getNearestEndpoint(ip[1].getEndpoint())));
+ edge.push_back(RS_Line(
+ container.getNearestEndpoint(ip[1].getEndpoint()),
+ container.getNearestEndpoint(ip[0].getStartpoint())));
+ std::vector<RS_Vector> tangent;//holds the tangential points on edges, in the order of edges: 1 3 2 0
+ int parallel=0;
+ for(int i=0;i<=1;++i) {
+ RS_VectorSolutions sol1=RS_Information::getIntersectionLineLine(& edge[i],& edge[(i+2)%edge.size()]);
RS_Vector direction;
if(sol1.getNumber()==0) {
direction=edge[i].getEndpoint()-edge[i].getStartpoint();
@@ -789,52 +811,52 @@ bool RS_Ellipse::createInscribeQuadrilateral(const QVector<RS_Line*>& lines)
// std::cout<<"Direction: "<<direction<<std::endl;
RS_Line l(centerProjection, centerProjection+direction);
for(int k=1;k<=3;k+=2){
- RS_VectorSolutions sol2=RS_Information::getIntersection(&l, &edge[(i+k)%edge.size()],false);
+ RS_VectorSolutions sol2=RS_Information::getIntersectionLineLine(&l, &edge[(i+k)%edge.size()]);
for(int j=0;j<sol2.getNumber();j++) {
tangent.push_back(sol2.get(j));
// std::cout<<"Tangential: "<<tangent.size()<<": "<<sol2.get(j)<<std::endl;
}
}
}
+ qDebug()<<"parallel="<<parallel;
- RS_Line* cl0=new RS_Line(ip[0].getEndpoint(),(tangent[0]+tangent[2])*0.5);
- RS_Line* cl1=new RS_Line(ip[1].getEndpoint(),(tangent[1]+tangent[2])*0.5);
- sol=RS_Information::getIntersection(cl0,cl1,false);
+ RS_Line cl0(ip[0].getEndpoint(),(tangent[0]+tangent[2])*0.5);
+ RS_Line cl1(ip[1].getEndpoint(),(tangent[1]+tangent[2])*0.5);
+ sol=RS_Information::getIntersection(&cl0, &cl1,false);
if(sol.getNumber()==0){
//this should not happen
// RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Ellipse::createInscribeQuadrilateral(): can not locate Ellipse Center");
RS_DEBUG->print("RS_Ellipse::createInscribeQuadrilateral(): can not locate Ellipse Center");
return false;
}
+ //ellipse center
RS_Vector center(sol.get(0));
// std::cout<<"line0: "<<*cl0<<std::endl;
// std::cout<<"line1: "<<*cl1<<std::endl;
// std::cout<<"center: "<<center<<std::endl;
- delete cl0;
- delete cl1;
// double ratio;
// std::cout<<"dn="<<dn[0]<<' '<<dn[1]<<' '<<dn[2]<<std::endl;
- QVector<double> dn(3);
+ QVector<double> dn(3);
RS_Vector angleVector(false);
- for(int i=0;i<tangent.size();i++) {
+ for(size_t i=0;i<tangent.size();i++) {
tangent[i] -= center;//relative to ellipse center
}
QVector<QVector<double> > mt;
mt.clear();
- for(int i=0;i<tangent.size();i++){//form the linear equation
- RS_Vector vp(tangent[i]);
-// std::cout<<"point "<<i<<" : "<<vp<<std::endl;
+ const double symTolerance=100.*RS_TOLERANCE;
+ for(const RS_Vector& vp: tangent){//form the linear equation
+ std::cout<<"point : "<<vp<<std::endl;
QVector<double> mtRow;
mtRow.push_back(vp.x*vp.x);
mtRow.push_back(vp.x*vp.y);
mtRow.push_back(vp.y*vp.y);
bool addRow(true);
for(int j=0;j<mt.size();j++){
- if( fabs(mtRow[0]-mt[j][0])<RS_TOLERANCE &&
- fabs(mtRow[1]-mt[j][1])<RS_TOLERANCE &&
- fabs(mtRow[2]-mt[j][2])<RS_TOLERANCE){
+ if(fabs(mtRow[0]-mt[j][0])<symTolerance &&
+ fabs(mtRow[1]-mt[j][1])<symTolerance &&
+ fabs(mtRow[2]-mt[j][2])<symTolerance){
//symmetric
addRow=false;
break;
@@ -854,7 +876,7 @@ bool RS_Ellipse::createInscribeQuadrilateral(const QVector<RS_Line*>& lines)
double dx(majorP.magnitude());
if(dx<RS_TOLERANCE2) return false; //refuse to return zero size ellipse
angleVector.set(majorP.x/dx,-majorP.y/dx);
- for(int i=0;i<tangent.size();i++)tangent[i].rotate(angleVector);
+ for(size_t i=0;i<tangent.size();i++)tangent[i].rotate(angleVector);
RS_Vector minorP(tangent[2]);
double dy2(minorP.squared());
@@ -892,9 +914,11 @@ bool RS_Ellipse::createInscribeQuadrilateral(const QVector<RS_Line*>& lines)
angleVector.y *= -1.;
rotate(center,angleVector);
}
+ std::cout<<*this<<std::endl;
return true;
}
+
/**
* a naive implementation of middle point
* to accurately locate the middle point from arc length is possible by using elliptic integral to find the total arc length, then, using elliptic function to find the half length point
@@ -332,7 +332,9 @@ RS_VectorSolutions RS_Information::getIntersectionLineLine(RS_Line* e1,
double num = ((p4.x-p3.x)*(p1.y-p3.y) - (p4.y-p3.y)*(p1.x-p3.x));
double div = ((p4.y-p3.y)*(p2.x-p1.x) - (p4.x-p3.x)*(p2.y-p1.y));
- if (fabs(div)>RS_TOLERANCE) {
+ if (fabs(div)>RS_TOLERANCE &&
+ fabs(remainder(e1->getAngle1()-e2->getAngle1(), M_PI))>=RS_TOLERANCE_ANGLE
+ ) {
double u = num / div;
double xs = p1.x + u * (p2.x-p1.x);
@@ -433,7 +433,7 @@ RS_VectorSolutions LC_Quadratic::getIntersection(const LC_Quadratic& l1, const L
return ret;
}
std::vector<std::vector<double> > ce(0);
- if(fabsf(p2->m_vLinear(1))<RS_TOLERANCE){
+ if(fabs(p2->m_vLinear(1))<RS_TOLERANCE){
const double angle=0.25*M_PI;
LC_Quadratic p11(*p1);
LC_Quadratic p22(*p2);
@@ -591,7 +591,7 @@ void QC_ApplicationWindow::initMDI() {
// Since this nice feature causes a bug of lost key events when the command widget is on
// a screen different from the main window, disabled for the time being
//send key events for mdiAreaCAD to command widget by default
-// mdiAreaCAD->installEventFilter(commandWidget);
+ mdiAreaCAD->installEventFilter(commandWidget);
RS_DEBUG->print("QC_ApplicationWindow::initMDI() end");
@@ -81,34 +81,42 @@ bool QG_CommandWidget::checkFocus() {
bool QG_CommandWidget::eventFilter(QObject */*obj*/, QEvent *event)
{
- if (event->type() == QEvent::KeyPress) {
- QKeyEvent* e=static_cast<QKeyEvent*>(event);
- switch(e->key()){
- case Qt::Key_Return:
- case Qt::Key_Enter:
- case Qt::Key_Escape:
- return false;
- default:
- {
- //detect Ctl- Alt- modifier, but not Shift
- //This should avoid filtering shortcuts, such as Ctl-C
- if(e->modifiers() & (Qt::KeyboardModifierMask ^ Qt::ShiftModifier)) return false;
-// DEBUG_HEADER();
- leCommand->setFocus(Qt::OtherFocusReason);
- event->accept();
- QKeyEvent * newEvent = new QKeyEvent(*static_cast<QKeyEvent*>(event));
- QApplication::postEvent(leCommand, newEvent);
- return true;
- }
- }
-
- }
- return false;
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent* e=static_cast<QKeyEvent*>(event);
+ // qDebug()<<QString::number(e->key(), 16);
+ switch(e->key()){
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ if(!leCommand->text().size())
+ return false;
+ else
+ break;
+ case Qt::Key_Escape:
+ // DEBUG_HEADER();
+ // qDebug()<<"Not filtered";
+ return false;
+ default:
+ break;
+ }
+ //detect Ctl- Alt- modifier, but not Shift
+ //This should avoid filtering shortcuts, such as Ctl-C
+ if(e->modifiers() & (Qt::KeyboardModifierMask ^ Qt::ShiftModifier)) return false;
+ event->accept();
+ QKeyEvent * newEvent = new QKeyEvent(*static_cast<QKeyEvent*>(event));
+ QApplication::postEvent(leCommand, newEvent);
+ this->setFocus();
+ // DEBUG_HEADER();
+ // qDebug()<<"Filtered";
+ return true;
+ }
+ return false;
}
void QG_CommandWidget::setFocus() {
//setCommandMode();
+ QFocusEvent* newEvent=new QFocusEvent(QEvent::FocusIn);
+ QApplication::postEvent(leCommand, newEvent);
leCommand->setFocus();
}

No commit comments for this range