21 #include <QTextStream>
23 #include <QMouseEvent>
41 #include <QInputDialog>
43 #include <QApplication>
44 #include <QMessageBox>
45 #include <Q3PopupMenu>
54 #define DOC_X_POS(x) (int(float(x)/Doc->Scale) + Doc->ViewX1)
55 #define DOC_Y_POS(y) (int(float(y)/Doc->Scale) + Doc->ViewY1)
56 #define DOC_X_FPOS (float(Event->pos().x())/Doc->Scale + float(Doc->ViewX1))
57 #define DOC_Y_FPOS (float(Event->pos().y())/Doc->Scale + float(Doc->ViewY1))
59 #define SCR_X_POS(x) int(float(x - Doc->ViewX1) * Doc->Scale)
60 #define SCR_Y_POS(y) int(float(y - Doc->ViewY1) * Doc->Scale)
75 focusMEvent =
new QMouseEvent(QEvent::MouseButtonPress, QPoint(0,0),
76 Qt::NoButton, Qt::NoButton);
102 QClipboard *cb = QApplication::clipboard();
103 QString s = cb->text(QClipboard::Clipboard);
104 QTextStream stream(&s, QIODevice::ReadOnly);
109 int xmax, xmin, ymax, ymin;
110 xmin = ymin = INT_MAX;
111 xmax = ymax = INT_MIN;
115 if(pe->
x1 < xmin) xmin = pe->
x1;
116 if(pe->
x2 > xmax) xmax = pe->
x2;
117 if(pe->
y1 < ymin) ymin = pe->
y1;
118 if(pe->
y2 > ymax) ymax = pe->
y2;
121 if(pe->
cx < xmin) xmin = pe->
cx;
122 if(pe->
cx > xmax) xmax = pe->
cx;
123 if(pe->
cy < ymin) ymin = pe->
cy;
124 if(pe->
cy > ymax) ymax = pe->
cy;
128 xmin = -((xmax+xmin) >> 1);
129 ymin = -((ymax+ymin) >> 1);
135 pe->
cx += xmin; pe->
x1 += xmin;
136 pe->
cy += ymin; pe->
y1 += ymin;
148 int Result = Dia->exec();
149 if(Result == 0)
return;
151 QString Name = Dia->
NodeName->text();
155 if(Name.isEmpty() && Value.isEmpty()) {
164 if(Result == 1)
return;
169 if(pl->
cx > (pl->
x1+(pl->
x2>>1)))
170 pl->
x1 -= pl->
x2 - old_x2;
174 Doc->viewport()->update();
184 for(pe = movElements->first(); pe!=0; pe = movElements->next()) {
189 if(pe->
y1 == pe->
y2) {
191 if(((
Wire*)pe)->Label) {
193 ((
Wire*)pe)->Label = 0;
223 movElements->clear();
230 Doc->viewport()->update();
240 for(pe = movElements->first(); pe != 0; pe = movElements->next()) {
244 if(((
unsigned long)pw->
Port1) > 3) {
245 pw->
x1 += x; pw->
y1 += y;
248 else {
if(
long(pw->
Port1) & 1) { pw->
x1 += x; }
249 if(
long(pw->
Port1) & 2) { pw->
y1 += y; } }
251 if(((
unsigned long)pw->
Port2) > 3) { pw->
x2 += x; pw->
y2 += y; }
252 else {
if(
long(pw->
Port2) & 1) pw->
x2 += x;
253 if(
long(pw->
Port2) & 2) pw->
y2 += y; }
279 int x = Event->pos().x();
280 int y = Event->pos().y();
293 x -= Doc->contentsX();
294 y -= Doc->contentsY();
298 Doc->viewport()->update();
312 Doc->viewport()->update();
337 Doc->viewport()->update();
357 Doc->viewport()->update();
372 if(abs(
MAx2) > abs(MAy2)) {
375 else {
if(MAy2<0) MAy2 = -abs(
MAx2);
else MAy2 = abs(
MAx2); }
408 Doc->viewport()->repaint();
421 else {
if(
long(pw->
Port2) & 1) pw->
x2 += MAx1;
422 if(
long(pw->
Port2) & 2) pw->
y2 += MAy1; }
432 else pe->setCenter(MAx1, MAy1,
true);
434 pe->paintScheme(Doc);
463 if((Event->state() & Qt::ControlModifier) == 0)
473 pe->paintScheme(Doc);
715 Doc->viewport()->update();
742 QObject::tr(
"Edit Properties"),
QucsMain, SLOT(slotEditElement()));
770 SLOT(slotSaveDiagramToGraphicsFile()));
780 QString s = QObject::tr(
"power matching");
782 s = QObject::tr(
"noise matching");
786 SLOT(slot2PortMatching()));
822 Doc->viewport()->update();
829 int x = int(fX), y = int(fY);
845 QMessageBox::information(0, QObject::tr(
"Info"),
846 QObject::tr(
"The ground potential cannot be labeled!"));
853 if(Dia->exec() == 0)
return;
859 if(Name.isEmpty() && Value.isEmpty() ) {
885 if(pw) pw->
setName(Name, Value, x-pw->
x1 + y-pw->
y1, xl, yl);
886 else pn->
setName(Name, Value, xl, yl);
890 Doc->viewport()->update();
899 if(Event->state() & Qt::ControlModifier) Ctrl =
true;
910 qDebug() <<
"MPressSelect: focusElement->Type" << QString(
"0x%1").arg(
focusElement->
Type, 0, 16);
912 qDebug() <<
"MPressSelect";
984 Doc->viewport()->update();
1026 Doc->grabKeyboard();
1027 Doc->viewport()->update();
1062 Doc->viewport()->update();
1080 Doc->viewport()->update();
1090 if(c->
Ports.count() < 1)
return;
1100 Doc->viewport()->update();
1111 if(c->
Ports.count() < 1)
return;
1121 Doc->viewport()->update();
1151 pl = ((
Wire*)e)->Label;
1152 ((
Wire*)e)->Label = 0;
1153 Doc->
Wires->setAutoDelete(
false);
1155 ((
Wire*)e)->Label = pl;
1161 Doc->
Wires->setAutoDelete(
true);
1169 ((
Painting*)e)->Bounding(x1,y1,x2,y2);
1176 Doc->viewport()->update();
1190 int x1, y1, x2, y2, rot;
1194 QString entryName = Comp->
Name;
1196 switch(Event->button()) {
1197 case Qt::LeftButton :
1205 if(Comp->
tx < Comp->
x1) Comp->
tx -= x2 - x1;
1215 Doc->viewport()->update();
1224 Comp =
dynamic_cast<vacomponent*
>(Comp)->newOne(filename);
1225 qDebug() <<
" => recast = Comp;" << Comp->
Name <<
"filename: " << filename;
1232 while(rot--) Comp->
rotate();
1235 case Qt::RightButton :
1236 if(Comp->
Ports.count() == 0)
1252 if(Event->button() != Qt::LeftButton)
return;
1259 Info.dirPath() + QDir::separator() + Doc->
DataSet, Doc);
1260 if(dia->exec() == QDialog::Rejected) {
1261 Doc->viewport()->update();
1270 Doc->viewport()->repaint();
1285 Doc->viewport()->update();
1320 Doc->viewport()->update();
1334 int set1 = 0, set2 = 0;
1335 switch(Event->button()) {
1336 case Qt::LeftButton :
1368 Doc->viewport()->update();
1376 case Qt::RightButton :
1403 Doc->viewport()->update();
1419 Doc->viewport()->update();
1438 Doc->viewport()->update();
1456 Doc->viewport()->update();
1460 Doc->grabKeyboard();
1467 qDebug() <<
"zoom into box";
1476 Doc->grabKeyboard();
1477 Doc->viewport()->update();
1490 if(Event->state() & Qt::ControlModifier) ctrl =
true;
1501 Doc->releaseKeyboard();
1507 Doc->viewport()->update();
1515 if(Event->button() != Qt::LeftButton)
return;
1518 if(Event->state() & Qt::ControlModifier) Ctrl =
true;
1524 Doc->releaseKeyboard();
1530 Doc->viewport()->update();
1537 if(Event->button() != Qt::LeftButton)
return;
1547 Doc->viewport()->update();
1558 Doc->releaseKeyboard();
1569 if(Event->button() != Qt::LeftButton)
return;
1599 for(
Marker *pm = pg->Markers.first(); pm!=0; pm = pg->Markers.next()) {
1612 Doc->releaseKeyboard();
1614 Doc->viewport()->update();
1622 if(Event->button() != Qt::LeftButton)
return;
1628 Doc->releaseKeyboard();
1630 Doc->viewport()->update();
1651 pe->
cx += x1; pe->
x1 += x1;
1652 pe->
cy += y1; pe->
y1 += y1;
1677 pe->
x1 = pe->
y1 - y1 + x1;
1678 pe->
y1 = x1 - x2 + y1;
1680 pe->
x2 = pe->
y2 - y1 + x1;
1681 pe->
y2 = x1 - x2 + y1;
1685 ((
Painting*)pe)->getCenter(x2, y2);
1686 pe->
setCenter(y2 - y1 + x1, x1 - x2 + y1);
1699 int x1, y1, x2, y2, rot;
1704 switch(Event->button()) {
1705 case Qt::LeftButton :
1711 if(pe->
x1 == pe->
x2)
if(pe->
y1 == pe->
y2)
break;
1713 if (Doc->
Wires->containsRef ((
Wire*)pe))
1719 ((
Diagram*)pe)->loadGraphData(Info.dirPath() + QDir::separator() +
1725 ((
Painting*)pe)->Bounding(x1,y1,x2,y2);
1754 Doc->viewport()->update();
1759 case Qt::RightButton :
1782 if(Event->button() != Qt::LeftButton)
return;
1786 Doc->releaseKeyboard();
1790 Doc->viewport()->update();
1798 if(Event->button() != Qt::LeftButton)
return;
1800 MAx1 = Event->pos().x();
1801 MAy1 = Event->pos().y();
1802 float DX = float(abs(
MAx2));
1803 float DY = float(abs(
MAy2));
1804 if((Doc->
Scale * DX) < 6.0) {
1809 MAx1 = int(DX *
float(Event->pos().x()));
1810 MAy1 = int(DX *
float(Event->pos().y()));
1813 float xScale = float(Doc->visibleWidth()) / DX;
1814 float yScale = float(Doc->visibleHeight()) / DY;
1815 if(xScale > yScale) xScale = yScale;
1816 yScale = Doc->
Scale;
1822 MAx1 = int(
float(
MAx1) * xScale) - Doc->contentsX();
1823 MAy1 = int(
float(
MAy1) * xScale) - Doc->contentsY();
1829 Doc->releaseKeyboard();
1862 if(c->
Model ==
"GND")
return;
1864 if(c->
Model ==
"SPICE") {
1866 if(sd->exec() != 1)
break;
1868 else if(c->
Model ==
".Opt") {
1870 if(od->exec() != 1)
break;
1874 if(cd->exec() != 1)
break;
1889 if(dia->
Name.at(0) ==
'T') {
1890 if(dia->
Name ==
"Time") {
1891 if(dia->
cy <
int(fY)) {
1898 if(dia->
cx >
int(fX)) {
1907 Info.dirPath() + QDir::separator() + Doc->
DataSet, Doc);
1908 if(ddia->exec() != QDialog::Rejected)
1919 if(dia->
Graphs.findRef(pg) >= 0)
1925 Info.dirPath() + QDir::separator() + Doc->
DataSet, Doc, pg);
1926 if(ddia->exec() != QDialog::Rejected)
1947 if(mdia->exec() > 1)
1958 Doc->viewport()->update();
1965 Doc->releaseKeyboard();
virtual Component * newOne()
void MPressElement(Schematic *, QMouseEvent *, float, float)
void MMoveLabel(Schematic *, QMouseEvent *)
MouseActions::MMoveLabel Paints a label above the mouse cursor for "set wire label".
void rotateElements(Schematic *, int &, int &)
void MMoveMoving2(Schematic *, QMouseEvent *)
void MMoveMoving(Schematic *, QMouseEvent *)
void MMoveActivate(Schematic *, QMouseEvent *)
MouseActions::MMoveActivate Paints a crossed box mouse cursor to "(de)activate" components.
void setName(const QString &, const QString &, int x_=0, int y_=0)
Marker * setMarker(int, int)
void PostPaintEvent(PE pe, int x1=0, int y1=0, int x2=0, int y2=0, int a=0, int b=0, bool PaintOnViewport=false)
void MReleaseSelect2(Schematic *, QMouseEvent *)
label for Node and Wire classes
void(MouseActions::* MouseMoveAction)(Schematic *, QMouseEvent *)
void MMoveMirrorY(Schematic *, QMouseEvent *)
MouseActions::MMoveMirrorX Paints rounded "mirror about y axis" mouse cursor.
void MMoveElement(Schematic *, QMouseEvent *)
void editElement(Schematic *, QMouseEvent *)
Node * selectedNode(int, int)
void setName(const QString &Name_)
tQucsSettings QucsSettings
void MMoveMirrorX(Schematic *, QMouseEvent *)
MouseActions::MMoveMirrorX Paints rounded "mirror about x axis" mouse cursor.
void(MouseActions::* MousePressAction)(Schematic *, QMouseEvent *, float, float)
void MPressActivate(Schematic *, QMouseEvent *, float, float)
void MMoveOnGrid(Schematic *, QMouseEvent *)
MouseActions::MMoveOnGrid Paints a grid beside the mouse cursor, put "on grid" mode.
int selectElements(int, int, int, int, bool)
void MMoveMoveTextB(Schematic *, QMouseEvent *)
MouseActions::MMoveMoveTextB Paints mouse symbol for "move component text" mode.
void MPressLabel(Schematic *, QMouseEvent *, float, float)
bool paste(QTextStream *, Q3PtrList< Element > *)
void MPressMirrorX(Schematic *, QMouseEvent *, float, float)
Q3PopupMenu * ComponentMenu
void setOnGrid(int &, int &)
int textSize(int &, int &)
void MMoveRotate(Schematic *, QMouseEvent *)
MouseActions::MMoveMirrorX Paints "rotate" mouse cursor.
void MReleaseMoveText(Schematic *, QMouseEvent *)
void endElementMoving(Schematic *, Q3PtrList< Element > *)
void MPressDelete(Schematic *, QMouseEvent *, float, float)
void MPressMarker(Schematic *, QMouseEvent *, float, float)
Q3PtrList< Element > movingElements
void MMoveResizePainting(Schematic *, QMouseEvent *)
void insertRawComponent(Component *, bool noOptimize=true)
Painting * selectedPainting(float, float)
#define isDigitalComponent
void enlargeView(int, int, int, int)
Q3PtrList< Diagram > * Diagrams
void MMoveScrollBar(Schematic *, QMouseEvent *)
Definitions and declarations for the main application.
void MPressWire1(Schematic *, QMouseEvent *, float, float)
MouseActions::MPressWire1 Is called if starting point of wire is pressed.
void MMoveWire1(Schematic *, QMouseEvent *)
MouseActions::MMoveWire1 Paint hair cross for "insert wire" mode.
void MReleaseResizePainting(Schematic *, QMouseEvent *)
void MMovePaste(Schematic *, QMouseEvent *)
MouseActions::MMovePaste Moves components after paste from clipboard.
void entireBounds(int &, int &, int &, int &, float)
void setPainter(Schematic *)
int copySelectedElements(Q3PtrList< Element > *)
Q3PtrList< Component > * Components
Element * selectElement(float, float, bool, int *index=0)
void MReleaseSelect(Schematic *, QMouseEvent *)
void MMoveMarker(Schematic *, QMouseEvent *)
MouseActions::MMoveMarker Paints a triangle above the mouse for "set marker on graph".
Component * selectCompText(int, int, int &, int &)
Component * selectedComponent(int, int)
void MReleaseActivate(Schematic *, QMouseEvent *)
int placeNodeLabel(WireLabel *)
void MPressOnGrid(Schematic *, QMouseEvent *, float, float)
virtual void setSchematic(Schematic *p)
Q3PtrList< Graph > Graphs
void Bounding(int &, int &, int &, int &)
void MMoveSelect(Schematic *, QMouseEvent *)
MouseActions::MMoveSelect Paints a rectangle for select area.
void setCompPorts(Component *)
void MPressRotate(Schematic *, QMouseEvent *, float, float)
void(MouseActions::* MouseReleaseAction)(Schematic *, QMouseEvent *)
#define isAnalogComponent
Superclass of all schematic drawing elements.
void MReleaseMoving(Schematic *, QMouseEvent *)
void MMoveMoveText(Schematic *, QMouseEvent *)
MouseActions::MMoveMoveText Paint rectangle around component text being mouse moved.
static QMap< QString, QString > vaComponents
void editLabel(Schematic *, WireLabel *)
bool activateSpecifiedComponent(int, int)
void MDoubleClickWire2(Schematic *, QMouseEvent *)
MouseActions::MDoubleClickWire2 Double click terminates wire insertion.
void MMoveDelete(Schematic *, QMouseEvent *)
MouseActions::MMoveDelete Paints a cross under the mouse cursor to show the delete mode...
Element * getWireLabel(Node *)
void MPressWire2(Schematic *, QMouseEvent *, float, float)
MouseActions::MPressWire2 Is called if ending point of wire is pressed.
void MReleasePaste(Schematic *, QMouseEvent *)
Wire * selectedWire(int, int)
virtual Diagram * newOne()
void MPressMoveText(Schematic *, QMouseEvent *, float, float)
void(MouseActions::* MouseDoubleClickAction)(Schematic *, QMouseEvent *)
void selectWireLine(Element *, Node *, bool)
void paintElementsScheme(Schematic *)
void setComponentNumber(Component *)
void MReleaseZoomIn(Schematic *, QMouseEvent *)
bool pasteElements(Schematic *)
void moveElements(Schematic *, int &, int &)
Definition of the vacomponent class.
void activateCompsWithinRect(int, int, int, int)
void paintScheme(Schematic *)
virtual void paintScheme(Schematic *)
void MPressMirrorY(Schematic *, QMouseEvent *, float, float)
void sizeOfAll(int &, int &, int &, int &)
void rightPressMenu(Schematic *, QMouseEvent *, float, float)
void deselectElements(Element *)
void MDoubleClickSelect(Schematic *, QMouseEvent *)
QMouseEvent * focusMEvent
Q3PtrList< Painting > * Paintings
Q3PtrList< Wire > * Wires
void MMoveWire2(Schematic *, QMouseEvent *)
MouseActions::MMoveWire2 Paint wire as it is being drawn with mouse.
virtual bool scrollTo(int, int, int)
void MPressSelect(Schematic *, QMouseEvent *, float, float)
void MMoveZoomIn(Schematic *, QMouseEvent *)
MouseActions::MMoveZoomIn Paints symbol beside the mouse to show the "Zoom in" modus.
void insertComponent(Component *)
void setName(const QString &, const QString &, int delta_=0, int x_=0, int y_=0)
void highlightWireLabels(void)
virtual void setCenter(int, int, bool relative=false)
void paintScheme(Schematic *)
void MReleaseResizeDiagram(Schematic *, QMouseEvent *)
void setChanged(bool, bool fillStack=false, char Op='*')
void insertNodeLabel(WireLabel *)
void MPressZoomIn(Schematic *, QMouseEvent *, float, float)