Conversation
|
|
||
| void MainWindow::new_project() | ||
| { | ||
| if (!can_close_project()) |
There was a problem hiding this comment.
I think that in scripting, we always want to close existing project, even if it has unsaved changes.
We should move the can_close_project() test back to the slot.
What do you think?
There was a problem hiding this comment.
agree
but maybe we don't want to close project if it's unsaved? Maybe it would be a good idea to introduce force flag here? And if force==false and project is not saved then throw exception
|
|
||
| void MainWindow::build_python_console_panel() | ||
| { | ||
| PythonInterpreter::instance().set_mainwindow(this); |
There was a problem hiding this comment.
Can we move this to the place where the mainwindow is created?
It's not really related to the python console panel.
| // appleseed.foundation headers. | ||
| #include "foundation/core/concepts/noncopyable.h" | ||
|
|
||
| #include "mainwindow/mainwindow.h" |
There was a problem hiding this comment.
that way I need to include mainwindow.h in module.cpp and in every file where I use PythonInterpreter and get MainWindow from it. Is it ok?
There was a problem hiding this comment.
Yes, it is ok. It's more work, but it's better and we already do it everywhere in the rest of the code.
| #include <algorithm> | ||
| #include <cassert> | ||
|
|
||
| #include "python/pythoninterpreter.h" |
There was a problem hiding this comment.
Move to the appleseed.studio headers section.
| m_project_manager.load_project(filepath.toAscii().constData()); | ||
| } | ||
|
|
||
| void MainWindow::new_project() |
There was a problem hiding this comment.
Maybe move before open_project() to follow the natural progression: new, open, save, save as, etc.
| @@ -85,7 +98,9 @@ PythonInterpreter::PythonInterpreter() | |||
| // Imports appleseed module and creates asd alias for it | |||
There was a problem hiding this comment.
Update comment now that there are two modules.
| @@ -85,7 +98,9 @@ PythonInterpreter::PythonInterpreter() | |||
| // Imports appleseed module and creates asd alias for it | |||
| // so we can refer to it by both names. | |||
| PyRun_SimpleString("import appleseed\n" | |||
There was a problem hiding this comment.
All imports first, all namespace aliases next.
| studio::PythonInterpreter::instance().get_mainwindow()->open_project(project_path); | ||
| } | ||
|
|
||
| void new_project() |
There was a problem hiding this comment.
Reorder here too: new_project() first, open_project() second
| void execute_command(const char* command); | ||
|
|
||
| void redirect_output(OutputRedirector redirector); | ||
| void set_mainwindow(MainWindow* mainWindow); |
There was a problem hiding this comment.
I'd suggest reordering methods of this class to follow a more logical progression:
instance
set_mainwindow
get_mainwindow
redirect_output
execute_command
|
|
||
| void redirect_output(OutputRedirector redirector); | ||
| void set_mainwindow(MainWindow* mainWindow); | ||
| MainWindow* get_mainwindow(); |
There was a problem hiding this comment.
get_mainwindow() should be made const.
There was a problem hiding this comment.
I can't because then I can't use its non-const functions
const MainWindow* PythonInterpreter::get_mainwindow()
{
return mainWindow;
}
PythonInterpreter::instance().get_mainwindow().->open_project();
There was a problem hiding this comment.
I'm not talking about returning a const MainWindow*, I'm just saying you should make get_mainwindow() itself const, which isn't the same thing:
MainWindow* get_mainwindow() const;
|
|
||
| #include "foundation/platform/python.h" | ||
|
|
||
| #include "pythoninterpreter.h" |
There was a problem hiding this comment.
Headers should be ordered from the most specific first (appleseed.studio headers first in this case) to the most general (typically standard headers). This order was chosen because it helps catching missing header files. Several explanations and details can be found here: https://stackoverflow.com/questions/2762568/c-c-include-file-order-best-practices
Also, add the section comments: "appleseed.studio headers", "appleseed.foundation headers", etc.
| namespace bpy = boost::python; | ||
| namespace bf = boost::filesystem; | ||
|
|
||
| extern "C" void init_appleseedstudio(); |
There was a problem hiding this comment.
Where is this function defined?
There was a problem hiding this comment.
it is generated by BOOST_PYTHON_MODULE(_appleseedstudio) in module.cpp
| m_project_manager.load_project(filepath.toAscii().constData()); | ||
| } | ||
|
|
||
| void MainWindow::open_and_render_project(const QString& filepath, const QString& configuration) |
There was a problem hiding this comment.
idk if I should expose this
There was a problem hiding this comment.
I thought you wanted to remove MainWindow::open_and_render_project()?
There was a problem hiding this comment.
no, it was there before. Should I?
There was a problem hiding this comment.
Ah ok, my bad :) It's fine then.
| return false; | ||
| } | ||
|
|
||
| bool MainWindow::can_close_project() |
There was a problem hiding this comment.
I separated it to use in python module, but don't use it now. Should I revert it?
There was a problem hiding this comment.
Yes, if it is unused, lets remove it.
| return m_project_manager.get_project(); | ||
| } | ||
|
|
||
| bool MainWindow::is_project_dirty() |
There was a problem hiding this comment.
is it ok to add this function here?
There was a problem hiding this comment.
maybe change all appearances of m_project_manager.is_project_dirty in MainWindow on this then?
There was a problem hiding this comment.
I'm really not enthusiastic about it. I see no value in duplicating what the project manager already offers. I'm in favor of removing this method.
|
|
||
| MainWindow* mainwindow() | ||
| { | ||
| return PythonInterpreter::instance().get_mainwindow(); |
There was a problem hiding this comment.
Does it have any significant overhead to call for interpreter instance every time I need MainWindow?
There was a problem hiding this comment.
Not really. Scripting is not really about performance and on top of that Python is super slow.
| } | ||
|
|
||
| bool MainWindow::can_close_project() | ||
| bool MainWindow::attempt_close_project() |
There was a problem hiding this comment.
The name of this method is misleading: it isn't closing the project, it's just checking if the project can be closed. Maybe ask_can_close_project()? Not ideal but better. Maybe you have a better suggestion? :)
There was a problem hiding this comment.
I will revert it back to old can_close_project function as I don't use separated part anyway
|
|
||
| bool MainWindow::can_close_project() | ||
| { | ||
| return !m_project_manager.is_project_loading() && // Project is not being loaded: no problem |
There was a problem hiding this comment.
Rewrite as a series of if with early exits as it used to be done. This makes the logic much clearer.
|
|
||
| // appleseed.studio headers. | ||
| #include "mainwindow/mainwindow.h" | ||
| #include "pythoninterpreter.h" |
There was a problem hiding this comment.
Should be python/pythoninterpreter.h.
| using namespace renderer; | ||
| using namespace foundation; | ||
|
|
||
| MainWindow* mainwindow() |
|
|
||
| MainWindow* mainwindow() | ||
| { | ||
| return PythonInterpreter::instance().get_mainwindow(); |
| } | ||
|
|
||
| void PythonInterpreter::execute_command(const char* command) | ||
| void PythonInterpreter::set_mainwindow(MainWindow* window) |
| PythonInterpreter(); | ||
| ~PythonInterpreter(); | ||
|
|
||
| MainWindow* mainWindow; |
|
Starts to look pretty awesome! |
| case QMessageBox::Save: | ||
| slot_save_project(); | ||
| return true; | ||
| case QMessageBox::Save: |
There was a problem hiding this comment.
Revert indentation for the switch block.
| m_project_manager.load_project(filepath.toAscii().constData()); | ||
| } | ||
|
|
||
| void MainWindow::open_and_render_project(const QString& filepath, const QString& configuration) |
There was a problem hiding this comment.
I thought you wanted to remove MainWindow::open_and_render_project()?
| update_recent_files_menu(filepath); | ||
| update_workspace(); | ||
| } | ||
| save_project(filepath); |
There was a problem hiding this comment.
There is a regression here: if the user cancelled the Save As dialog, filepath is empty. It appears like this case is no longer handled correctly.
There was a problem hiding this comment.
I think there isn't
This check is in save_prject(): if (!filepath.isEmpty())
There was a problem hiding this comment.
But it isn't in update_recent_files_menu() if I'm not mistaken.
| // Destructor. | ||
| ~MainWindow(); | ||
|
|
||
| ProjectManager* get_project_manager(); |
| return PythonInterpreter::instance().get_main_window(); | ||
| } | ||
|
|
||
| ProjectManager* project_manager() { |
| return project_manager()->get_project(); | ||
| } | ||
|
|
||
| void save_project(const char* project_path = 0) |
There was a problem hiding this comment.
Prefer nullptr now that we're using C++11.
|
|
||
| void save_project(const char* project_path = 0) | ||
| { | ||
| if (project_path == 0) |
| namespace bf = boost::filesystem; | ||
|
|
||
| // Function prototypes. | ||
| extern "C" void init_appleseedstudio(); |
There was a problem hiding this comment.
Where is this function defined?
There was a problem hiding this comment.
it is generated by BOOST_PYTHON_MODULE(_appleseedstudio) in module.cpp
There was a problem hiding this comment.
Got it. Maybe worth adding a comment to explain this.
|
Almost there! I think you introduced a regression that needs to be fixed, apart from that I've made a handful of minor cosmetics/formatting remarks. Once this is fixed we can merge! |
…unction in python studio module
* Fix camera movement bug * Fix line endings * Fix issues -Use normalized camera direction -Simplify expressions -Cosmetics
CIE 1960 UCS was removed from the colorTransform node together with the uv related functions. The main purpose here was to get uv chromaticity coordinates from correlated color temperature, but we ended up using Klang (2002) CCT to xy method, which dispenses uv and UCS. HSL, HSV functions were cleaned up and deal correctly with corner cases. RGB->XYZ->RGB roundtrip, when no space change occurred, using only XYZ as an intermediary space for transforms, did incur precision loss which in some cases was enough to set a component as negative (imaginary color). In the case of HSV, HSL transformations, this resulted in a visible artifacts. In short, XYZ/RGB have lower bound restricted to 0.
6388b68 to
53f8638
Compare
Created new Python module with appleseed.studio specific binding such as:
open_project: opens project in UI by its pathsave_project: saves project that is currently opened in UInew_project: creates new project and shows it in UIcurrent_project: returns currently opened project as Project objectis_project_dirty: returns True if project is changed after last saveclose_project: closes project and cleans UI