Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TechDraw] Align points to direction by rotation #16342

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benj5378
Copy link
Contributor

@benj5378 benj5378 commented Sep 6, 2024

Fixes #7061

@github-actions github-actions bot added the Mod: TechDraw Related to the TechDraw Workbench label Sep 6, 2024
@luzpaz luzpaz requested a review from WandererFan September 6, 2024 22:14
@benj5378
Copy link
Contributor Author

benj5378 commented Sep 6, 2024

auto selection = cmd->getSelection().getSelectionEx(
nullptr, App::DocumentObject::getClassTypeId(), resolve, single);
for (auto& sel : selection) {
bool is_linked = false;
auto obj = sel.getObject();
if (obj->isDerivedFrom(TechDraw::DrawPage::getClassTypeId())) {
continue;
}
if (obj->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
//use the dvp's Sources as sources for this ComplexSection &
//check the subelement(s) to see if they can be used as a profile
baseView = static_cast<TechDraw::DrawViewPart*>(obj);
if (!sel.getSubNames().empty()) {
//need to add profile subs as parameter
profileObject = baseView;
profileSubs = sel.getSubNames();
}
continue;
}

@WandererFan Dude, we seriously need to do something about this. It's way too complicated retrieving just the base view from selection. And the code is just copy-pasted everywhere.

@maxwxyz maxwxyz added this to the Post 1.0 milestone Sep 7, 2024
@benj5378 benj5378 closed this Sep 13, 2024
@benj5378 benj5378 deleted the memberVariables branch September 13, 2024 22:22
@benj5378 benj5378 restored the memberVariables branch September 13, 2024 22:22
@benj5378 benj5378 reopened this Sep 13, 2024
@benj5378 benj5378 marked this pull request as ready for review September 13, 2024 22:23
@benj5378
Copy link
Contributor Author

benj5378 commented Sep 13, 2024

@WandererFan, ready for review.

This should be tested broadly, as there were multiple issues with rotating the incorrect direction and such stuff. Issue was, that Base::Vector2d::GetAngle(otherVector) would give the same value, no matter the vector order/rotation direction...

@benj5378
Copy link
Contributor Author

image
Better late than never

@benj5378
Copy link
Contributor Author

@WandererFan

@benj5378
Copy link
Contributor Author

@WandererFan @chennes

@chennes
Copy link
Member

chennes commented Sep 30, 2024

@benj5378 right now we are struggling to keep up with the 1.0 milestone PRs. Hold tight, we will get back to our normal PR process as soon as we can.

@maxwxyz
Copy link
Collaborator

maxwxyz commented Nov 24, 2024

@benj5378 could you update the PR?

@maxwxyz
Copy link
Collaborator

maxwxyz commented Nov 30, 2024

@benj5378 ping

@maxwxyz
Copy link
Collaborator

maxwxyz commented Dec 6, 2024

waiting for feedback

@maxwxyz
Copy link
Collaborator

maxwxyz commented Dec 8, 2024

bump

@maxwxyz maxwxyz added the Status: Stale Stale and might be closed automatically. label Dec 9, 2024
@benj5378
Copy link
Contributor Author

@maxwxyz updated

@maxwxyz maxwxyz removed the Status: Stale Stale and might be closed automatically. label Dec 19, 2024
@chennes
Copy link
Member

chennes commented Dec 20, 2024

@davesrocketshop is going to give it a look

@chennes
Copy link
Member

chennes commented Dec 23, 2024

And so is @WandererFan


std::vector<QGIVertex*> vertexes = view->getObjects<QGIVertex*>(vertexIndexes);
if(vertexes.size() != 2) {
Base::Console().Error(QObject::tr("You must select 2 vertexes\n").toStdString().c_str());
Copy link
Contributor

@WandererFan WandererFan Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message only in Report view is easy to miss. Need a QMessageBox here.

    QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect selection"),
                         QObject::tr("Please select 2 vertexes or 1 edge"));
    return false;


std::vector<std::string> vertexNames = getSelection().getSelectionEx()[0].getSubNames();
std::vector<int> vertexIndexes = DrawUtil::getIndexFromName(vertexNames);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't the feature request ask for alignment by an edge? This only does 2 vertexes. Need something like:

std::string gType = TechDraw::DrawUtil::getGeomTypeFromName(subnames.at(0));
if (gType == "Edge") {.
    auto edgeIndex = TechDraw::DrawUtil::getIndexFromName(Name);
    TechDraw::BaseGeomPtr geom = dvp->getGeomByIndex(edgeIndex);
    if (geom->getGeomType() != TechDraw::GENERIC) {
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
                    QObject::tr("Please select a straight edge"));
        return;
    }
    point0 = geom->getStartPoint();
    point1 = geom->getEndPoint();
} else if (gType == "Vertex") {
    ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It indeed did! However, I think that it will give more flexibility with points. There might not be an edge for the desired alignment, but there will always be points for a desired edge.

We can also do, that either two points or one edge are required?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since they asked for an edge, we should give them an edge. Points can be a bonus.

@WandererFan
Copy link
Contributor

Works well with 2 vertices.

aligning->setCommand("Aligning");
*aligning << "TechDraw_AlignVertexesVertically";
*aligning << "TechDraw_AlignVertexesHorizontally";

// main menu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No button in toolbar? Hard to find the function if it is only in the menu.


std::vector<std::string> vertexNames = getSelection().getSelectionEx()[0].getSubNames();
std::vector<int> vertexIndexes = DrawUtil::getIndexFromName(vertexNames);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since they asked for an edge, we should give them an edge. Points can be a bonus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mod: TechDraw Related to the TechDraw Workbench
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] TechDraw: Align View With Selected Edge
4 participants