drawing->dirty = false;
drawing->update();
documentName.clear();
- setWindowTitle("Architektonas - Untitled");
+// setWindowTitle("Architektonas - Untitled");
+ setWindowFilePath(documentName);
statusBar()->showMessage(tr("New drawing is ready."));
}
toolbar->setObjectName(tr("Pen"));
toolbar->addWidget(pw);
connect(drawing, SIGNAL(ObjectSelected(Object *)), pw, SLOT(SetFields(Object *)));
- connect(pw, SIGNAL(WidthSelected(float)), drawing, SLOT(HandlePenWidth(float)));
- connect(pw, SIGNAL(StyleSelected(int)), drawing, SLOT(HandlePenStyle(int)));
- connect(pw, SIGNAL(ColorSelected(uint32_t)), drawing, SLOT(HandlePenColor(uint32_t)));
connect(pw->tbStamp, SIGNAL(triggered(QAction *)), drawing, SLOT(HandlePenStamp(QAction *)));
connect(pw->tbDropper, SIGNAL(triggered(QAction *)), drawing, SLOT(HandlePenDropper(QAction *)));
}
//
void DrawingView::DeleteCurrentLayer(int layer)
{
-//printf("DrawingView::DeleteCurrentLayer(): currentLayer = %i\n", layer);
VPVectorIter i = document.objects.begin();
while (i != document.objects.end())
//
void DrawingView::HandleLayerSwap(int layer1, int layer2)
{
-//printf("DrawingView: Swapping layers %i and %i.\n", layer1, layer2);
HandleLayerSwap(layer1, layer2, document.objects);
}
}
}
-void DrawingView::HandlePenWidth(float width)
-{
- for(VPVectorIter i=select.begin(); i!=select.end(); i++)
- {
- Object * obj = (Object *)(*i);
- obj->thickness = width;
- }
-
- supressSelected = true;
- update();
-}
-
-void DrawingView::HandlePenStyle(int style)
-{
- for(VPVectorIter i=select.begin(); i!=select.end(); i++)
- {
- Object * obj = (Object *)(*i);
- obj->style = style;
- }
-
- supressSelected = true;
- update();
-}
-
-void DrawingView::HandlePenColor(uint32_t color)
-{
- for(VPVectorIter i=select.begin(); i!=select.end(); i++)
- {
- Object * obj = (Object *)(*i);
- obj->color = color;
- }
-
- supressSelected = true;
- update();
-}
-
void DrawingView::HandlePenStamp(QAction * action)
{
PenWidget * pw = (PenWidget *)action->parentWidget();
void DrawingView::focusOutEvent(QFocusEvent * /*event*/)
{
-// printf("DrawingView::focusOutEvent()...\n");
// Make sure all modkeys being held are marked as released when the app
// loses focus (N.B.: This only works because the app sets the focus policy
// of this object to something other than Qt::NoFocus)
setCursor(curMarker);
else if (Global::penDropper)
setCursor(curDropper);
-//FocusOut already set this...
-// else
-// setCursor(Qt::ArrowCursor);
}
void DrawingView::paintEvent(QPaintEvent * /*event*/)
}
//
-// This toggles the selection being hovered (typically, only 1 object)
+// This toggles the selection being hovered (typically, only 1 object). We
+// toggle because the CTRL key might be held, in which case, we want to
+// deselect a selected object.
//
-void DrawingView::AddHoveredToSelection(void)
+void DrawingView::HandleSelectionClick(VPVector & v)
{
- for(VPVectorIter i=document.objects.begin(); i!=document.objects.end(); i++)
+ if (ctrlDown)
+ {
+ for(VPVectorIter i=v.begin(); i!=v.end(); i++)
+ {
+ Object * obj = (Object *)(*i);
+
+ if (obj->hovered)
+ obj->selected = !obj->selected;
+ }
+
+ return;
+ }
+
+ for(VPVectorIter i=v.begin(); i!=v.end(); i++)
+ ((Object *)(*i))->selected = false;
+
+ // Check if the hover changed, and if so, reset the selection stack
+ if (oldHover.size() != v.size())
{
- if (((Object *)(*i))->hovered)
-// ((Object *)(*i))->selected = true;
- ((Object *)(*i))->selected = !((Object *)(*i))->selected;
+ oldHover = v;
+ currentSelect = 0;
}
+ else
+ {
+ // Select next object in the stack under the cursor
+ currentSelect++;
+
+ if (currentSelect >= v.size())
+ currentSelect = 0;
+ }
+
+ dragged = (Object *)v[currentSelect];
+ dragged->selected = true;
}
VPVector DrawingView::GetSelection(void)
{
if (event->button() == Qt::LeftButton)
{
-//printf("mousePressEvent::Qt::LeftButton numHovered=%li\n", numHovered);
Vector point = Painter::QtToCartesianCoords(Vector(event->x(), event->y()));
// Handle tool processing, if any
if (!ctrlDown)
ClearSelected(document.objects);
- // If any objects are being hovered on click, add them to the selection
- // & return
+ // If any objects are being hovered on click, deal with 'em
if (numHovered > 0)
{
- AddHoveredToSelection();
- update(); // needed??
-// GetHovered(hover); // prolly needed
VPVector hover2 = GetHovered();
dragged = (Object *)hover2[0];
- draggingObject = true;
-//printf("mousePressEvent::numHovered > 0 (hover2[0]=$%llx, type=%s)\n", dragged, objName[dragged->type]);
// Alert the pen widget
if (Global::penDropper)
Global::penWidth = dragged->thickness;
Global::penStyle = dragged->style;
emit ObjectSelected(dragged);
- ClearSelected(document.objects);
return;
}
-
- if (Global::penStamp)
+ else if (Global::penStamp)
{
dragged->color = Global::penColor;
dragged->thickness = Global::penWidth;
dragged->style = Global::penStyle;
return;
}
-
- // See if anything is using just a straight click on a handle
- if (HandleObjectClicked())
+ // See if anything is using just a straight click on a custom
+ // object handle (like Dimension objects)
+ else if (HandleObjectClicked())
{
- draggingObject = false;
update();
return;
}
+ draggingObject = true;
+ HandleSelectionClick(hover2);
+ update(); // needed??
+
// Needed for grab & moving objects
// We do it *after*... why? (doesn't seem to confer any advantage...)
if (hoveringIntersection)
Point SnapPointToGrid(Point);
Point SnapPointToAngle(Point);
void RenderObjects(Painter *, VPVector &, int, bool ignoreLayer = false);
- void AddHoveredToSelection(void);
+ void HandleSelectionClick(VPVector &);
VPVector GetSelection(void);
VPVector GetHovered(bool exclude = false);
void MoveSelectedToLayer(int);
void HandleLayerToggle(void);
void HandleLayerSwap(int, int);
void HandleLayerSwap(int, int, VPVector &);
- void HandlePenWidth(float);
- void HandlePenStyle(int);
- void HandlePenColor(uint32_t);
void HandlePenStamp(QAction *);
void HandlePenDropper(QAction *);
bool supressSelected;
QCursor curMarker;
QCursor curDropper;
+ uint32_t currentSelect;
public:
Container document;
uint32_t gridPixels; // Grid size in pixels
double gridPixelsF; // Grid size in pixels (float)
-// private:
- public:
bool collided;
bool scrollDrag;
Vector oldPoint;
VPVector toolObjects;
std::vector<Object> toolScratch;
VPVector toolScratch2;
+ VPVector oldHover;
Point toolPoint[32];
Object * toolObj[32];
double toolParam[32];
// --- ---------- -----------------------------------------------------------
// JLH 05/07/2017 Created this file
//
-//maybe add a button to have it stamp attributes on all objects clicked on? [added Global::penStamp to facilitate this.]
-//need to add to drawingview the ability to use attributes on new objects [DONE]
-//need to override the selection so you can see the attributes effects immediately when they are changed instead of having to deselect them to see [IN PROGRESS]
+// Maybe add a "pen" pallete, to hold most frequently used pen colors/styles
+//
#include "penwidget.h"
return;
Global::penWidth = value;
- emit WidthSelected(Global::penWidth);
}
void PenWidget::HandleStyleSelected(int selected)
// Styles are 1-based, but the combobox is 0-based, so we compensate for
// that here
Global::penStyle = selected + 1;
- emit StyleSelected(Global::penStyle);
}
void PenWidget::HandleRedSelected(QString text)
r = value;
Global::penColor = (r << 16) | (g << 8) | b;
- emit ColorSelected(Global::penColor);
}
void PenWidget::HandleGreenSelected(QString text)
g = value;
Global::penColor = (r << 16) | (g << 8) | b;
- emit ColorSelected(Global::penColor);
}
void PenWidget::HandleBlueSelected(QString text)
b = value;
Global::penColor = (r << 16) | (g << 8) | b;
- emit ColorSelected(Global::penColor);
}