*** empty log message ***

This commit is contained in:
margraf 2004-12-04 18:41:22 +00:00
parent 85818e0b07
commit 602fd68627
27 changed files with 203 additions and 112 deletions

1
NEWS
View File

@ -28,6 +28,7 @@ Version 0.0.5
* translations into French and Japanese
* some new components and diagrams
* some new graph styles (stars, circles, ...)
* manual axes scale for diagrams
* many minor improvements and bug fixes

View File

@ -1,3 +1,13 @@
2004-12-04 Michael Margraf <michael.margraf@alumni.tu-berlin.de>
* fixed some bugs in diagram clipping algorithm
* graphs can be painted with stars, circles and arrows
2004-12-01 Michael Margraf <michael.margraf@alumni.tu-berlin.de>
* disabled rotation angle in graphictext dialog if in
symbol mode
2004-11-23 Michael Margraf <michael.margraf@alumni.tu-berlin.de>
* wire label a little bit more beautiful

View File

@ -36,7 +36,7 @@ AC_Sim::AC_Sim()
if (b != -1) Texts.append(new Text(0, 0, s.mid(b+1)));
x1 = -10; y1 = -9;
x2 = x1+115; y2 = y1+28;
x2 = x1+128; y2 = y1+41;
tx = 0;
ty = y2+1;

View File

@ -254,8 +254,8 @@ void Component::paint(ViewPainter *p)
void Component::paintScheme(QPainter *p)
{
if(Model.at(0) == '.') { // is simulation component (dc, ac, ...)
int xb = x2-x1;
int yb = y2-y1;
int xb = x2-x1-13;
int yb = y2-y1-13;
p->drawRect(cx-6, cy-5, xb, yb);
p->drawLine(cx-1, cy+yb, cx-6, cy+yb-5);

View File

@ -36,7 +36,7 @@ DC_Sim::DC_Sim()
if (b != -1) Texts.append(new Text(0, 0, s.mid(b+1)));
x1 = -10; y1 = -9;
x2 = x1+115; y2 = y1+28;
x2 = x1+128; y2 = y1+41;
tx = 0;
ty = y2+1;

View File

@ -31,7 +31,7 @@ HB_Sim::HB_Sim()
if (a != -1) Texts.append(new Text(0, 0, s.mid(a+1)));
x1 = -10; y1 = -9;
x2 = x1+150; y2 = y1+46;
x2 = x1+163; y2 = y1+59;
tx = 0;
ty = y2+1;

View File

@ -34,8 +34,8 @@ OpAmp::OpAmp()
Lines.append(new Line(-16,-19, -9,-19,QPen(QPen::red,1)));
Lines.append(new Line(-13,-22,-13,-15,QPen(QPen::red,1)));
Ports.append(new Port(-30,-20));
Ports.append(new Port(-30, 20));
Ports.append(new Port(-30,-20));
Ports.append(new Port( 40, 0));
x1 = -30; y1 = -38;

View File

@ -31,7 +31,7 @@ Param_Sweep::Param_Sweep()
if (a != -1) Texts.append(new Text(0, 0, s.mid(a+1)));
x1 = -10; y1 = -9;
x2 = x1+91; y2 = y1+46;
x2 = x1+104; y2 = y1+59;
tx = 0;
ty = y2+1;

View File

@ -35,7 +35,7 @@ SP_Sim::SP_Sim()
if (b != -1) Texts.append(new Text(0, 0, s.mid(b+1)));
x1 = -10; y1 = -9;
x2 = x1+108; y2 = y1+46;
x2 = x1+121; y2 = y1+59;
tx = 0;
ty = y2+1;

View File

@ -31,7 +31,7 @@ TR_Sim::TR_Sim()
if (a != -1) Texts.append(new Text(0, 0, s.mid(a+1)));
x1 = -10; y1 = -9;
x2 = x1+91; y2 = y1+46;
x2 = x1+104; y2 = y1+59;
tx = 0;
ty = y2+1;

View File

@ -1,5 +1,5 @@
/***************************************************************************
diagram.cpp - description
diagram.cpp
-------------------
begin : Thu Oct 2 2003
copyright : (C) 2003, 2004 by Michael Margraf
@ -211,6 +211,18 @@ int Diagram::regionCode(int x, int y)
return code;
}
// ------------------------------------------------------------
bool Diagram::insideDiagram(int x, int y)
{
if(Name.at(0) == 'R')
return (regionCode(x, y) == 0);
int R = x2 >> 1;
x -= R;
y -= R;
return ((x*x + y*y) <= R*R);
}
// ------------------------------------------------------------
// Cohen-Sutherland clipping algorithm
void Diagram::clip(int* &p)
@ -220,7 +232,7 @@ void Diagram::clip(int* &p)
return;
}
int x, y, dx, dy, code, z=0;
int x=0, y=0, dx, dy, code, z=0;
int x_1 = *(p-4), y_1 = *(p-3);
int x_2 = *(p-2), y_2 = *(p-1);
@ -302,22 +314,19 @@ void Diagram::roundClip(int* &p)
int dt2 = dt1 - x_2*x_2 - y_2*y_2;
dt1 -= x_1*x_1 + y_1*y_1;
int code = 0;
if(dt1 < 0) code |= 1;
if(dt2 < 0) code |= 2;
if(code == 0) return; // line completly inside ?
if(dt1 >= 0) if(dt2 >= 0) return; // line completly inside ?
if(code & 1) if(*(p-5) >= 0) { // is there already a line end flag ?
if(dt1 < 0) if(*(p-5) >= 0) { // is there already a line end flag ?
p++;
*(p-5) = -2;
}
int x = x_2-x_1;
int y = y_2-y_1;
int x = x_1-x_2;
int y = y_1-y_2;
int C = x_1*x + y_1*y;
int D = x*x + y*y;
float F = float(C);
F = F*F + float(dt1)*float(D);
F = F*F + float(dt1)*float(D); // use float because number is easily > 2^32
x_1 += R;
y_1 += R;
@ -330,29 +339,36 @@ void Diagram::roundClip(int* &p)
return;
}
F = sqrt(F);
if(code & 1) { // start point outside ?
R = int(F) + C;
*(p-4) = x_1 - x*R / D;
*(p-3) = y_1 - y*R / D;
int code = 0;
R = int(sqrt(F));
dt1 = C - R;
if((dt1 > 0) && (dt1 < D)) { // intersection outside start/end point ?
*(p-4) = x_1 - x*dt1 / D;
*(p-3) = y_1 - y*dt1 / D;
code |= 1;
}
else {
*(p-4) = x_1;
*(p-3) = y_1;
}
if(code & 2) { // end point outside ?
R = int(F) - C;
*(p-2) = x_1 + x*R / D;
*(p-1) = y_1 + y*R / D;
*(p++) = -2;
*(p++) = x_2;
*(p++) = y_2;
dt2 = C + R;
if((dt2 > 0) && (dt2 < D)) { // intersection outside start/end point ?
*(p-2) = x_1 - x*dt2 / D;
*(p-1) = y_1 - y*dt2 / D;
*p = -2;
p += 3;
code |= 2;
}
else {
*(p-2) = x_2;
*(p-1) = y_2;
*(p-2) = x_2;
*(p-1) = y_2;
if(code == 0) { // intersections both lie outside ?
*(p-4) = x_2;
*(p-3) = y_2;
p -= 2;
}
}
// ------------------------------------------------------------
@ -401,13 +417,46 @@ void Diagram::calcData(Graph *g, int valid)
if(Counter >= 2) // clipping only if an axis is manual
clip(p);
}
if(*(p-3) == -2) if(*(p-1) > -2)
p -= 2; // no single point after "no stroke"
*(p++) = -10;
}
*p = -100;
return;
case 1: Stroke = 10.0; Space = 6.0; break; // dash line
case 2: Stroke = 2.0; Space = 4.0; break; // dot line
case 3: Stroke = 24.0; Space = 8.0; break; // long dash line
default:
if(g->Style == 4) xtmp = -7; // **** a star at each point ******
else if(g->Style == 5) xtmp = -6; // **** a circle at each point ****
else if(g->Style == 6) xtmp = -5; // **** a arrow at each point *****
for(i=g->countY; i>0; i--) { // every branch of curves
px = g->cPointsX.getFirst()->Points;
for(z=g->cPointsX.getFirst()->count; z>0; z--) { // every point
if(p >= p_end) { // need to enlarge memory block ?
Size += 256;
tmp = p - g->Points;
p = p_end = g->Points
= (int*)realloc(g->Points, Size*sizeof(int));
p += tmp;
p_end += Size - 9;
}
calcCoordinate(px, py, p, p+1, pa);
if(insideDiagram(*p, *(p+1))) { // within diagram ?
*(p+2) = xtmp;
p += 3;
}
}
*(p++) = -10;
}
*p = -100;
/*qDebug("\n******");
for(int zz=0; zz<60; zz+=2)
qDebug("c: %d/%d", *(g->Points+zz), *(g->Points+zz+1));*/
return;
}
double alpha, dist;
@ -474,6 +523,8 @@ void Diagram::calcData(Graph *g, int valid)
}
} // of x loop
if(*(p-3) == -2) if(*(p-1) > -2)
p -= 2; // no single point after "no stroke"
*(p++) = -10;
} // of y loop
*p = -100;

View File

@ -75,6 +75,7 @@ public:
void createPolarDiagram(Axis*, int Mode=3);
int regionCode(int, int);
bool insideDiagram(int, int);
void clip(int* &);
void roundClip(int* &);

View File

@ -110,6 +110,9 @@ DiagramDialog::DiagramDialog(Diagram *d, const QString& _DataSet,
PropertyBox->insertItem(tr("dash line"));
PropertyBox->insertItem(tr("dot line"));
PropertyBox->insertItem(tr("long dash line"));
PropertyBox->insertItem(tr("stars"));
PropertyBox->insertItem(tr("circles"));
PropertyBox->insertItem(tr("arrows"));
connect(PropertyBox, SIGNAL(activated(int)),
SLOT(slotSetGraphStyle(int)));
Box2->setStretchFactor(new QWidget(Box2), 5); // stretchable placeholder
@ -679,6 +682,27 @@ void DiagramDialog::slotApply()
}
}
QString tmp;
if(startX->text().toDouble() > stopX->text().toDouble()) {
tmp = startX->text();
startX->setText(stopX->text());
stopX->setText(tmp);
}
if(startY->text().toDouble() > stopY->text().toDouble()) {
tmp = startY->text();
startY->setText(stopY->text());
stopY->setText(tmp);
}
if(startZ->text().toDouble() > stopZ->text().toDouble()) {
tmp = startZ->text();
startZ->setText(stopZ->text());
stopZ->setText(tmp);
}
if((Diag->Name == "Smith") || (Diag->Name == "ySmith"))
if(stopY->text().toDouble() < 1.0)
stopY->setText("1");
if(Diag->xAxis.autoScale == manualX->isChecked()) {
Diag->xAxis.autoScale = !(manualX->isChecked());
changed = true;

View File

@ -51,67 +51,56 @@ Graph::~Graph()
// ---------------------------------------------------------------------
void Graph::paint(ViewPainter *p, int x0, int y0)
{
int *pp = Points;
if(pp == 0) {
p->Painter->setPen(QPen(QColor(Color))); // set color for xlabel text
if(Points == 0)
return;
}
int n1;
if(isSelected) {
p->Painter->setPen(QPen(QPen::darkGray,Thick+4));
if(*pp < 0) pp++;
for(n1=countY; n1>0; n1--) {
p->drawPoint(x0+(*pp), y0-(*(pp+1)));
do {
pp += 2;
if(*pp > -2)
do {
p->drawLine(x0+(*(pp-2)), y0-(*(pp-1)), x0+(*pp), y0-(*(pp+1)));
pp += 2;
} while(*pp > -2); // until end of stroke
if(*pp < -9) break; // end of line ?
pp++;
} while(*pp > -9);
pp++;
}
paintLines(p, x0, y0);
pp = Points;
p->Painter->setPen(QPen(QPen::white, Thick, Qt::SolidLine));
if(*pp < 0) pp++;
for(n1=countY; n1>0; n1--) {
p->drawPoint(x0+(*pp), y0-(*(pp+1)));
do {
pp += 2;
if(*pp > -2)
do {
p->drawLine(x0+(*(pp-2)), y0-(*(pp-1)), x0+(*pp), y0-(*(pp+1)));
pp += 2;
} while(*pp > -2); // until end of stroke
if(*pp < -9) break; // end of line ?
pp++;
} while(*pp > -9);
pp++;
}
p->Painter->setPen(QPen(QColor(Color))); // set color for xlabel text
paintLines(p, x0, y0);
return;
}
// **** not selected ****
p->Painter->setPen(QPen(QColor(Color), Thick, Qt::SolidLine));
paintLines(p, x0, y0);
}
// ---------------------------------------------------------------------
void Graph::paintLines(ViewPainter *p, int x0, int y0)
{
int x, y;
int *pp = Points;
if(*pp < 0) pp++;
for(n1=countY; n1>0; n1--) { // every branch of curves
p->drawPoint(x0+(*pp), y0-(*(pp+1)));
do { // until end of branch
for(int n1=countY; n1>0; n1--) { // every branch of curves
if(*pp >= 0) p->drawPoint(x0+(*pp), y0-(*(pp+1)));
while(*pp > -9) { // until end of branch
pp += 2;
if(*pp > -2)
do { // until end of stroke
while(*pp > -2) { // until end of stroke
p->drawLine(x0+(*(pp-2)), y0-(*(pp-1)), x0+(*pp), y0-(*(pp+1)));
pp += 2;
} while(*pp > -2); // until end of stroke
if(*pp < -9) break; // end of line ?
}
if(*pp < -9) break; // end of line ?
else {
x = x0 + *(pp-2);
y = y0 - *(pp-1);
if(*pp == -7) { // paint star
p->drawLine(x-5, y, x+5, y); // horizontal line
p->drawLine(x-4, y+4, x+4, y-4); // upper left to lower right
p->drawLine(x+4, y+4, x-4, y-4); // upper right to lower left
}
else if(*pp == -6) // paint circle
p->drawEllipse(x-4, y-4, 8, 8);
else if(*pp == -5) { // paint arrow
p->drawLine(x, y, x, y0);
p->drawLine(x-4, y+7, x, y);
p->drawLine(x+4, y+7, x, y);
}
}
pp++;
} while(*pp > -9);
}
pp++;
}
}
@ -190,19 +179,28 @@ int Graph::getSelected(int x, int y)
do {
x1 = *(pp++); y1 = *(pp++);
zi++;
dx = x - x1;
dy = y - y1;
dx2 = (*pp);
if(dx2 < -1) {
if(dx2 < -9) break;
dx2 = *(++pp);
pp++;
if(dx2 < -2) { // no line, but single point (e.g. star) ?
if(*pp < -9) break;
if(dx < -5) continue;
if(dx > 5) continue;
if(dy < -5) continue;
if(dy > 5) continue;
return z*countX;// + zi; // points on graph
}
dx2 = *pp;
if(dx2 < -9) break;
zi -= 2; // because of space (edge-values)
}
if(dx < -5) { if(x < dx2-5) continue; } // point between x coordinates ?
else { if(x > 5) if(x > dx2+5) continue; }
dy = y - y1;
dy2 = (*(pp+1));
if(dy < -5) { if(y < dy2-5) continue; } // point between y coordinates ?
else { if(y > 5) if(y > dy2+5) continue; }

View File

@ -21,15 +21,12 @@
#include "marker.h"
#include "element.h"
#include "viewpainter.h"
#include <qcolor.h>
#include <qpainter.h>
#include <qptrlist.h>
#include <qtextstream.h>
#include <qvaluevector.h>
class Diagram;
class ViewPainter;
/**
*@author Michael Margraf
@ -51,6 +48,7 @@ public:
~Graph();
void paint(ViewPainter*, int, int);
void paintLines(ViewPainter*, int, int);
QString save();
bool load(const QString&);
int getSelected(int, int);

View File

@ -26,7 +26,7 @@
RectDiagram::RectDiagram(int _cx, int _cy) : Diagram(_cx, _cy)
{
x1 = 10; // position of label text
y1 = y3 = 32;
y1 = y3 = 33;
x2 = 240; // initial size of diagram
y2 = 160;
x3 = 247;
@ -374,8 +374,8 @@ if(xAxis.log) {
if(fabs(log10(zD)) < 3.0) tmp = StringNum(zD);
else tmp = StringNum(zD, 'e', 1);
if(set_log) Texts.append(new Text(z-10, -5, '-'+tmp));
else Texts.append(new Text(z-10, -5, tmp));
if(set_log) Texts.append(new Text(z-10, -6, '-'+tmp));
else Texts.append(new Text(z-10, -6, tmp));
Lines.append(new Line(z, 5, z, -5, QPen(QPen::black,0))); // x marks
}
@ -413,7 +413,7 @@ else { // not logarithmical
z = int(zD);
}
} // of "if(xlog) ... else ..."
y1 = QucsSettings.font.pointSize()+20;
// ==== y grid =======================================================

View File

@ -18,9 +18,11 @@
#ifndef ELEMENT_H
#define ELEMENT_H
#include <qpainter.h>
#include <qpen.h>
#include <qbrush.h>
class Node;
class QPainter;
/**
*@author Michael Margraf

View File

@ -44,6 +44,8 @@ tQucsSettings QucsSettings
QFont savingFont; // to remember which font to save in "qucsrc"
QucsApp *QucsMain; // the Qucs application itself
// just dummies for empty lists
QPtrList<Wire> SymbolWires;
QPtrList<Node> SymbolNodes;
@ -204,10 +206,10 @@ int main(int argc, char *argv[])
tor.load( QString("qucs_") + QTextCodec::locale(), LANGUAGEDIR );
a.installTranslator( &tor );
QucsApp *qucs = new QucsApp();
a.setMainWidget(qucs);
qucs->show();
QucsMain = new QucsApp();
a.setMainWidget(QucsMain);
QucsMain->show();
int result = a.exec();
saveApplSettings(qucs);
saveApplSettings(QucsMain);
return result;
}

View File

@ -42,6 +42,8 @@ struct tQucsSettings {
extern tQucsSettings QucsSettings; // extern because nearly everywhere used
extern QFont savingFont; // to remember which font to save in "qucsrc"
extern QucsApp *QucsMain; // the Qucs application itself
bool saveApplSettings(QucsApp*);
QString complexRect (double, double, int Precision=3);

View File

@ -28,7 +28,7 @@
*/
class Arrow : public Painting {
public:
public:
Arrow();
~Arrow();

View File

@ -20,12 +20,13 @@
#include "painting.h"
/**
*@author Michael Margraf
*/
class GraphicLine : public Painting {
public:
public:
GraphicLine(int cx_=0, int cy_=0, int x2_=0, int y2_=0,
QPen Pen_=QPen(QColor()));
~GraphicLine();

View File

@ -1,6 +1,6 @@
/***************************************************************************
graphictext.cpp - description
-------------------
graphictext.cpp
-----------------
begin : Mon Nov 24 2003
copyright : (C) 2003 by Michael Margraf
email : michael.margraf@alumni.tu-berlin.de

View File

@ -1,5 +1,5 @@
/***************************************************************************
graphictext.h - description
graphictext.h
-------------------
begin : Mon Nov 24 2003
copyright : (C) 2003 by Michael Margraf
@ -20,12 +20,13 @@
#include "painting.h"
/**
*@author Michael Margraf
*/
class GraphicText : public Painting {
public:
public:
GraphicText();
~GraphicText();

View File

@ -1,6 +1,6 @@
/***************************************************************************
graphictextdialog.cpp - description
-------------------
graphictextdialog.cpp
-----------------------
begin : Wed Nov 26 2003
copyright : (C) 2003 by Michael Margraf
email : michael.margraf@alumni.tu-berlin.de
@ -18,6 +18,7 @@
#include "graphictextdialog.h"
#include "qucs.h"
#include "qucsview.h"
#include <qlayout.h>
#include <qlabel.h>
@ -87,10 +88,10 @@ GraphicTextDialog::GraphicTextDialog(QWidget *parent, const char *name)
Angle->setMaximumWidth(35);
Angle->setText("0");
// if(((QucsApp*)pApp->mainWidget())->view->Docs.current()->symbolMode) {
// l1->setEnabled(false);
// Angle->setEnabled(false);
// }
if(QucsMain->view->Docs.current()->symbolMode) {
l1->setEnabled(false);
Angle->setEnabled(false);
}
text->setFocus();
}

View File

@ -1,6 +1,6 @@
/***************************************************************************
graphictextdialog.h - description
-------------------
graphictextdialog.h
---------------------
begin : Wed Nov 26 2003
copyright : (C) 2003 by Michael Margraf
email : michael.margraf@alumni.tu-berlin.de
@ -20,7 +20,6 @@
#include <qdialog.h>
class QLineEdit;
class QTextEdit;
class QPushButton;

View File

@ -21,7 +21,7 @@
#include "element.h"
#include "viewpainter.h"
#include <qpainter.h>
class QPainter;
/**
*@author Michael Margraf

View File

@ -28,7 +28,7 @@
*/
class Rectangle : public Painting {
public:
public:
Rectangle(bool _filled=false);
~Rectangle();