Skip to content

Commit

Permalink
Align interface save/reload
Browse files Browse the repository at this point in the history
  • Loading branch information
ponchio committed Jan 26, 2025
1 parent 7635fc7 commit 1cbbe20
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
12 changes: 5 additions & 7 deletions relightlab/alignframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ AlignFrame::AlignFrame(QWidget *parent): QFrame(parent) {
new_align->setMaximumWidth(300);

QFrame *aligns_frame = new QFrame;
content->addWidget(aligns_frame);
content->addWidget(aligns_frame, 0);
aligns = new QVBoxLayout(aligns_frame);

AlignPicking *picking = new AlignPicking();
content->addWidget(picking);

content->addStretch(1);
//content->addStretch();
connect(new_align, SIGNAL(clicked()), this, SLOT(newAlign()));
}
Expand Down Expand Up @@ -77,16 +75,16 @@ AlignRow *AlignFrame::addAlign(Align *align) {
}

void AlignFrame::removeAlign(AlignRow *row) {
layout()->removeWidget(row);

row->stopFinding();

layout()->removeWidget(row);

Align *align = row->align;
auto &aligns = qRelightApp->project().aligns;

auto it = std::find(aligns.begin(), aligns.end(), align);

// assert(it != aligns.end());
assert(it != aligns.end());

delete align;
aligns.erase(it);
Expand Down
4 changes: 3 additions & 1 deletion relightlab/domepanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ void DomePanel::updateDomeList() {
try {
dome.load(path);
} catch (QString error) {
qDebug() << error;
qDebug() << "Problems loading dome at" << path << ": " << error;
qRelightApp->removeDome(path);
continue;
}

QFileInfo info(path);
Expand Down
4 changes: 2 additions & 2 deletions relightlab/sphererow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ void SphereRow::edit() {
void SphereRow::verify() {
std::vector<QPointF> &positions = sphere->lights;
for(QPointF &pos: positions)
pos -= sphere->inner.topLeft();
pos -= sphere->inner.center();
VerifyDialog *verify_dialog = new VerifyDialog(sphere->thumbs, positions, VerifyDialog::REFLECTION, this);
verify_dialog->exec();

for(QPointF &pos: positions)
pos += sphere->inner.topLeft();
pos += sphere->inner.center();
}

void SphereRow::remove() {
Expand Down
1 change: 0 additions & 1 deletion relightlab/verifydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ VerifyDialog::VerifyDialog(std::vector<QImage> &_thumbs, std::vector<QPointF> &_

area->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

cout << "Thumbs.size: " << thumbs.size() << endl;
for(size_t i = 0; i < thumbs.size(); i++) {
assert(!thumbs[i].isNull());
if(marker == REFLECTION ) {
Expand Down
31 changes: 16 additions & 15 deletions relightlab/verifyview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ VerifyView:: VerifyView(QImage &_image, int _height, QPointF &_pos, VerifyMarker
height = _height;
setScene(&scene);

setFocusPolicy(Qt::StrongFocus);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

Expand All @@ -76,35 +77,35 @@ VerifyView:: VerifyView(QImage &_image, int _height, QPointF &_pos, VerifyMarker
double scale = height/(double)pix.height();
setFixedSize(pix.width()*scale, height);

center = QPointF(image.width()/2.0f, image.height()/2.0f);

marker_item = new VerifyMarker(this, marker);
marker_item->radius = 8*scale;
if(pos.isNull()) {
marker_item->setPos(image.width()/2, image.height()/2);
marker_item->active = false;

} else {
marker_item->setPos(pos);
marker_item->active = true;
}
marker_item->setPos(pos + center);
marker_item->active = !pos.isNull();
scene.addItem(marker_item);
}


void VerifyView::update() {
QPointF p = marker_item->pos();
if(!img_item->boundingRect().contains(p)) {
marker_item->setPos(image.width()/2, image.height()/2);
marker_item->active = false;
pos = QPointF(0, 0); //order is important: setPos triggers again.

} else {
pos = p;
marker_item->active = true;
marker_item->setPos(center);
}
pos = p - center;
marker_item->active = !pos.isNull();
}

void VerifyView::resizeEvent(QResizeEvent *) {
fitInView(img_item->boundingRect()); //.sceneRect()); //img_item);
}

void VerifyView::keyPressEvent(QKeyEvent *event) {
if (event->key() == Qt::Key_Delete) {
marker_item->setPos(center);
update();
return;
}
QWidget::keyPressEvent(event);
}

7 changes: 4 additions & 3 deletions relightlab/verifyview.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ class VerifyView: public QGraphicsView {
void update();

protected:
void resizeEvent(QResizeEvent *event);

void resizeEvent(QResizeEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
protected:
VerifyMarker *marker_item = nullptr;
QGraphicsPixmapItem *img_item = nullptr;
QGraphicsScene scene = nullptr;
QGraphicsScene scene ;
QImage &image;
QPointF center;
QPointF &pos;
int id;
int height;
Expand Down
1 change: 0 additions & 1 deletion src/align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ void Align::readThumb(QImage img, int n) {
if(n == 0)
thumbs.clear();
thumbs.push_back(img.copy(rect));
offsets.push_back(QPointF(0, 0));
}

0 comments on commit 1cbbe20

Please sign in to comment.