//----------------------------------------------------------------------------- void StyleDialog::updatePic() { static mglGraph gr(0,128,30); static bool f = true; mglData x(3), y(3), a(32,2); x.Fill(-1,1); a.Fill(-1,1); if(!f) gr.Clf(); if(f) { gr.SubPlot(1,1,0,""); gr.SetMarkSize(15); gr.SetArrowSize(20); f = false; } result = ""; int i,j; QString col="wbgrcmylenuqphkWBGRCMYLENUQPH", mrk=".+x*sdv^<>o.*+xsdv^<>o", dsh="|;=ji: ", arw="AVIKTSDO", s; QString msk="-+=;oOsS~<>jdD*^", dir="/\\I"; switch(tab->currentIndex()) { case 0: // line style i = a2->currentIndex(); if(i>0) result += arw[i-1]; j = a1->currentIndex(); if(j>0) { if(i==0) result += '_'; result += arw[j-1]; } i = dash->currentIndex(); if(i>0 && i<8) result += dsh[i-1]; else if(i==8) // manual { int d=0; for(int i=0;i<16;i++) if(dash_bit[i]->isChecked()) d += 1<<i; result += "{d"+QString::number(d,16)+"}"; } i = mark->currentIndex(); if(i>0) result += mrk[i-1]; if(i>11) result += '#'; i = cline->currentIndex(); if(i>0) { j = nline->value(); if(j!=5) result += "{"+col[i-1]+char('0'+j)+"}"; else result += col[i-1]; } i = width->value(); if(i>1) result += char('0'+i); gr.Plot(x,y,result.toLocal8Bit().constData()); break; case 1: // color sceheme case 3: // manual mask for(j=0;j<7;j++) { i = cc[j]->currentIndex(); if(i<1) break; QCharRef c = col[i-1]; i = nn[j]->value(); if(i!=5) result += "{"+c+char('0'+i)+"}"; else result += c; } if(swire->isChecked()) result += '#'; i = ctext->currentIndex(); if(i==1) result += 't'; if(i==2) result += 'T'; i = mask->currentIndex(); if(i>0 && i<17) { result += msk[i-1]; i = angle->currentIndex(); if(i>0) result += dir[i-1]; i = msize->value(); if(i>1) result += char('0'+i); } else if(i==17) { uint64_t t=0; for(int j=0;j<64;j++) if(mask_bit[j]->isChecked()) t += uint64_t(1)<<j; result += "{s"+QString::number(t,16)+"}"; // TODO get hex-mask i = angle->currentIndex(); if(i>0) result += dir[i-1]; i = msize->value(); if(i>1) result += char('0'+i); } i = axial->currentIndex(); if(i>0) result = result+':'+char('x'+i-1); gr.Surf(a,result.toLocal8Bit().constData()); break; case 2: // text style if(font_sch->isChecked()) for(j=0;j<7;j++) { i = cc[j]->currentIndex(); if(i<1) break; QCharRef c = col[i-1]; i = nn[j]->value(); if(i!=5) result += "{"+c+char('0'+i)+"}"; else result += c; } else { i = cfont->currentIndex(); if(i>1) result += col[i-1]; } result += ':'; if(bold->isChecked()) result += 'b'; if(ital->isChecked()) result += 'i'; if(wire->isChecked()) result += 'w'; if(uline->isChecked()) result += 'u'; if(oline->isChecked()) result += 'o'; if(rbL->isChecked()) result += 'L'; if(rbC->isChecked()) result += 'C'; if(rbR->isChecked()) result += 'R'; gr.Puts(mglPoint(0,-0.5),"Font test",result.toLocal8Bit().constData(),-10); break; } result = "'" + result + "'"; res->setText(result); QPixmap p; convertFromGraph(p, &gr, &grBuf); pic->setPixmap(p); }
//----------------------------------------------------------------------------- void SubplotDialog::updatePic() { static mglGraph gr; gr.SetSize(pic->width(),pic->height()); mglParse par; setlocale(LC_NUMERIC, "C"); QString stl="'"; // style for subplot if(rb->isChecked()) stl+='_'; if(rl->isChecked()) stl+='<'; if(rr->isChecked()) stl+='>'; if(rt->isChecked()) stl+='^'; if(rw->isChecked()) stl+='#'; stl += '\''; if(stl=="'_<>^'") stl=""; int Tet = tet->value(), Phi = phi->value(); int Ax = 1, Ay = 1; if(!axz->text().isEmpty()) Ax = axz->text().toDouble(); if(!ayz->text().isEmpty()) Ay = ayz->text().toDouble(); if(cb->isChecked()) // subplot { int n=bn->value(), m=bm->value(), k=bk->value(); for(int i=0;i<n*m;i++) if(i!=k) { gr.SubPlot(n,m,i); gr.Box("h"); } cmd = "subplot "+QString::number(n)+" "+QString::number(m)+" "+QString::number(k)+" "+stl; if(!title->text().isEmpty()) { cmd += ":title '"+title->text()+"'"; if(!fmt.isEmpty()) cmd += fmt; } if(Tet || Phi) cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi); if(Ax!=1 || Ay!=1) cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay); par.Execute(&gr, cmd.toStdWString().c_str()); gr.Box(); res->setText(cmd); } else if(cm->isChecked()) // multiplot { int n=mn->value(), m=mm->value(), k=mk->value(), dx=mx->value(), dy=my->value(); for(int i=0;i<n*m;i++) if(i!=k) { gr.SubPlot(n,m,i); gr.Box("h"); } cmd = "multiplot "+QString::number(n)+" "+QString::number(m)+" "+QString::number(k)+" "+QString::number(dx)+" "+QString::number(dy)+" "+stl; if(!title->text().isEmpty()) { cmd += ":title '"+title->text()+"'"; if(!fmt.isEmpty()) cmd += fmt; } if(Tet || Phi) cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi); if(Ax!=1 || Ay!=1) cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay); par.Execute(&gr, cmd.toStdWString().c_str()); gr.Box(); res->setText(cmd); } else if(cg->isChecked()) // gridplot { int n=gn->value(), m=gm->value(), k=gk->value(); double d = gd->text().isEmpty()?0:gd->text().toDouble(); for(int i=0;i<n*m;i++) if(i!=k) { gr.GridPlot(n,m,i,d); gr.Box("h"); } cmd = "gridplot "+QString::number(n)+" "+QString::number(m)+" "+QString::number(k)+" "+QString::number(d); if(Ax!=1 || Ay!=1) cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay); par.Execute(&gr, cmd.toStdWString().c_str()); gr.Box(); res->setText(cmd); } else if(cs->isChecked()) // stickplot { int n=sn->value(), k=sk->value(); for(int i=0;i<n;i++) if(i!=k) { gr.StickPlot(n,i,Tet,Phi); gr.Box("h"); } cmd = "stickplot "+QString::number(n)+" "+QString::number(k)+" "+QString::number(Tet)+" "+QString::number(Phi); if(Ax!=1 || Ay!=1) cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay); par.Execute(&gr, cmd.toStdWString().c_str()); gr.Box(); res->setText(cmd); } else if(cc->isChecked()) // columnplot // TODO add angles { int n=cn->value(), k=ck->value(); double d = cd->text().isEmpty()?0:cd->text().toDouble(); for(int i=0;i<n;i++) if(i!=k) { gr.ColumnPlot(n,i,d); gr.Rotate(Tet,Phi); gr.Box("h"); } cmd = "columnplot "+QString::number(n)+" "+QString::number(k)+" "+QString::number(d); if(Tet || Phi) cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi); if(Ax!=1 || Ay!=1) cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay); par.Execute(&gr, cmd.toStdWString().c_str()); gr.Box(); res->setText(cmd); } else if(ci->isChecked()) // inplot { { gr.SubPlot(1,1,0); gr.Box("h"); } cmd = "inplot "+x1->text()+" "+x2->text()+" "+y1->text()+" "+y2->text(); if(!title->text().isEmpty()) { cmd += ":title '"+title->text()+"'"; if(!fmt.isEmpty()) cmd += fmt; } if(Tet || Phi) cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi); if(Ax!=1 || Ay!=1) cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay); par.Execute(&gr, cmd.toStdWString().c_str()); gr.Box(); res->setText(cmd); } setlocale(LC_NUMERIC, ""); QPixmap p; convertFromGraph(p, &gr, &grBuf); pic->setPixmap(p); }