0.19pre FEM, OK button fail on GMSH task panel

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
fc_tofu
Posts: 652
Joined: Sun Jan 05, 2020 4:56 pm

0.19pre FEM, OK button fail on GMSH task panel

Post by fc_tofu » Sat May 30, 2020 10:15 am

Summary:
FEM WB, task panel of GMSH mesher, "OK" button fail to work.

Reproduce:
1. Restart FC.
2. PartWB, create Cube primitive, size 100mm * 10mm * 10mm.
3. FEM WB, select the cube.
4. menu >Mesh >FEM mesh from shape by GMSH.
5. An empty object named "FEMMeshGmsh" appear in TreeView.
6. Toggle on visibility of "FEMMeshGmsh", nothing appears on viewport.
fsc_2020-05-30_180352.jpg
fsc_2020-05-30_180352.jpg (107.42 KiB) Viewed 328 times
ps.
Same issue on FC 0.18.4/Win10X64

Code: Select all

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21280 (Git)
Build type: Release
Branch: master
Hash: 6f3160db3e88733536c7eaf97ad7d6ebd21baccd
Python version: 3.8.2
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: Chinese/China (zh_CN)
Attachments
019_fem_ok_gmsh.FCStd
(5.38 KiB) Downloaded 2 times

User avatar
bernd
Posts: 10098
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: 0.19pre FEM, OK button fail on GMSH task panel

Post by bernd » Sun May 31, 2020 7:29 am

have you tried to click on apply?

fc_tofu
Posts: 652
Joined: Sun Jan 05, 2020 4:56 pm

Re: 0.19pre FEM, OK button fail on GMSH task panel

Post by fc_tofu » Sun May 31, 2020 7:47 am

bernd wrote:
Sun May 31, 2020 7:29 am
have you tried to click on apply?
Apply button take effect.
Ok button works same as Cancel button.

File: FreeCAD/src/Mod/Fem/femviewprovider/view_mesh_gmsh.py

Code: Select all

https://github.com/FreeCAD/FreeCAD/blob/0944b5994772f063747cf5939ee09d81f47fde17/src/Mod/Fem/femviewprovider/view_mesh_gmsh.py
Line: 318-341

Code: Select all

    def getStandardButtons(self):
        button_value = int(
            QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel
        )
        return button_value
        # show a OK, a apply and a Cancel button
        # def reject() is called on Cancel button
        # def clicked(self, button) is needed, to access the apply button

    def accept(self):
        self.set_mesh_params()
        self.mesh_obj.ViewObject.Document.resetEdit()
        self.mesh_obj.Document.recompute()
        return True

    def reject(self):
        self.mesh_obj.ViewObject.Document.resetEdit()
        self.mesh_obj.Document.recompute()
        return True

    def clicked(self, button):
        if button == QtGui.QDialogButtonBox.Apply:
            self.set_mesh_params()
            self.run_gmsh()
It seems that same code has been writen for OK and Cancel buttons.
You can compare with OK button behavior in Netgen task panel.

File: FreeCAD/src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.h
https://github.com/FreeCAD/FreeCAD/blob ... peNetgen.h
Line: 53-54

Code: Select all

    /// is called by the framework if the dialog is accepted (Ok)
    virtual bool accept();
File: FreeCAD/src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.cpp
https://github.com/FreeCAD/FreeCAD/blob ... Netgen.cpp
Line: 98-130

Code: Select all

bool TaskDlgMeshShapeNetgen::accept()
{
    try {
        if(param->touched)
        {
            Gui::WaitCursor wc;
            bool ret = FemMeshShapeNetgenObject->recomputeFeature();
            if (!ret) {
                wc.restoreCursor();
                QMessageBox::critical(Gui::getMainWindow(), tr("Meshing failure"),
                                      QString::fromStdString(FemMeshShapeNetgenObject->getStatusString()));
                return true;
            }
        }

        // hide the input object
        App::DocumentObject* obj = FemMeshShapeNetgenObject->Shape.getValue();
        if (obj) {
            Gui::Application::Instance->hideViewProvider(obj);
        }

        //FemSetNodesObject->Label.setValue(name->name);
        Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
        Gui::Command::commitCommand();

        return true;
    }
    catch (const Base::Exception& e) {
        Base::Console().Warning("TaskDlgMeshShapeNetgen::accept(): %s\n", e.what());
    }

    return false;
}
Sorry, I know little about coding.

User avatar
bernd
Posts: 10098
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: 0.19pre FEM, OK button fail on GMSH task panel

Post by bernd » Sun May 31, 2020 11:44 am

no cancel does not save the user input, whereas OK does not mesh, but saves the user input.

fc_tofu
Posts: 652
Joined: Sun Jan 05, 2020 4:56 pm

Re: 0.19pre FEM, OK button fail on GMSH task panel

Post by fc_tofu » Sun May 31, 2020 3:12 pm

bernd wrote:
Sun May 31, 2020 11:44 am
no cancel does not save the user input, whereas OK ...saves the user input.
Thank, here I see.
bernd wrote:
Sun May 31, 2020 11:44 am
...OK does not mesh...
Do you mean this is intended behavior? I see inconsistency with OK button in Netgen task panel.
OK button in Netgen task panel does mesh.

fc_tofu
Posts: 652
Joined: Sun Jan 05, 2020 4:56 pm

Re: 0.19pre FEM, OK button fail on GMSH task panel

Post by fc_tofu » Tue Jun 02, 2020 5:21 am

I made a mock-up code.

File: view_mesh_gmsh.py
Line: 327-332

Code: Select all

    def accept(self):
        self.set_mesh_params()
        self.mesh_obj.ViewObject.Document.resetEdit()
        self.mesh_obj.Document.recompute()
        self.run_gmsh()    #rv+
        return True

fc_tofu
Posts: 652
Joined: Sun Jan 05, 2020 4:56 pm

Re: 0.19pre FEM, OK button fail on GMSH task panel

Post by fc_tofu » Sat Jun 13, 2020 12:05 pm

In latest build, related code has moved to file "task_mesh_gmsh.py".

a mock-up fix, (line 103)

Code: Select all

    def accept(self):
        self.set_mesh_params()
        self.mesh_obj.ViewObject.Document.resetEdit()
        self.run_gmsh()    #rv+
        self.mesh_obj.Document.recompute()
        return True

Code: Select all



OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21514 (Git)
Build type: Release
Branch: master
Hash: 89ddab33f692a9bd739171689f9ab0eb58d64b35
Python version: 3.8.2
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: Chinese/China (zh_CN)

Post Reply