Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mouseactions.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  mouseactions.cpp
3  ------------------
4  begin : Thu Aug 28 2003
5  copyright : (C) 2003 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
7  ***************************************************************************/
8 
9 /* Copyright (C) 2014 Guilherme Brondani Torri <guitorri@gmail.com> */
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 #include <QtGui>
20 #include "qucs.h"
21 #include <QTextStream>
22 #include <Q3PtrList>
23 #include <QMouseEvent>
24 #include "main.h"
25 #include "node.h"
26 #include "schematic.h"
27 #include "mouseactions.h"
28 #include "module.h"
29 #include "components/component.h"
30 #include "components/spicedialog.h"
31 #include "components/spicefile.h"
34 #include "components/vacomponent.h"
35 #include "diagrams/diagramdialog.h"
36 #include "diagrams/markerdialog.h"
37 #include "diagrams/tabdiagram.h"
38 #include "diagrams/timingdiagram.h"
39 #include "dialogs/labeldialog.h"
40 
41 #include <QInputDialog>
42 #include <QClipboard>
43 #include <QApplication>
44 #include <QMessageBox>
45 #include <Q3PopupMenu>
46 #include <QEvent>
47 #include <QAction>
48 #include <QTabWidget>
49 
50 #include <limits.h>
51 #include <stdlib.h>
52 
53 
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))
58 
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)
61 
62 QAction *formerAction; // remember action before drag n'drop etc.
63 
64 
66 {
67  App = App_; // pointer to main app
68  selElem = 0; // no component/diagram is selected
69  isMoveEqual = false; // mouse cursor move x and y the same way
70  focusElement = 0; //element being interacted with mouse
71 
72  // ...............................................................
73  // initialize menu appearing by right mouse button click on component
74  ComponentMenu = new Q3PopupMenu(QucsMain);
75  focusMEvent = new QMouseEvent(QEvent::MouseButtonPress, QPoint(0,0),
76  Qt::NoButton, Qt::NoButton);
77 }
78 
79 
81 {
82  delete ComponentMenu;
83  delete focusMEvent;
84 }
85 
86 // -----------------------------------------------------------
88 {
89  // contents to viewport transformation
90 
91  Doc->PostPaintEvent(_Translate,-Doc->contentsX(), -Doc->contentsY());
92  Doc->PostPaintEvent(_Scale,Doc->Scale, Doc->Scale);
93  Doc->PostPaintEvent(_Translate,-Doc->ViewX1, -Doc->ViewY1);
95  Doc->PostPaintEvent(_NotRop);
96 
97 }
98 
99 // -----------------------------------------------------------
101 {
102  QClipboard *cb = QApplication::clipboard(); // get system clipboard
103  QString s = cb->text(QClipboard::Clipboard);
104  QTextStream stream(&s, QIODevice::ReadOnly);
105  movingElements.clear();
106  if(!Doc->paste(&stream, &movingElements)) return false;
107 
108  Element *pe;
109  int xmax, xmin, ymax, ymin;
110  xmin = ymin = INT_MAX;
111  xmax = ymax = INT_MIN;
112  // First, get the max and min coordinates of all selected elements.
113  for(pe = movingElements.first(); pe != 0; pe = movingElements.next()) {
114  if(pe->Type == isWire) {
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;
119  }
120  else {
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;
125  }
126  }
127 
128  xmin = -((xmax+xmin) >> 1); // calculate midpoint
129  ymin = -((ymax+ymin) >> 1);
130  Doc->setOnGrid(xmin, ymin);
131 
132  // moving with mouse cursor in the midpoint
133  for(pe = movingElements.first(); pe != 0; pe = movingElements.next())
134  if(pe->Type & isLabel) {
135  pe->cx += xmin; pe->x1 += xmin;
136  pe->cy += ymin; pe->y1 += ymin;
137  }
138  else
139  pe->setCenter(xmin, ymin, true);
140 
141  return true;
142 }
143 
144 // -----------------------------------------------------------
146 {
147  LabelDialog *Dia = new LabelDialog(pl, Doc);
148  int Result = Dia->exec();
149  if(Result == 0) return;
150 
151  QString Name = Dia->NodeName->text();
152  QString Value = Dia->InitValue->text();
153  delete Dia;
154 
155  if(Name.isEmpty() && Value.isEmpty()) { // if nothing entered, delete label
156  pl->pOwner->Label = 0; // delete name of wire
157  delete pl;
158  }
159  else {
160 /* Name.replace(' ', '_'); // label must not contain spaces
161  while(Name.at(0) == '_') Name.remove(0,1); // must not start with '_'
162  if(Name.isEmpty()) return;
163  if(Name == pl->Name) return;*/
164  if(Result == 1) return; // nothing changed
165 
166  int old_x2 = pl->x2;
167  pl->setName(Name); // set new name
168  pl->initValue = Value;
169  if(pl->cx > (pl->x1+(pl->x2>>1)))
170  pl->x1 -= pl->x2 - old_x2; // don't change position due to text width
171  }
172 
173  Doc->sizeOfAll(Doc->UsedX1, Doc->UsedY1, Doc->UsedX2, Doc->UsedY2);
174  Doc->viewport()->update();
175  drawn = false;
176  Doc->setChanged(true, true);
177 }
178 
179 // -----------------------------------------------------------
180 // Reinserts all elements (moved by the user) back into the schematic.
181 void MouseActions::endElementMoving(Schematic *Doc, Q3PtrList<Element> *movElements)
182 {
183  Element *pe;
184  for(pe = movElements->first(); pe!=0; pe = movElements->next()) {
185 // pe->isSelected = false; // deselect first (maybe afterwards pe == NULL)
186  switch(pe->Type) {
187  case isWire:
188  if(pe->x1 == pe->x2)
189  if(pe->y1 == pe->y2) {
190  // Delete wires with zero length, but preserve label.
191  if(((Wire*)pe)->Label) {
192  Doc->insertNodeLabel((WireLabel*)((Wire*)pe)->Label);
193  ((Wire*)pe)->Label = 0;
194  }
195  delete (Wire*)pe;
196  break;
197  }
198 
199  Doc->insertWire((Wire*)pe);
200  break;
201  case isDiagram:
202  Doc->Diagrams->append((Diagram*)pe);
203  break;
204  case isPainting:
205  Doc->Paintings->append((Painting*)pe);
206  break;
207  case isComponent:
208  case isAnalogComponent:
209  case isDigitalComponent:
210  Doc->insertRawComponent((Component*)pe, false);
211  break;
212  case isMovingLabel:
213  case isHMovingLabel:
214  case isVMovingLabel:
215  Doc->insertNodeLabel((WireLabel*)pe);
216  break;
217  case isMarker:
218  ((Marker*)pe)->pGraph->Markers.append((Marker*)pe);
219  break;
220  }
221  }
222 
223  movElements->clear();
224  if((MAx3 != 0) || (MAy3 != 0)) // moved or put at the same place ?
225  Doc->setChanged(true, true);
226 
227  // enlarge viewarea if components lie outside the view
228  Doc->sizeOfAll(Doc->UsedX1, Doc->UsedY1, Doc->UsedX2, Doc->UsedY2);
229  Doc->enlargeView(Doc->UsedX1, Doc->UsedY1, Doc->UsedX2, Doc->UsedY2);
230  Doc->viewport()->update();
231  drawn = false;
232 }
233 
234 // -----------------------------------------------------------
235 // Moves elements in "movElements" by x/y
236 void MouseActions::moveElements(Q3PtrList<Element> *movElements, int x, int y)
237 {
238  Wire *pw;
239  Element *pe;
240  for(pe = movElements->first(); pe != 0; pe = movElements->next()) {
241  if(pe->Type == isWire) {
242  pw = (Wire*)pe; // connected wires are not moved completely
243 
244  if(((unsigned long)pw->Port1) > 3) {
245  pw->x1 += x; pw->y1 += y;
246  if(pw->Label) { pw->Label->cx += x; pw->Label->cy += y; }
247  }
248  else { if(long(pw->Port1) & 1) { pw->x1 += x; }
249  if(long(pw->Port1) & 2) { pw->y1 += y; } }
250 
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; }
254 
255  if(pw->Label) { // root of node label must lie on wire
256  if(pw->Label->cx < pw->x1) pw->Label->cx = pw->x1;
257  if(pw->Label->cy < pw->y1) pw->Label->cy = pw->y1;
258  if(pw->Label->cx > pw->x2) pw->Label->cx = pw->x2;
259  if(pw->Label->cy > pw->y2) pw->Label->cy = pw->y2;
260  }
261 
262  }
263  else pe->setCenter(x, y, true);
264  }
265 }
266 
267 
268 // ***********************************************************************
269 // ********** **********
270 // ********** Functions for serving mouse moving **********
271 // ********** **********
272 // ***********************************************************************
273 void MouseActions::MMoveElement(Schematic *Doc, QMouseEvent *Event)
274 {
275  if(selElem == 0) return;
276 
277 // qDebug() << "MMoveElement got selElem";
278 
279  int x = Event->pos().x();
280  int y = Event->pos().y();
281  int fx = DOC_X_POS(x);
282  int fy = DOC_Y_POS(y);
283  int gx = fx;
284  int gy = fy;
285  Doc->setOnGrid(gx, gy);
286 
287 
288  //QPainter painter(Doc->viewport());
289  setPainter(Doc);
290 
291  if(selElem->Type == isPainting) {
292  Doc->PostPaintEvent (_NotRop, 0,0,0,0);
293  x -= Doc->contentsX();
294  y -= Doc->contentsY();
295  ((Painting*)selElem)->MouseMoving(Doc, x, y, gx, gy,
296  Doc, x, y, drawn);
297  drawn = true;
298  Doc->viewport()->update();
299  return;
300  } // of "if(isPainting)"
301 
302 
303  // ********** it is a component or diagram
304  if(drawn) selElem->paintScheme(Doc); // erase old scheme
305  drawn = true;
306 
307 // Component *comp = (Component*)selElem;
308  //qDebug() << "desc" << comp->Description << "gx" << gx << "gy" << gy;
309 
310  selElem->setCenter(gx, gy);
311  selElem->paintScheme(Doc); // paint scheme at new position
312  Doc->viewport()->update();
313 }
314 
315 // -----------------------------------------------------------
321 void MouseActions::MMoveWire2(Schematic *Doc, QMouseEvent *Event)
322 {
323  MAx2 = DOC_X_POS(Event->pos().x());
324  MAy2 = DOC_Y_POS(Event->pos().y());
325  Doc->setOnGrid(MAx2, MAy2);
326 
327  if(MAx1 == 0) {
328  Doc->PostPaintEvent (_Line, MAx3, MAy3, MAx3, MAy2); // paint
329  Doc->PostPaintEvent (_Line, MAx3, MAy2, MAx2, MAy2); // paint
330  }
331  else {
332  Doc->PostPaintEvent (_Line, MAx3, MAy3, MAx2, MAy3); // paint
333  Doc->PostPaintEvent (_Line, MAx2, MAy3, MAx2, MAy2); // paint
334  }
335 
337  Doc->viewport()->update();
338 }
339 
340 
346 void MouseActions::MMoveWire1(Schematic *Doc, QMouseEvent *Event)
347 {
348  MAx3 = DOC_X_POS(Event->pos().x());
349  MAy3 = DOC_Y_POS(Event->pos().y());
350  Doc->setOnGrid(MAx3, MAy3);
351 
352  MAx2 = DOC_X_POS(Doc->viewport()->width());
353  MAy2 = DOC_Y_POS(Doc->viewport()->height());
354 
355  Doc->PostPaintEvent (_Line, Doc->ViewX1, MAy3, MAx2, MAy3);
356  Doc->PostPaintEvent (_Line, MAx3, Doc->ViewY1, MAx3, MAy2);
357  Doc->viewport()->update();
358 }
359 
360 
366 void MouseActions::MMoveSelect(Schematic *Doc, QMouseEvent *Event)
367 {
368  //qDebug() << "MMoveSelect " << "select area";
369  MAx2 = DOC_X_POS(Event->pos().x()) - MAx1;
370  MAy2 = DOC_Y_POS(Event->pos().y()) - MAy1;
371  if(isMoveEqual) { // x and y size must be equal ?
372  if(abs(MAx2) > abs(MAy2)) {
373  if(MAx2<0) MAx2 = -abs(MAy2); else MAx2 = abs(MAy2);
374  }
375  else { if(MAy2<0) MAy2 = -abs(MAx2); else MAy2 = abs(MAx2); }
376  }
377 
378  Doc->PostPaintEvent (_Rect, MAx1, MAy1, MAx2, MAy2);
379 }
380 
381 // -----------------------------------------------------------
382 void MouseActions::MMoveResizePainting(Schematic *Doc, QMouseEvent *Event)
383 {
384  setPainter(Doc);
385 
386  MAx1 = DOC_X_POS(Event->pos().x());
387  MAy1 = DOC_Y_POS(Event->pos().y());
388  Doc->setOnGrid(MAx1, MAy1);
389  ((Painting*)focusElement)->MouseResizeMoving(MAx1, MAy1, Doc);
390 }
391 
392 // -----------------------------------------------------------
393 // Moves components by keeping the mouse button pressed.
394 void MouseActions::MMoveMoving(Schematic *Doc, QMouseEvent *Event)
395 {
396 
397  setPainter(Doc);
398 
399  MAx2 = DOC_X_POS(Event->pos().x());
400  MAy2 = DOC_Y_POS(Event->pos().y());
401 
402  Doc->setOnGrid(MAx2, MAy2);
403  MAx3 = MAx1 = MAx2 - MAx1;
404  MAy3 = MAy1 = MAy2 - MAy1;
405 
406  movingElements.clear();
408  Doc->viewport()->repaint();
409 
410  Wire *pw;
411  // Changes the position of all moving elements by dx/dy
412  for(Element *pe=movingElements.first(); pe!=0; pe=movingElements.next()) {
413  if(pe->Type == isWire) {
414  pw = (Wire*)pe; // connecting wires are not moved completely
415 
416  if(((unsigned long)pw->Port1) > 3) { pw->x1 += MAx1; pw->y1 += MAy1; }
417  else { if(long(pw->Port1) & 1) { pw->x1 += MAx1; }
418  if(long(pw->Port1) & 2) { pw->y1 += MAy1; } }
419 
420  if(((unsigned long)pw->Port2) > 3) { pw->x2 += MAx1; pw->y2 += MAy1; }
421  else { if(long(pw->Port2) & 1) pw->x2 += MAx1;
422  if(long(pw->Port2) & 2) pw->y2 += MAy1; }
423 
424  if(pw->Label) { // root of node label must lie on wire
425  if(pw->Label->cx < pw->x1) pw->Label->cx = pw->x1;
426  if(pw->Label->cy < pw->y1) pw->Label->cy = pw->y1;
427  if(pw->Label->cx > pw->x2) pw->Label->cx = pw->x2;
428  if(pw->Label->cy > pw->y2) pw->Label->cy = pw->y2;
429  }
430 
431  }
432  else pe->setCenter(MAx1, MAy1, true);
433 
434  pe->paintScheme(Doc);
435  }
436 
437  drawn = true;
438  MAx1 = MAx2;
439  MAy1 = MAy2;
442 
443 }
444 
445 // -----------------------------------------------------------
446 // Moves components by keeping the mouse button pressed.
447 void MouseActions::MMoveMoving2(Schematic *Doc, QMouseEvent *Event)
448 {
449  setPainter(Doc);
450 
451  MAx2 = DOC_X_POS(Event->pos().x());
452  MAy2 = DOC_Y_POS(Event->pos().y());
453 
454  Element *pe;
455  if(drawn) // erase old scheme
456  for(pe = movingElements.first(); pe != 0; pe = movingElements.next())
457  pe->paintScheme(Doc);
458 // if(pe->Type == isWire) if(((Wire*)pe)->Label)
459 // if(!((Wire*)pe)->Label->isSelected)
460 // ((Wire*)pe)->Label->paintScheme(&painter);
461 
462  drawn = true;
463  if((Event->state() & Qt::ControlModifier) == 0)
464  Doc->setOnGrid(MAx2, MAy2); // use grid only if CTRL key not pressed
465  MAx1 = MAx2 - MAx1;
466  MAy1 = MAy2 - MAy1;
467  MAx3 += MAx1; MAy3 += MAy1; // keep track of the complete movement
468 
469  moveElements(&movingElements, MAx1, MAy1); // moves elements by MAx1/MAy1
470 
471  // paint afterwards to avoid conflict between wire and label painting
472  for(pe = movingElements.first(); pe != 0; pe = movingElements.next())
473  pe->paintScheme(Doc);
474 // if(pe->Type == isWire) if(((Wire*)pe)->Label)
475 // if(!((Wire*)pe)->Label->isSelected)
476 // ((Wire*)pe)->Label->paintScheme(&painter);
477 
478  MAx1 = MAx2;
479  MAy1 = MAy2;
480 }
481 
482 
488 void MouseActions::MMovePaste(Schematic *Doc, QMouseEvent *Event)
489 {
490  MAx1 = DOC_X_POS(Event->pos().x());
491  MAy1 = DOC_Y_POS(Event->pos().y());
492  moveElements(Doc,MAx1,MAy1);
493  paintElementsScheme(Doc);
494 
495  drawn = true;
498 }
499 
500 // -----------------------------------------------------------
501 // Moves scroll bar of diagram (e.g. tabular) according the mouse cursor.
502 void MouseActions::MMoveScrollBar(Schematic *Doc, QMouseEvent *Event)
503 {
505  int x = DOC_X_POS(Event->pos().x());
506  int y = DOC_Y_POS(Event->pos().y());
507 
508  if(d->scrollTo(MAx2, x - MAx1, y - MAy1)) {
509  Doc->setChanged(true, true, 'm'); // 'm' = only the first time
510 
511 // FIXME #warning QPainter p(Doc->viewport());
512  // FIXME #warning ViewPainter Painter;
513  // FIXME #warning Painter.init(&p, Doc->Scale, -Doc->ViewX1, -Doc->ViewY1,
514 // FIXME #warning Doc->contentsX(), Doc->contentsY());
515 // FIXME #warning Painter.fillRect(d->cx-d->x1, d->cy-d->y2, d->x2+d->x1, d->y2+d->y1,
516 // FIXME #warning QucsSettings.BGColor);
517 // FIXME #warning d->paint(&Painter);
518  }
519 }
520 
521 
528 void MouseActions::MMoveDelete(Schematic *Doc, QMouseEvent *Event)
529 {
530  MAx3 = DOC_X_POS(Event->pos().x());
531  MAy3 = DOC_Y_POS(Event->pos().y());
532 
533  // cannot draw on the viewport, it is displaced by the size of dock and toolbar
534  Doc->PostPaintEvent (_Line, MAx3-15, MAy3-15, MAx3+15, MAy3+15,0,0,false);
535  Doc->PostPaintEvent (_Line, MAx3-15, MAy3+15, MAx3+15, MAy3-15,0,0,false);
536 }
537 
538 
544 void MouseActions::MMoveLabel(Schematic *Doc, QMouseEvent *Event)
545 {
546  MAx3 = DOC_X_POS(Event->pos().x());
547  MAy3 = DOC_Y_POS(Event->pos().y());
548 
549  // paint marker
550  Doc->PostPaintEvent (_Line, MAx3, MAy3, MAx3+10, MAy3-10);
551  Doc->PostPaintEvent (_Line, MAx3+10, MAy3-10, MAx3+20, MAy3-10);
552  Doc->PostPaintEvent (_Line, MAx3+10, MAy3-10, MAx3+10, MAy3-17);
553 
554  // paint A
555  Doc->PostPaintEvent (_Line, MAx3+12, MAy3-12, MAx3+15, MAy3-23);
556  Doc->PostPaintEvent (_Line, MAx3+14, MAy3-17, MAx3+17, MAy3-17);
557  Doc->PostPaintEvent (_Line, MAx3+19, MAy3-12, MAx3+16, MAy3-23);
558 }
559 
560 
566 void MouseActions::MMoveMarker(Schematic *Doc, QMouseEvent *Event)
567 {
568  MAx3 = DOC_X_POS(Event->pos().x());
569  MAy3 = DOC_Y_POS(Event->pos().y());
570 
571  Doc->PostPaintEvent (_Line, MAx3, MAy3-2, MAx3-8, MAy3-10);
572  Doc->PostPaintEvent (_Line, MAx3+1, MAy3-3, MAx3+8, MAy3-10);
573  Doc->PostPaintEvent (_Line, MAx3-7, MAy3-10, MAx3+7, MAy3-10);
574 }
575 
576 
582 void MouseActions::MMoveMirrorY(Schematic *Doc, QMouseEvent *Event)
583 {
584  MAx3 = DOC_X_POS(Event->pos().x());
585  MAy3 = DOC_Y_POS(Event->pos().y());
586 
587  Doc->PostPaintEvent (_Line, MAx3-11, MAy3-4, MAx3-9, MAy3-9);
588  Doc->PostPaintEvent (_Line, MAx3-11, MAy3-3, MAx3-6, MAy3-3);
589  Doc->PostPaintEvent (_Line, MAx3+11, MAy3-4, MAx3+9, MAy3-9);
590  Doc->PostPaintEvent (_Line, MAx3+11, MAy3-3, MAx3+6, MAy3-3);
591  Doc->PostPaintEvent (_Arc, MAx3-10, MAy3-8, 21, 10, 16*20, 16*140,false);
592 }
593 
594 
600 void MouseActions::MMoveMirrorX(Schematic *Doc, QMouseEvent *Event)
601 {
602  MAx3 = DOC_X_POS(Event->pos().x());
603  MAy3 = DOC_Y_POS(Event->pos().y());
604 
605  Doc->PostPaintEvent (_Line, MAx3-4, MAy3-11, MAx3-9, MAy3-9);
606  Doc->PostPaintEvent (_Line, MAx3-3, MAy3-11, MAx3-3, MAy3-6);
607  Doc->PostPaintEvent (_Line, MAx3-4, MAy3+11, MAx3-9, MAy3+9);
608  Doc->PostPaintEvent (_Line, MAx3-3, MAy3+11, MAx3-3, MAy3+6);
609  Doc->PostPaintEvent (_Arc, MAx3-8, MAy3-10, 10, 21, 16*110, 16*140,false);
610 }
611 
617 void MouseActions::MMoveRotate(Schematic *Doc, QMouseEvent *Event)
618 {
619  MAx3 = DOC_X_POS(Event->pos().x());
620  MAy3 = DOC_Y_POS(Event->pos().y());
621 
622  Doc->PostPaintEvent (_Line, MAx3-6, MAy3+8, MAx3-6, MAy3+1);
623  Doc->PostPaintEvent (_Line, MAx3-7, MAy3+8, MAx3-12, MAy3+8);
624  Doc->PostPaintEvent (_Arc, MAx3-10, MAy3-10, 21, 21, -16*20, 16*240,false);
625 }
626 
627 
633 void MouseActions::MMoveActivate(Schematic *Doc, QMouseEvent *Event)
634 {
635  MAx3 = DOC_X_POS(Event->pos().x());
636  MAy3 = DOC_Y_POS(Event->pos().y());
637 
638  Doc->PostPaintEvent (_Rect, MAx3, MAy3-9, 14, 10);
639  Doc->PostPaintEvent (_Line, MAx3, MAy3-9, MAx3+13, MAy3);
640  Doc->PostPaintEvent (_Line, MAx3, MAy3, MAx3+13, MAy3-9);
641 }
642 
643 
649 void MouseActions::MMoveOnGrid(Schematic *Doc, QMouseEvent *Event)
650 {
651  MAx3 = DOC_X_POS(Event->pos().x());
652  MAy3 = DOC_Y_POS(Event->pos().y());
653 
654  Doc->PostPaintEvent (_Line, MAx3+10, MAy3+ 3, MAx3+25, MAy3+3);
655  Doc->PostPaintEvent (_Line, MAx3+10, MAy3+ 7, MAx3+25, MAy3+7);
656  Doc->PostPaintEvent (_Line, MAx3+10, MAy3+11, MAx3+25, MAy3+11);
657  Doc->PostPaintEvent (_Line, MAx3+13, MAy3, MAx3+13, MAy3+15);
658  Doc->PostPaintEvent (_Line, MAx3+17, MAy3, MAx3+17, MAy3+15);
659  Doc->PostPaintEvent (_Line, MAx3+21, MAy3, MAx3+21, MAy3+15);
660 }
661 
662 
668 void MouseActions::MMoveMoveTextB(Schematic *Doc, QMouseEvent *Event)
669 {
670  MAx3 = DOC_X_POS(Event->pos().x());
671  MAy3 = DOC_Y_POS(Event->pos().y());
672 
673  Doc->PostPaintEvent (_Line, MAx3+14, MAy3 , MAx3+16, MAy3);
674  Doc->PostPaintEvent (_Line, MAx3+23, MAy3 , MAx3+25, MAy3);
675  Doc->PostPaintEvent (_Line, MAx3+13, MAy3 , MAx3+13, MAy3+ 3);
676  Doc->PostPaintEvent (_Line, MAx3+13, MAy3+ 7, MAx3+13, MAy3+10);
677  Doc->PostPaintEvent (_Line, MAx3+14, MAy3+10, MAx3+16, MAy3+10);
678  Doc->PostPaintEvent (_Line, MAx3+23, MAy3+10, MAx3+25, MAy3+10);
679  Doc->PostPaintEvent (_Line, MAx3+26, MAy3 , MAx3+26, MAy3+ 3);
680  Doc->PostPaintEvent (_Line, MAx3+26, MAy3+ 7, MAx3+26, MAy3+10);
681 }
682 
683 
689 void MouseActions::MMoveMoveText(Schematic *Doc, QMouseEvent *Event)
690 {
691  int newX = DOC_X_POS(Event->pos().x());
692  int newY = DOC_Y_POS(Event->pos().y());
693  MAx1 += newX - MAx3;
694  MAy1 += newY - MAy3;
695  MAx3 = newX;
696  MAy3 = newY;
697 
698  Doc->PostPaintEvent (_Rect, MAx1, MAy1, MAx2, MAy2);
699 }
700 
701 
707 void MouseActions::MMoveZoomIn(Schematic *Doc, QMouseEvent *Event)
708 {
709  MAx3 = DOC_X_POS(Event->pos().x());
710  MAy3 = DOC_Y_POS(Event->pos().y());
711 
712  Doc->PostPaintEvent (_Line, MAx3+14, MAy3 , MAx3+22, MAy3);
713  Doc->PostPaintEvent (_Line, MAx3+18, MAy3-4 , MAx3+18, MAy3+4);
714  Doc->PostPaintEvent (_Ellipse, MAx3+12, MAy3-6, 13, 13,0,0,false);
715  Doc->viewport()->update();
716 }
717 
718 
719 // ************************************************************************
720 // ********** **********
721 // ********** Functions for serving mouse button clicking **********
722 // ********** **********
723 // ************************************************************************
724 
725 // Is called from several MousePress functions to show right button menu.
726 void MouseActions::rightPressMenu(Schematic *Doc, QMouseEvent *Event, float fX, float fY)
727 {
728  MAx1 = int(fX);
729  MAy1 = int(fY);
730  focusElement = Doc->selectElement(fX, fY, false);
731 
732  if(focusElement) // remove special function (4 least significant bits)
734 
735 
736  // define menu
737  ComponentMenu->clear();
738  while(true) {
739  if(focusElement) {
740  focusElement->isSelected = true;
741  ComponentMenu->insertItem(
742  QObject::tr("Edit Properties"), QucsMain, SLOT(slotEditElement()));
743 
744  if((focusElement->Type & isComponent) == 0) break;
745  }
746  else {
747  QucsMain->symEdit->addTo(ComponentMenu);
749  }
750  if(!QucsMain->moveText->isOn())
752  break;
753  }
754  while(true) {
755  if(focusElement)
756  if(focusElement->Type == isGraph) break;
757  if(!QucsMain->onGrid->isOn())
758  QucsMain->onGrid->addTo(ComponentMenu);
760  if(!QucsMain->editPaste->isOn())
762  break;
763  }
764 
765  while (true) {
766  if (focusElement) {
767  if (focusElement->Type == isDiagram) {
768 
769  ComponentMenu->insertItem(QObject::tr("Export as image"), QucsMain,
770  SLOT(slotSaveDiagramToGraphicsFile()));
771  }
772  }
773  break;
774  }
775 
776  if(!QucsMain->editDelete->isOn())
778  if(focusElement) if(focusElement->Type == isMarker) {
779  ComponentMenu->insertSeparator();
780  QString s = QObject::tr("power matching");
781  if( ((Marker*)focusElement)->pGraph->Var == "Sopt" )
782  s = QObject::tr("noise matching");
783  ComponentMenu->insertItem(s, QucsMain, SLOT(slotPowerMatching()));
784  if( ((Marker*)focusElement)->pGraph->Var.left(2) == "S[" )
785  ComponentMenu->insertItem(QObject::tr("2-port matching"), QucsMain,
786  SLOT(slot2PortMatching()));
787  }
788  do {
789  if(focusElement) {
790  if(focusElement->Type == isDiagram) break;
791  if(focusElement->Type == isGraph) {
793  break;
794  }
795  }
796  ComponentMenu->insertSeparator();
798  if(!QucsMain->editActivate->isOn())
800  if(!QucsMain->editRotate->isOn())
802  if(!QucsMain->editMirror->isOn())
804  if(!QucsMain->editMirrorY->isOn())
806 
807  // right-click menu to go into hierarchy
808  if(focusElement) {
810  if(((Component*)focusElement)->Model == "Sub")
811  if(!QucsMain->intoH->isOn())
812  QucsMain->intoH->addTo(ComponentMenu);
813  }
814  // right-click menu to pop out of hierarchy
815  if(!focusElement)
816  if(!QucsMain->popH->isOn())
817  QucsMain->popH->addTo(ComponentMenu);
818  } while(false);
819 
820  *focusMEvent = *Event; // remember event for "edit component" action
821  ComponentMenu->popup(Event->globalPos());
822  Doc->viewport()->update();
823  drawn = false;
824 }
825 
826 // -----------------------------------------------------------
827 void MouseActions::MPressLabel(Schematic *Doc, QMouseEvent*, float fX, float fY)
828 {
829  int x = int(fX), y = int(fY);
830  Wire *pw = 0;
831  WireLabel *pl=0;
832  Node *pn = Doc->selectedNode(x, y);
833  if(!pn) {
834  pw = Doc->selectedWire(x, y);
835  if(!pw) return;
836  }
837 
838  QString Name, Value;
839  Element *pe=0;
840  // is wire line already labeled ?
841  if(pw) pe = Doc->getWireLabel(pw->Port1);
842  else pe = Doc->getWireLabel(pn);
843  if(pe) {
844  if(pe->Type & isComponent) {
845  QMessageBox::information(0, QObject::tr("Info"),
846  QObject::tr("The ground potential cannot be labeled!"));
847  return;
848  }
849  pl = ((Conductor*)pe)->Label;
850  }
851 
852  LabelDialog *Dia = new LabelDialog(pl, Doc);
853  if(Dia->exec() == 0) return;
854 
855  Name = Dia->NodeName->text();
856  Value = Dia->InitValue->text();
857  delete Dia;
858 
859  if(Name.isEmpty() && Value.isEmpty() ) { // if nothing entered, delete name
860  if(pe) {
861  if(((Conductor*)pe)->Label)
862  delete ((Conductor*)pe)->Label; // delete old name
863  ((Conductor*)pe)->Label = 0;
864  }
865  else {
866  if(pw) pw->setName("", ""); // delete name of wire
867  else pn->setName("", "");
868  }
869  }
870  else {
871 /* Name.replace(' ', '_'); // label must not contain spaces
872  while(Name.at(0) == '_') Name.remove(0,1); // must not start with '_'
873  if(Name.isEmpty()) return;
874 */
875  if(pe) {
876  if(((Conductor*)pe)->Label)
877  delete ((Conductor*)pe)->Label; // delete old name
878  ((Conductor*)pe)->Label = 0;
879  }
880 
881  int xl = x+30;
882  int yl = y-30;
883  Doc->setOnGrid(xl, yl);
884  // set new name
885  if(pw) pw->setName(Name, Value, x-pw->x1 + y-pw->y1, xl, yl);
886  else pn->setName(Name, Value, xl, yl);
887  }
888 
889  Doc->sizeOfAll(Doc->UsedX1, Doc->UsedY1, Doc->UsedX2, Doc->UsedY2);
890  Doc->viewport()->update();
891  drawn = false;
892  Doc->setChanged(true, true);
893 }
894 
895 // -----------------------------------------------------------
896 void MouseActions::MPressSelect(Schematic *Doc, QMouseEvent *Event, float fX, float fY)
897 {
898  bool Ctrl;
899  if(Event->state() & Qt::ControlModifier) Ctrl = true;
900  else Ctrl = false;
901 
902  int No=0;
903  MAx1 = int(fX);
904  MAy1 = int(fY);
905  focusElement = Doc->selectElement(fX, fY, Ctrl, &No);
906  isMoveEqual = false; // moving not neccessarily square
907 
908  if(focusElement)
909  // print define value in hex, see element.h
910  qDebug() << "MPressSelect: focusElement->Type" << QString("0x%1").arg(focusElement->Type, 0, 16);
911  else
912  qDebug() << "MPressSelect";
913 
914  if(focusElement)
915  switch(focusElement->Type)
916  {
917  case isPaintingResize: // resize painting ?
923  Doc->grabKeyboard(); // no keyboard inputs during move actions
924  // Update matching wire label highlighting
925  Doc->highlightWireLabels ();
926  return;
927 
928  case isDiagramResize: // resize diagram ?
929  if(((Diagram*)focusElement)->Name.left(4) != "Rect")
930  if(((Diagram*)focusElement)->Name.at(0) != 'T')
931  if(((Diagram*)focusElement)->Name != "Curve")
932  isMoveEqual = true; // diagram must be square
933 
935  MAx1 = focusElement->cx;
936  MAx2 = focusElement->x2;
937  if(((Diagram*)focusElement)->State & 1) {
938  MAx1 += MAx2;
939  MAx2 *= -1;
940  }
941  MAy1 = focusElement->cy;
942  MAy2 = -focusElement->y2;
943  if(((Diagram*)focusElement)->State & 2) {
944  MAy1 += MAy2;
945  MAy2 *= -1;
946  }
947 
952  Doc->grabKeyboard(); // no keyboard inputs during move actions
953  // Update matching wire label highlighting
954  Doc->highlightWireLabels ();
955  return;
956 
957  case isDiagramHScroll: // scroll in tabular ?
958  MAy1 = MAx1;
959 
960  case isDiagramVScroll:
962 
963  No = ((TabDiagram*)focusElement)->scroll(MAy1);
964 
965  switch(No)
966  {
967  case 1:
968  Doc->setChanged(true, true, 'm'); // 'm' = only the first time
969  break;
970  case 2: // move scroll bar with mouse cursor
974  Doc->grabKeyboard(); // no keyboard inputs during move actions
975 
976  // Remember inital scroll bar position.
977  MAx2 = int(((TabDiagram*)focusElement)->xAxis.limit_min);
978  // Update matching wire label highlighting
979  Doc->highlightWireLabels ();
980  return;
981  }
982  // Update matching wire label highlighting
983  Doc->highlightWireLabels ();
984  Doc->viewport()->update();
985  drawn = false;
986  return;
987 
988  case isComponentText: // property text of component ?
990 
991  MAx3 = No;
993  // Update matching wire label highlighting
994  Doc->highlightWireLabels ();
995  return;
996 
997  case isNode:
999  {
1000  MAx1 = 0; // paint wire corner first up, then left/right
1001  MAx3 = focusElement->cx; // works even if node is not on grid
1002  MAy3 = focusElement->cy;
1005  QucsMain->MouseReleaseAction = 0; // if function is called from elsewhere
1007 
1008  formerAction = QucsMain->select; // to restore action afterwards
1010 
1011  QucsMain->select->blockSignals(true);
1012  QucsMain->select->setOn(false);
1013  QucsMain->select->blockSignals(false);
1014 
1015  QucsMain->insWire->blockSignals(true);
1016  QucsMain->insWire->setOn(true);
1017  QucsMain->insWire->blockSignals(false);
1018  // Update matching wire label highlighting
1019  Doc->highlightWireLabels ();
1020  return;
1021  }
1022  }
1023 
1026  Doc->grabKeyboard(); // no keyboard inputs during move actions
1027  Doc->viewport()->update();
1028  drawn = false;
1029 
1030  if(focusElement == 0) {
1031  MAx2 = 0; // if not clicking on an element => open a rectangle
1032  MAy2 = 0;
1035  }
1036  else
1037  {
1038  // element could be moved
1039  if(!Ctrl)
1040  {
1041  if(!focusElement->isSelected)// Don't move selected elements if clicked
1042  Doc->deselectElements(focusElement); // element was not selected.
1043  focusElement->isSelected = true;
1044  }
1045  Doc->setOnGrid(MAx1, MAy1);
1047  }
1048  // Update matching wire label highlighting
1049  Doc->highlightWireLabels ();
1050 }
1051 
1052 // -----------------------------------------------------------
1053 void MouseActions::MPressDelete(Schematic *Doc, QMouseEvent*, float fX, float fY)
1054 {
1055  Element *pe = Doc->selectElement(fX, fY, false);
1056  if(pe)
1057  {
1058  pe->isSelected = true;
1059  Doc->deleteElements();
1060 
1061  Doc->sizeOfAll(Doc->UsedX1, Doc->UsedY1, Doc->UsedX2, Doc->UsedY2);
1062  Doc->viewport()->update();
1063  drawn = false;
1064  }
1065 }
1066 
1067 // -----------------------------------------------------------
1068 void MouseActions::MPressActivate(Schematic *Doc, QMouseEvent*, float fX, float fY)
1069 {
1070  MAx1 = int(fX);
1071  MAy1 = int(fY);
1072  if(!Doc->activateSpecifiedComponent(MAx1, MAy1)) {
1073 // if(Event->button() != Qt::LeftButton) return;
1074  MAx2 = 0; // if not clicking on a component => open a rectangle
1075  MAy2 = 0;
1079  }
1080  Doc->viewport()->update();
1081  drawn = false;
1082 }
1083 
1084 // -----------------------------------------------------------
1085 void MouseActions::MPressMirrorX(Schematic *Doc, QMouseEvent*, float fX, float fY)
1086 {
1087  // no use in mirroring wires or diagrams
1088  Component *c = Doc->selectedComponent(int(fX), int(fY));
1089  if(c) {
1090  if(c->Ports.count() < 1) return; // only mirror components with ports
1091  c->mirrorX();
1092  Doc->setCompPorts(c);
1093  }
1094  else {
1095  Painting *p = Doc->selectedPainting(fX, fY);
1096  if(p == 0) return;
1097  p->mirrorX();
1098  }
1099 
1100  Doc->viewport()->update();
1101  drawn = false;
1102  Doc->setChanged(true, true);
1103 }
1104 
1105 // -----------------------------------------------------------
1106 void MouseActions::MPressMirrorY(Schematic *Doc, QMouseEvent*, float fX, float fY)
1107 {
1108  // no use in mirroring wires or diagrams
1109  Component *c = Doc->selectedComponent(int(fX), int(fY));
1110  if(c) {
1111  if(c->Ports.count() < 1) return; // only mirror components with ports
1112  c->mirrorY();
1113  Doc->setCompPorts(c);
1114  }
1115  else {
1116  Painting *p = Doc->selectedPainting(fX, fY);
1117  if(p == 0) return;
1118  p->mirrorY();
1119  }
1120 
1121  Doc->viewport()->update();
1122  drawn = false;
1123  Doc->setChanged(true, true);
1124 }
1125 
1126 // -----------------------------------------------------------
1127 void MouseActions::MPressRotate(Schematic *Doc, QMouseEvent*, float fX, float fY)
1128 {
1129  Element *e = Doc->selectElement(int(fX), int(fY), false);
1130  if(e == 0) return;
1131  e->Type &= isSpecialMask; // remove special functions
1132 
1133 
1134  WireLabel *pl;
1135  int x1, y1, x2, y2;
1136 // e->isSelected = false;
1137  switch(e->Type) {
1138  case isComponent:
1139  case isAnalogComponent:
1140  case isDigitalComponent:
1141  if(((Component*)e)->Ports.count() < 1)
1142  break; // do not rotate components without ports
1143  ((Component*)e)->rotate();
1144  Doc->setCompPorts((Component*)e);
1145  // enlarge viewarea if component lies outside the view
1146  ((Component*)e)->entireBounds(x1,y1,x2,y2, Doc->textCorr());
1147  Doc->enlargeView(x1, y1, x2, y2);
1148  break;
1149 
1150  case isWire:
1151  pl = ((Wire*)e)->Label;
1152  ((Wire*)e)->Label = 0; // prevent label to be deleted
1153  Doc->Wires->setAutoDelete(false);
1154  Doc->deleteWire((Wire*)e);
1155  ((Wire*)e)->Label = pl;
1156  ((Wire*)e)->rotate();
1157  Doc->setOnGrid(e->x1, e->y1);
1158  Doc->setOnGrid(e->x2, e->y2);
1159  if(pl) Doc->setOnGrid(pl->cx, pl->cy);
1160  Doc->insertWire((Wire*)e);
1161  Doc->Wires->setAutoDelete(true);
1162  if (Doc->Wires->containsRef ((Wire*)e))
1163  Doc->enlargeView(e->x1, e->y1, e->x2, e->y2);
1164  break;
1165 
1166  case isPainting:
1167  ((Painting*)e)->rotate();
1168  // enlarge viewarea if component lies outside the view
1169  ((Painting*)e)->Bounding(x1,y1,x2,y2);
1170  Doc->enlargeView(x1, y1, x2, y2);
1171  break;
1172 
1173  default:
1174  return;
1175  }
1176  Doc->viewport()->update();
1177  drawn = false;
1178  Doc->setChanged(true, true);
1179 }
1180 
1181 // -----------------------------------------------------------
1182 // insert component, diagram, painting into schematic ?!
1183 void MouseActions::MPressElement(Schematic *Doc, QMouseEvent *Event, float, float)
1184 {
1185  if(selElem == 0) return;
1186  //QPainter painter(Doc->viewport());
1187  //setPainter(Doc, &painter);
1188 
1189 
1190  int x1, y1, x2, y2, rot;
1191  if(selElem->Type & isComponent) {
1192  Component *Comp = (Component*)selElem;
1193 // qDebug() << "+-+ got to switch:" << Comp->Name;
1194  QString entryName = Comp->Name;
1195 
1196  switch(Event->button()) {
1197  case Qt::LeftButton :
1198  // left mouse button inserts component into the schematic
1199  // give the component a pointer to the schematic it's a
1200  // part of
1201  Comp->setSchematic (Doc);
1202  Comp->textSize(x1, y1);
1203  Doc->insertComponent(Comp);
1204  Comp->textSize(x2, y2);
1205  if(Comp->tx < Comp->x1) Comp->tx -= x2 - x1;
1206 
1207  // Note: insertCopmponents does increment name1 -> name2
1208 // qDebug() << " +-+ got to insert:" << Comp->Name;
1209 
1210  // enlarge viewarea if component lies outside the view
1211  Comp->entireBounds(x1,y1,x2,y2, Doc->textCorr());
1212  Doc->enlargeView(x1, y1, x2, y2);
1213 
1214  drawn = false;
1215  Doc->viewport()->update();
1216  Doc->setChanged(true, true);
1217  rot = Comp->rotated;
1218 
1219  // handle static and dynamic components
1220 // QucsApp::CompChoose;
1221  if (Module::vaComponents.contains(entryName)){
1222  QString filename = Module::vaComponents[entryName];
1223 // qDebug() << " ===+ recast";
1224  Comp = dynamic_cast<vacomponent*>(Comp)->newOne(filename); //va component
1225  qDebug() << " => recast = Comp;" << Comp->Name << "filename: " << filename;
1226  }
1227  else {
1228  Comp = Comp->newOne(); // static component is used, so create a new one
1229  }
1230  rot -= Comp->rotated;
1231  rot &= 3;
1232  while(rot--) Comp->rotate(); // keep last rotation for single component
1233  break;
1234 
1235  case Qt::RightButton : // right mouse button rotates the component
1236  if(Comp->Ports.count() == 0)
1237  break; // do not rotate components without ports
1238  Comp->paintScheme(Doc); // erase old component scheme
1239  Comp->rotate();
1240  Comp->paintScheme(Doc); // paint new component scheme
1241  break;
1242 
1243  default: ; // avoids compiler warnings
1244  }
1245 // qDebug() << " => selElem = Comp;" << Comp->Name;
1246  // comp it geting empty
1247  selElem = Comp;
1248  return;
1249 
1250  } // of "if(isComponent)"
1251  else if(selElem->Type == isDiagram) {
1252  if(Event->button() != Qt::LeftButton) return;
1253 
1254  Diagram *Diag = (Diagram*)selElem;
1255  QFileInfo Info(Doc->DocName);
1256  // dialog is Qt::WDestructiveClose !!!
1257  DiagramDialog *dia =
1258  new DiagramDialog(Diag,
1259  Info.dirPath() + QDir::separator() + Doc->DataSet, Doc);
1260  if(dia->exec() == QDialog::Rejected) { // don't insert if dialog canceled
1261  Doc->viewport()->update();
1262  drawn = false;
1263  return;
1264  }
1265 
1266  Doc->Diagrams->append(Diag);
1267  Doc->enlargeView(Diag->cx, Diag->cy-Diag->y2, Diag->cx+Diag->x2, Diag->cy);
1268  Doc->setChanged(true, true); // document has been changed
1269 
1270  Doc->viewport()->repaint();
1271  Diag = Diag->newOne(); // the component is used, so create a new one
1272  Diag->paintScheme(Doc);
1273  selElem = Diag;
1274  return;
1275  } // of "if(isDiagram)"
1276 
1277 
1278  // *********** it is a painting !!!
1279  if(((Painting*)selElem)->MousePressing()) {
1280  Doc->Paintings->append((Painting*)selElem);
1281  ((Painting*)selElem)->Bounding(x1,y1,x2,y2);
1282  //Doc->enlargeView(x1, y1, x2, y2);
1283  selElem = ((Painting*)selElem)->newOne();
1284 
1285  Doc->viewport()->update();
1286  Doc->setChanged(true, true);
1287 
1288  MMoveElement(Doc, Event); // needed before next mouse pressing
1289  drawn = false;
1290  }
1291 }
1292 
1293 
1300 void MouseActions::MPressWire1(Schematic *Doc, QMouseEvent*, float fX, float fY)
1301 {
1302  //Doc->PostPaintEvent (_DotLine);
1303  //Doc->PostPaintEvent (_NotRop);
1304  //if(drawn) {
1305  Doc->PostPaintEvent (_Line, 0, MAy3, MAx2, MAy3); // erase old mouse cross
1306  Doc->PostPaintEvent (_Line, MAx3, 0, MAx3, MAy2);
1307  //}
1308  //drawn = false;
1309 
1310  MAx1 = 0; // paint wire corner first up, then left/right
1311  MAx3 = int(fX);
1312  MAy3 = int(fY);
1313  Doc->setOnGrid(MAx3, MAy3);
1314 
1315  formerAction = 0; // keep wire action active after first wire finished
1318  // Double-click action is set in "MMoveWire2" to not initiate it
1319  // during "Wire1" actions.
1320  Doc->viewport()->update();
1321 }
1322 
1323 
1331 void MouseActions::MPressWire2(Schematic *Doc, QMouseEvent *Event, float fX, float fY)
1332 {
1333 
1334  int set1 = 0, set2 = 0;
1335  switch(Event->button()) {
1336  case Qt::LeftButton :
1337  if(MAx1 == 0) { // which wire direction first ?
1338  if(MAy2 != MAy3)
1339  set1 = Doc->insertWire(new Wire(MAx3, MAy3, MAx3, MAy2));
1340  if(MAx2 != MAx3) {
1341  set2 = set1;
1342  set1 = Doc->insertWire(new Wire(MAx3, MAy2, MAx2, MAy2));
1343  }
1344  }
1345  else {
1346  if(MAx2 != MAx3)
1347  set1 = Doc->insertWire(new Wire(MAx3, MAy3, MAx2, MAy3));
1348  if(MAy2 != MAy3) {
1349  set2 = set1;
1350  set1 = Doc->insertWire(new Wire(MAx2, MAy3, MAx2, MAy2));
1351  }
1352  }
1353 
1354  if(set1 & 2) {
1355  // if last port is connected, then...
1356  if(formerAction) {
1357  // ...restore old action
1358  QucsMain->select->setOn(true);
1359  }
1360  else {
1361  // ...start a new wire
1365  }
1366  }
1367 
1368  Doc->viewport()->update();
1369  drawn = false;
1370  if(set1 | set2) Doc->setChanged(true, true);
1371  MAx3 = MAx2;
1372  MAy3 = MAy2;
1373  break;
1374 
1376  case Qt::RightButton :
1377  if(MAx1 == 0) {
1378  Doc->PostPaintEvent (_Line, MAx3, MAy3, MAx3, MAy2); // erase old
1379  Doc->PostPaintEvent (_Line, MAx3, MAy2, MAx2, MAy2); // erase old
1380  }
1381  else {
1382  Doc->PostPaintEvent (_Line, MAx3, MAy3, MAx2, MAy3); // erase old
1383  Doc->PostPaintEvent (_Line, MAx2, MAy3, MAx2, MAy2); // erase old
1384  }
1385 
1386  MAx2 = int(fX);
1387  MAy2 = int(fY);
1388  Doc->setOnGrid(MAx2, MAy2);
1389 
1390  MAx1 ^= 1; // change the painting direction of wire corner
1391  if(MAx1 == 0) {
1392  Doc->PostPaintEvent (_Line, MAx3, MAy3, MAx3, MAy2); // paint
1393  Doc->PostPaintEvent (_Line, MAx3, MAy2, MAx2, MAy2); // paint
1394  }
1395  else {
1396  Doc->PostPaintEvent (_Line, MAx3, MAy3, MAx2, MAy3); // paint
1397  Doc->PostPaintEvent (_Line, MAx2, MAy3, MAx2, MAy2); // paint
1398  }
1399  break;
1400 
1401  default: ; // avoids compiler warnings
1402  }
1403  Doc->viewport()->update();
1404 }
1405 
1406 // -----------------------------------------------------------
1407 // Is called for setting a marker on a diagram's graph
1408 void MouseActions::MPressMarker(Schematic *Doc, QMouseEvent*, float fX, float fY)
1409 {
1410  MAx1 = int(fX);
1411  MAy1 = int(fY);
1412  Marker *pm = Doc->setMarker(MAx1, MAy1);
1413 
1414  if(pm) {
1415  int x0 = pm->Diag->cx;
1416  int y0 = pm->Diag->cy;
1417  Doc->enlargeView(x0+pm->x1, y0-pm->y1-pm->y2, x0+pm->x1+pm->x2, y0-pm->y1);
1418  }
1419  Doc->viewport()->update();
1420  drawn = false;
1421 }
1422 
1423 // -----------------------------------------------------------
1424 void MouseActions::MPressOnGrid(Schematic *Doc, QMouseEvent*, float fX, float fY)
1425 {
1426  Element *pe = Doc->selectElement(fX, fY, false);
1427  if(pe)
1428  {
1429  pe->Type &= isSpecialMask; // remove special functions (4 lowest bits)
1430 
1431  // onGrid is toggle action -> no other element can be selected
1432  pe->isSelected = true;
1433  Doc->elementsOnGrid();
1434 
1435  Doc->sizeOfAll(Doc->UsedX1, Doc->UsedY1, Doc->UsedX2, Doc->UsedY2);
1436  // Update matching wire label highlighting
1437  Doc->highlightWireLabels ();
1438  Doc->viewport()->update();
1439  drawn = false;
1440  }
1441 
1442 }
1443 
1444 // -----------------------------------------------------------
1445 void MouseActions::MPressMoveText(Schematic *Doc, QMouseEvent*, float fX, float fY)
1446 {
1447  MAx1 = int(fX);
1448  MAy1 = int(fY);
1450 
1451  if(focusElement) {
1452  MAx3 = MAx1;
1453  MAy3 = MAy1;
1454  MAx1 = ((Component*)focusElement)->cx + ((Component*)focusElement)->tx;
1455  MAy1 = ((Component*)focusElement)->cy + ((Component*)focusElement)->ty;
1456  Doc->viewport()->update();
1457  drawn = false;
1460  Doc->grabKeyboard(); // no keyboard inputs during move actions
1461  }
1462 }
1463 
1464 // -----------------------------------------------------------
1465 void MouseActions::MPressZoomIn(Schematic *Doc, QMouseEvent*, float fX, float fY)
1466 {
1467  qDebug() << "zoom into box";
1469  MAx1 = int(fX);
1470  MAy1 = int(fY);
1471  MAx2 = 0; // rectangle size
1472  MAy2 = 0;
1473 
1476  Doc->grabKeyboard(); // no keyboard inputs during move actions
1477  Doc->viewport()->update();
1478  drawn = false;
1479 }
1480 
1481 
1482 // ***********************************************************************
1483 // ********** **********
1484 // ********** Functions for serving mouse button releasing **********
1485 // ********** **********
1486 // ***********************************************************************
1487 void MouseActions::MReleaseSelect(Schematic *Doc, QMouseEvent *Event)
1488 {
1489  bool ctrl;
1490  if(Event->state() & Qt::ControlModifier) ctrl = true;
1491  else ctrl = false;
1492 
1493  if(!ctrl) Doc->deselectElements(focusElement);
1494 
1495  if(focusElement) if(Event->button() == Qt::LeftButton)
1496  if(focusElement->Type == isWire) {
1497  Doc->selectWireLine(focusElement, ((Wire*)focusElement)->Port1, ctrl);
1498  Doc->selectWireLine(focusElement, ((Wire*)focusElement)->Port2, ctrl);
1499  }
1500 
1501  Doc->releaseKeyboard(); // allow keyboard inputs again
1505  QucsMain->MouseMoveAction = 0; // no element moving
1506  Doc->highlightWireLabels ();
1507  Doc->viewport()->update();
1508  drawn = false;
1509 }
1510 
1511 // -----------------------------------------------------------
1512 // Is called after the rectangle for selection is released.
1513 void MouseActions::MReleaseSelect2(Schematic *Doc, QMouseEvent *Event)
1514 {
1515  if(Event->button() != Qt::LeftButton) return;
1516 
1517  bool Ctrl;
1518  if(Event->state() & Qt::ControlModifier) Ctrl = true;
1519  else Ctrl = false;
1520 
1521  // selects all elements within the rectangle
1522  Doc->selectElements(MAx1, MAy1, MAx1+MAx2, MAy1+MAy2, Ctrl);
1523 
1524  Doc->releaseKeyboard(); // allow keyboard inputs again
1529  Doc->highlightWireLabels ();
1530  Doc->viewport()->update();
1531  drawn = false;
1532 }
1533 
1534 // -----------------------------------------------------------
1535 void MouseActions::MReleaseActivate(Schematic *Doc, QMouseEvent *Event)
1536 {
1537  if(Event->button() != Qt::LeftButton) return;
1538 
1539  // activates all components within the rectangle
1541 
1546  Doc->highlightWireLabels ();
1547  Doc->viewport()->update();
1548  drawn = false;
1549 }
1550 
1551 // -----------------------------------------------------------
1552 // Is called after moving selected elements.
1553 void MouseActions::MReleaseMoving(Schematic *Doc, QMouseEvent*)
1554 {
1555  // Allow all mouse buttons, because for others than the left one,
1556  // a menu has already created.
1558  Doc->releaseKeyboard(); // allow keyboard inputs again
1559 
1564 }
1565 
1566 // -----------------------------------------------------------
1567 void MouseActions::MReleaseResizeDiagram(Schematic *Doc, QMouseEvent *Event)
1568 {
1569  if(Event->button() != Qt::LeftButton) return;
1570 
1571  MAx3 = focusElement->cx;
1572  MAy3 = focusElement->cy;
1573  if(MAx2 < 0) { // resize diagram
1574  if(MAx2 > -10) MAx2 = -10; // not smaller than 10 pixels
1575  focusElement->x2 = -MAx2;
1576  focusElement->cx = MAx1+MAx2;
1577  }
1578  else {
1579  if(MAx2 < 10) MAx2 = 10;
1580  focusElement->x2 = MAx2;
1581  focusElement->cx = MAx1;
1582  }
1583  if(MAy2 < 0) {
1584  if(MAy2 > -10) MAy2 = -10;
1585  focusElement->y2 = -MAy2;
1586  focusElement->cy = MAy1;
1587  }
1588  else {
1589  if(MAy2 < 10) MAy2 = 10;
1590  focusElement->y2 = MAy2;
1591  focusElement->cy = MAy1+MAy2;
1592  }
1593  MAx3 -= focusElement->cx;
1594  MAy3 -= focusElement->cy;
1595 
1596  Diagram *pd = (Diagram*)focusElement;
1597  pd->updateGraphData();
1598  for(Graph *pg = pd->Graphs.first(); pg != 0; pg = pd->Graphs.next())
1599  for(Marker *pm = pg->Markers.first(); pm!=0; pm = pg->Markers.next()) {
1600  pm->x1 += MAx3; // correct changes due to move of diagram corner
1601  pm->y1 += MAy3;
1602  }
1603 
1604  int x1, x2, y1, y2;
1605  pd->Bounding(x1, x2, y1, y2);
1606  Doc->enlargeView(x1, x2, y1, y2);
1607 
1612  Doc->releaseKeyboard(); // allow keyboard inputs again
1613 
1614  Doc->viewport()->update();
1615  drawn = false;
1616  Doc->setChanged(true, true);
1617 }
1618 
1619 // -----------------------------------------------------------
1620 void MouseActions::MReleaseResizePainting(Schematic *Doc, QMouseEvent *Event)
1621 {
1622  if(Event->button() != Qt::LeftButton) return;
1623 
1628  Doc->releaseKeyboard(); // allow keyboard inputs again
1629 
1630  Doc->viewport()->update();
1631  drawn = false;
1632  Doc->setChanged(true, true);
1633 }
1634 
1635 // -----------------------------------------------------------
1637 {
1638  Element *pe;
1639  for(pe = movingElements.first(); pe != 0; pe = movingElements.next())
1640  pe->paintScheme(p);
1641 }
1642 
1643 // -----------------------------------------------------------
1644 void MouseActions::moveElements(Schematic *Doc, int& x1, int& y1)
1645 {
1646  Element *pe;
1647  Doc->setOnGrid(x1, y1);
1648 
1649  for(pe=movingElements.first(); pe!=0; pe=movingElements.next()) {
1650  if(pe->Type & isLabel) {
1651  pe->cx += x1; pe->x1 += x1;
1652  pe->cy += y1; pe->y1 += y1;
1653  }
1654  else
1655  pe->setCenter(x1, y1, true);
1656  }
1657 }
1658 
1659 // -----------------------------------------------------------
1660 void MouseActions::rotateElements(Schematic *Doc, int& x1, int& y1)
1661 {
1662  int x2, y2;
1663  Element *pe;
1664  Doc->setOnGrid(x1, y1);
1665 
1666  for(pe = movingElements.first(); pe != 0; pe = movingElements.next()) {
1667  switch(pe->Type) {
1668  case isComponent:
1669  case isAnalogComponent:
1670  case isDigitalComponent:
1671  ((Component*)pe)->rotate(); // rotate !before! rotating the center
1672  x2 = x1 - pe->cx;
1673  pe->setCenter(pe->cy - y1 + x1, x2 + y1);
1674  break;
1675  case isWire:
1676  x2 = pe->x1;
1677  pe->x1 = pe->y1 - y1 + x1;
1678  pe->y1 = x1 - x2 + y1;
1679  x2 = pe->x2;
1680  pe->x2 = pe->y2 - y1 + x1;
1681  pe->y2 = x1 - x2 + y1;
1682  break;
1683  case isPainting:
1684  ((Painting*)pe)->rotate(); // rotate !before! rotating the center
1685  ((Painting*)pe)->getCenter(x2, y2);
1686  pe->setCenter(y2 - y1 + x1, x1 - x2 + y1);
1687  break;
1688  default:
1689  x2 = x1 - pe->cx; // if diagram -> only rotate cx/cy
1690  pe->setCenter(pe->cy - y1 + x1, x2 + y1);
1691  break;
1692  }
1693  }
1694 }
1695 
1696 // -----------------------------------------------------------
1697 void MouseActions::MReleasePaste(Schematic *Doc, QMouseEvent *Event)
1698 {
1699  int x1, y1, x2, y2, rot;
1700  QFileInfo Info(Doc->DocName);
1701  //QPainter painter(Doc->viewport());
1702 
1703  Element *pe;
1704  switch(Event->button()) {
1705  case Qt::LeftButton :
1706  // insert all moved elements into document
1707  for(pe = movingElements.first(); pe!=0; pe = movingElements.next()) {
1708  pe->isSelected = false;
1709  switch(pe->Type) {
1710  case isWire:
1711  if(pe->x1 == pe->x2) if(pe->y1 == pe->y2) break;
1712  Doc->insertWire((Wire*)pe);
1713  if (Doc->Wires->containsRef ((Wire*)pe))
1714  Doc->enlargeView(pe->x1, pe->y1, pe->x2, pe->y2);
1715  else pe = NULL;
1716  break;
1717  case isDiagram:
1718  Doc->Diagrams->append((Diagram*)pe);
1719  ((Diagram*)pe)->loadGraphData(Info.dirPath() + QDir::separator() +
1720  Doc->DataSet);
1721  Doc->enlargeView(pe->cx, pe->cy-pe->y2, pe->cx+pe->x2, pe->cy);
1722  break;
1723  case isPainting:
1724  Doc->Paintings->append((Painting*)pe);
1725  ((Painting*)pe)->Bounding(x1,y1,x2,y2);
1726  Doc->enlargeView(x1, y1, x2, y2);
1727  break;
1728  case isMovingLabel:
1729  pe->Type = isNodeLabel;
1730  Doc->placeNodeLabel((WireLabel*)pe);
1731  break;
1732  case isComponent:
1733  case isAnalogComponent:
1734  case isDigitalComponent:
1735  Doc->insertComponent((Component*)pe);
1736  ((Component*)pe)->entireBounds(x1,y1,x2,y2, Doc->textCorr());
1737  Doc->enlargeView(x1, y1, x2, y2);
1738  break;
1739  }
1740  }
1741 
1742  pasteElements(Doc);
1743  // keep rotation sticky for pasted elements
1744  rot = movingRotated;
1745  x1 = y1 = 0;
1746  while(rot--) rotateElements(Doc,x1,y1);
1747 
1752 
1753  drawn = false;
1754  Doc->viewport()->update();
1755  Doc->setChanged(true, true);
1756  break;
1757 
1758  // ............................................................
1759  case Qt::RightButton : // right button rotates the elements
1760  //setPainter(Doc, &painter);
1761 
1762  if(drawn) // erase old scheme
1763  paintElementsScheme(Doc);
1764  drawn = true;
1765 
1766  x1 = DOC_X_POS(Event->pos().x());
1767  y1 = DOC_Y_POS(Event->pos().y());
1768  rotateElements(Doc,x1,y1);
1769  paintElementsScheme(Doc);
1770  // save rotation
1771  movingRotated++;
1772  movingRotated &= 3;
1773  break;
1774 
1775  default: ; // avoids compiler warnings
1776  }
1777 }
1778 
1779 // -----------------------------------------------------------
1780 void MouseActions::MReleaseMoveText(Schematic *Doc, QMouseEvent *Event)
1781 {
1782  if(Event->button() != Qt::LeftButton) return;
1783 
1786  Doc->releaseKeyboard(); // allow keyboard inputs again
1787 
1788  ((Component*)focusElement)->tx = MAx1 - ((Component*)focusElement)->cx;
1789  ((Component*)focusElement)->ty = MAy1 - ((Component*)focusElement)->cy;
1790  Doc->viewport()->update();
1791  drawn = false;
1792  Doc->setChanged(true, true);
1793 }
1794 
1795 // -----------------------------------------------------------
1796 void MouseActions::MReleaseZoomIn(Schematic *Doc, QMouseEvent *Event)
1797 {
1798  if(Event->button() != Qt::LeftButton) return;
1799 
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) {
1805  DX = 1.5; // a simple click zooms by constant factor
1806  Doc->zoom(DX);
1807 
1808  DX -= 1.0;
1809  MAx1 = int(DX * float(Event->pos().x()));
1810  MAy1 = int(DX * float(Event->pos().y()));
1811  }
1812  else {
1813  float xScale = float(Doc->visibleWidth()) / DX;
1814  float yScale = float(Doc->visibleHeight()) / DY;
1815  if(xScale > yScale) xScale = yScale;
1816  yScale = Doc->Scale;
1817  xScale /= yScale;
1818  Doc->zoom(xScale);
1819 
1820  if(MAx2 > 0) MAx1 -= int(float(MAx2)*yScale);
1821  if(MAy2 > 0) MAy1 -= int(float(MAy2)*yScale);
1822  MAx1 = int(float(MAx1) * xScale) - Doc->contentsX();
1823  MAy1 = int(float(MAy1) * xScale) - Doc->contentsY();
1824  }
1825  Doc->scrollBy(MAx1, MAy1);
1826 
1829  Doc->releaseKeyboard(); // allow keyboard inputs again
1830 }
1831 
1832 
1833 // ***********************************************************************
1834 // ********** **********
1835 // ********** Functions for mouse button double clicking **********
1836 // ********** **********
1837 // ***********************************************************************
1838 void MouseActions::editElement(Schematic *Doc, QMouseEvent *Event)
1839 {
1840 // qDebug() << "+double click, editElement";
1841 
1842  if(focusElement == 0) return;
1843 
1844 // qDebug() << "+focusElement->Type" << focusElement->Type;
1845 
1846  Graph *pg;
1847  Component *c;
1848  Diagram *dia;
1849  DiagramDialog *ddia;
1850  MarkerDialog *mdia;
1851  int x1, y1, x2, y2;
1852 
1853  QFileInfo Info(Doc->DocName);
1854  float fX = DOC_X_FPOS, fY = DOC_Y_FPOS;
1855 
1856  switch(focusElement->Type) {
1857  case isComponent:
1858  case isAnalogComponent:
1859  case isDigitalComponent:
1860  c = (Component*)focusElement;
1861 // qDebug() << "cast focusElement into" << c->Name;
1862  if(c->Model == "GND") return;
1863 
1864  if(c->Model == "SPICE") {
1865  SpiceDialog *sd = new SpiceDialog(App, (SpiceFile*)c, Doc);
1866  if(sd->exec() != 1) break; // dialog is WDestructiveClose
1867  }
1868  else if(c->Model == ".Opt") {
1869  OptimizeDialog *od = new OptimizeDialog((Optimize_Sim*)c, Doc);
1870  if(od->exec() != 1) break; // dialog is WDestructiveClose
1871  }
1872  else {
1873  ComponentDialog * cd = new ComponentDialog(c, Doc);
1874  if(cd->exec() != 1) break; // dialog is WDestructiveClose
1875 
1876  Doc->Components->findRef(c);
1877  Doc->Components->take();
1878  Doc->setComponentNumber(c); // for ports/power sources
1879  Doc->Components->append(c);
1880  }
1881 
1882  Doc->setChanged(true, true);
1883  c->entireBounds(x1,y1,x2,y2, Doc->textCorr());
1884  Doc->enlargeView(x1,y1,x2,y2);
1885  break;
1886 
1887  case isDiagram :
1888  dia = (Diagram*)focusElement;
1889  if(dia->Name.at(0) == 'T') { // don't open dialog on scrollbar
1890  if(dia->Name == "Time") {
1891  if(dia->cy < int(fY)) {
1892  if(((TimingDiagram*)focusElement)->scroll(MAx1))
1893  Doc->setChanged(true, true, 'm'); // 'm' = only the first time
1894  break;
1895  }
1896  }
1897  else {
1898  if(dia->cx > int(fX)) {
1899  if(((TabDiagram*)focusElement)->scroll(MAy1))
1900  Doc->setChanged(true, true, 'm'); // 'm' = only the first time
1901  break;
1902  }
1903  }
1904  }
1905 
1906  ddia = new DiagramDialog(dia,
1907  Info.dirPath() + QDir::separator() + Doc->DataSet, Doc);
1908  if(ddia->exec() != QDialog::Rejected) // is WDestructiveClose
1909  Doc->setChanged(true, true);
1910 
1911  dia->Bounding(x1, x2, y1, y2);
1912  Doc->enlargeView(x1, x2, y1, y2);
1913  break;
1914 
1915  case isGraph :
1916  pg = (Graph*)focusElement;
1917  // searching diagram for this graph
1918  for(dia = Doc->Diagrams->last(); dia != 0; dia = Doc->Diagrams->prev())
1919  if(dia->Graphs.findRef(pg) >= 0)
1920  break;
1921  if(!dia) break;
1922 
1923 
1924  ddia = new DiagramDialog(dia,
1925  Info.dirPath() + QDir::separator() + Doc->DataSet, Doc, pg);
1926  if(ddia->exec() != QDialog::Rejected) // is WDestructiveClose
1927  Doc->setChanged(true, true);
1928  break;
1929 
1930  case isWire:
1931  MPressLabel(Doc, Event, fX, fY);
1932  break;
1933 
1934  case isNodeLabel:
1935  case isHWireLabel:
1936  case isVWireLabel:
1938  break;
1939 
1940  case isPainting:
1941  if( ((Painting*)focusElement)->Dialog() )
1942  Doc->setChanged(true, true);
1943  break;
1944 
1945  case isMarker:
1946  mdia = new MarkerDialog((Marker*)focusElement, Doc);
1947  if(mdia->exec() > 1)
1948  Doc->setChanged(true, true);
1949  break;
1950  }
1951 
1952  // Very strange: Now an open VHDL editor gets all the keyboard input !?!
1953  // I don't know why it only happens here, nor am I sure whether it only
1954  // happens here. Anyway, I hope the best and give the focus back to the
1955  // current document.
1956  Doc->setFocus();
1957 
1958  Doc->viewport()->update();
1959  drawn = false;
1960 }
1961 
1962 // -----------------------------------------------------------
1963 void MouseActions::MDoubleClickSelect(Schematic *Doc, QMouseEvent *Event)
1964 {
1965  Doc->releaseKeyboard(); // allow keyboard inputs again
1966  QucsMain->editText->setHidden(true);
1967  editElement(Doc, Event);
1968 }
1969 
1970 
1976 void MouseActions::MDoubleClickWire2(Schematic *Doc, QMouseEvent *Event)
1977 {
1978  MPressWire2(Doc, Event, DOC_X_FPOS, DOC_Y_FPOS);
1979 
1980  if(formerAction)
1981  QucsMain->select->setOn(true); // restore old action
1982  else {
1986  }
1987 }
virtual Component * newOne()
Definition: component.cpp:70
void MPressElement(Schematic *, QMouseEvent *, float, float)
void MMoveLabel(Schematic *, QMouseEvent *)
MouseActions::MMoveLabel Paints a label above the mouse cursor for "set wire label".
bool isMoveEqual
Definition: mouseactions.h:62
void rotateElements(Schematic *, int &, int &)
int Type
Definition: element.h:152
void MMoveMoving2(Schematic *, QMouseEvent *)
void MMoveMoving(Schematic *, QMouseEvent *)
void MMoveActivate(Schematic *, QMouseEvent *)
MouseActions::MMoveActivate Paints a crossed box mouse cursor to "(de)activate" components.
float textCorr()
Definition: schematic.cpp:922
#define isSpecialMask
Definition: element.h:108
void setName(const QString &, const QString &, int x_=0, int y_=0)
Definition: node.cpp:71
virtual ~MouseActions()
Definition: node.h:30
int y1
Definition: element.h:153
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)
Definition: schematic.cpp:533
void MReleaseSelect2(Schematic *, QMouseEvent *)
Definition: wire.h:31
label for Node and Wire classes
Definition: element.h:161
void(MouseActions::* MouseMoveAction)(Schematic *, QMouseEvent *)
Definition: qucs.h:85
void MMoveMirrorY(Schematic *, QMouseEvent *)
MouseActions::MMoveMirrorX Paints rounded "mirror about y axis" mouse cursor.
#define isNodeLabel
Definition: element.h:126
void MMoveElement(Schematic *, QMouseEvent *)
float Scale
Definition: qucsdoc.h:58
Definition: graph.h:57
void editElement(Schematic *, QMouseEvent *)
void rotate()
#define isDiagram
Definition: element.h:131
QString Name
Definition: diagram.h:92
Node * selectedNode(int, int)
void setName(const QString &Name_)
Definition: wirelabel.cpp:196
tQucsSettings QucsSettings
Definition: main.cpp:52
void MMoveMirrorX(Schematic *, QMouseEvent *)
MouseActions::MMoveMirrorX Paints rounded "mirror about x axis" mouse cursor.
#define DOC_X_FPOS
void(MouseActions::* MousePressAction)(Schematic *, QMouseEvent *, float, float)
Definition: qucs.h:86
void MPressActivate(Schematic *, QMouseEvent *, float, float)
void MMoveOnGrid(Schematic *, QMouseEvent *)
MouseActions::MMoveOnGrid Paints a grid beside the mouse cursor, put "on grid" mode.
int tx
Definition: component.h:78
int selectElements(int, int, int, int, bool)
void MMoveMoveTextB(Schematic *, QMouseEvent *)
MouseActions::MMoveMoveTextB Paints mouse symbol for "move component text" mode.
int y2
Definition: element.h:153
Definition: marker.h:31
int x1
Definition: element.h:153
void MPressLabel(Schematic *, QMouseEvent *, float, float)
bool paste(QTextStream *, Q3PtrList< Element > *)
Definition: schematic.cpp:1274
void MPressMirrorX(Schematic *, QMouseEvent *, float, float)
int insertWire(Wire *)
Q3PopupMenu * ComponentMenu
Definition: mouseactions.h:59
void setOnGrid(int &, int &)
Definition: schematic.cpp:858
int textSize(int &, int &)
Definition: component.cpp:86
void MMoveRotate(Schematic *, QMouseEvent *)
MouseActions::MMoveMirrorX Paints "rotate" mouse cursor.
void MReleaseMoveText(Schematic *, QMouseEvent *)
void endElementMoving(Schematic *, Q3PtrList< Element > *)
Element * focusElement
Definition: mouseactions.h:51
void deleteWire(Wire *)
void MPressDelete(Schematic *, QMouseEvent *, float, float)
void MPressMarker(Schematic *, QMouseEvent *, float, float)
void mirrorX()
Definition: component.cpp:490
Q3PtrList< Element > movingElements
Definition: mouseactions.h:55
void mirrorY()
Definition: component.cpp:552
Definition: schematic.h:55
void MMoveResizePainting(Schematic *, QMouseEvent *)
#define DOC_Y_POS(y)
void insertRawComponent(Component *, bool noOptimize=true)
Painting * selectedPainting(float, float)
QLineEdit * editText
Definition: qucs.h:81
#define isDigitalComponent
Definition: element.h:113
void enlargeView(int, int, int, int)
Definition: schematic.cpp:832
float zoom(float)
Definition: schematic.cpp:745
Q3PtrList< Diagram > * Diagrams
Definition: schematic.h:121
int ViewY1
Definition: schematic.h:132
QAction * editRotate
Definition: qucs.h:292
void MMoveScrollBar(Schematic *, QMouseEvent *)
Definitions and declarations for the main application.
QAction * insWire
Definition: qucs.h:292
MouseActions(QucsApp *)
void MPressWire1(Schematic *, QMouseEvent *, float, float)
MouseActions::MPressWire1 Is called if starting point of wire is pressed.
QucsApp * QucsMain
Definition: main.cpp:54
QAction * editDelete
Definition: qucs.h:292
int cx
Definition: element.h:153
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)
Definition: component.cpp:109
void setPainter(Schematic *)
int rotated
Definition: component.h:61
int copySelectedElements(Q3PtrList< Element > *)
QucsApp * App
Definition: mouseactions.h:63
#define isPaintingResize
Definition: element.h:121
Q3PtrList< Component > * Components
Definition: schematic.h:123
Element * selectElement(float, float, bool, int *index=0)
void MReleaseSelect(Schematic *, QMouseEvent *)
#define DOC_Y_FPOS
virtual void mirrorX()
Definition: painting.h:49
void MMoveMarker(Schematic *, QMouseEvent *)
MouseActions::MMoveMarker Paints a triangle above the mouse for "set marker on graph".
QAction * intoH
Definition: qucs.h:174
bool isSelected
Definition: element.h:151
unsigned int NodeWiring
Definition: main.h:64
#define isVMovingLabel
Definition: element.h:129
Component * selectCompText(int, int, int &, int &)
Component * selectedComponent(int, int)
void MReleaseActivate(Schematic *, QMouseEvent *)
int UsedX2
Definition: schematic.h:133
int placeNodeLabel(WireLabel *)
void MPressOnGrid(Schematic *, QMouseEvent *, float, float)
Element * selElem
Definition: mouseactions.h:50
QAction * moveText
Definition: qucs.h:292
virtual void setSchematic(Schematic *p)
Definition: component.h:65
Q3PtrList< Graph > Graphs
Definition: diagram.h:95
void Bounding(int &, int &, int &, int &)
Definition: diagram.cpp:622
void MMoveSelect(Schematic *, QMouseEvent *)
MouseActions::MMoveSelect Paints a rectangle for select area.
QAction * editMirrorY
Definition: qucs.h:292
void setCompPorts(Component *)
void MPressRotate(Schematic *, QMouseEvent *, float, float)
QAction * symEdit
Definition: qucs.h:174
void(MouseActions::* MouseReleaseAction)(Schematic *, QMouseEvent *)
Definition: qucs.h:88
#define isAnalogComponent
Definition: element.h:112
int ViewX1
Definition: schematic.h:132
Superclass of all schematic drawing elements.
Definition: element.h:142
#define isGraph
Definition: element.h:115
#define isDiagramVScroll
Definition: element.h:134
QAction * editActivate
Definition: qucs.h:292
void MReleaseMoving(Schematic *, QMouseEvent *)
#define isDiagramHScroll
Definition: element.h:133
#define isHWireLabel
Definition: element.h:124
void MMoveMoveText(Schematic *, QMouseEvent *)
MouseActions::MMoveMoveText Paint rectangle around component text being mouse moved.
QAction * formerAction
#define isLabel
Definition: element.h:123
Q3PtrList< Port > Ports
Definition: component.h:70
void slotApplyCompText()
QString DataSet
Definition: qucsdoc.h:52
void rotate()
Definition: component.cpp:390
static QMap< QString, QString > vaComponents
Definition: module.h:43
#define isVWireLabel
Definition: element.h:125
void editLabel(Schematic *, WireLabel *)
bool activateSpecifiedComponent(int, int)
#define isPainting
Definition: element.h:120
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...
QAction * popH
Definition: qucs.h:174
QAction * editCopy
Definition: qucs.h:174
QString Name
Definition: component.h:80
QAction * activeAction
Definition: qucs.h:182
QAction * graph2csv
Definition: qucs.h:292
Element * getWireLabel(Node *)
QAction * select
Definition: qucs.h:292
#define isDiagramResize
Definition: element.h:132
void MPressWire2(Schematic *, QMouseEvent *, float, float)
MouseActions::MPressWire2 Is called if ending point of wire is pressed.
QString Model
Definition: component.h:80
int UsedY2
Definition: schematic.h:133
QAction * fileSettings
Definition: qucs.h:174
void MReleasePaste(Schematic *, QMouseEvent *)
Conductor * pOwner
Definition: wirelabel.h:42
int cy
Definition: element.h:153
QAction * editPaste
Definition: qucs.h:292
#define isComponentText
Definition: element.h:111
void updateGraphData()
Definition: diagram.cpp:800
QLineEdit * InitValue
Definition: labeldialog.h:40
Wire * selectedWire(int, int)
virtual Diagram * newOne()
Definition: diagram.cpp:1191
WireLabel * Label
Definition: element.h:163
QString DocName
Definition: qucsdoc.h:51
void MPressMoveText(Schematic *, QMouseEvent *, float, float)
#define DOC_X_POS(x)
void(MouseActions::* MouseDoubleClickAction)(Schematic *, QMouseEvent *)
Definition: qucs.h:87
QAction * onGrid
Definition: qucs.h:292
void selectWireLine(Element *, Node *, bool)
#define isMovingLabel
Definition: element.h:127
void paintElementsScheme(Schematic *)
#define isComponent
Definition: element.h:110
Node * Port1
Definition: wire.h:43
void setComponentNumber(Component *)
void MReleaseZoomIn(Schematic *, QMouseEvent *)
bool pasteElements(Schematic *)
void moveElements(Schematic *, int &, int &)
#define isHMovingLabel
Definition: element.h:128
Definition of the vacomponent class.
Definition: qucs.h:61
void activateCompsWithinRect(int, int, int, int)
void paintScheme(Schematic *)
Definition: component.cpp:319
int UsedX1
Definition: schematic.h:133
virtual void paintScheme(Schematic *)
Definition: element.cpp:31
void MPressMirrorY(Schematic *, QMouseEvent *, float, float)
void sizeOfAll(int &, int &, int &, int &)
Definition: schematic.cpp:931
void rightPressMenu(Schematic *, QMouseEvent *, float, float)
void deselectElements(Element *)
void MDoubleClickSelect(Schematic *, QMouseEvent *)
#define isWire
Definition: element.h:118
QMouseEvent * focusMEvent
Definition: mouseactions.h:52
int x2
Definition: element.h:153
Q3PtrList< Painting > * Paintings
Definition: schematic.h:122
Node * Port2
Definition: wire.h:43
Q3PtrList< Wire > * Wires
Definition: schematic.h:119
int UsedY1
Definition: schematic.h:133
virtual void mirrorY()
Definition: painting.h:50
void MMoveWire2(Schematic *, QMouseEvent *)
MouseActions::MMoveWire2 Paint wire as it is being drawn with mouse.
virtual bool scrollTo(int, int, int)
Definition: tabdiagram.cpp:377
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)
Definition: wire.cpp:129
QString initValue
Definition: wirelabel.h:46
Diagram * Diag
Definition: marker.h:51
void highlightWireLabels(void)
bool elementsOnGrid()
Definition: schematic.cpp:1685
virtual void setCenter(int, int, bool relative=false)
Definition: element.cpp:35
void paintScheme(Schematic *)
Definition: diagram.cpp:150
void MReleaseResizeDiagram(Schematic *, QMouseEvent *)
void setChanged(bool, bool fillStack=false, char Op='*')
Definition: schematic.cpp:278
#define isNode
Definition: element.h:116
#define isMarker
Definition: element.h:117
void insertNodeLabel(WireLabel *)
QLineEdit * NodeName
Definition: labeldialog.h:40
void MPressZoomIn(Schematic *, QMouseEvent *, float, float)
QAction * editMirror
Definition: qucs.h:292