Skip to content

Commit 687d115

Browse files
committed
split tabs into multiple files (opengl and finalrender)
1 parent 553b4b6 commit 687d115

File tree

9 files changed

+401
-105
lines changed

9 files changed

+401
-105
lines changed

src/appleseed.studio/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ source_group ("mainwindow\\pythonconsole" FILES
252252
set (mainwindow_rendering_sources
253253
mainwindow/rendering/cameracontroller.cpp
254254
mainwindow/rendering/cameracontroller.h
255+
mainwindow/rendering/finalrenderviewporttab.cpp
256+
mainwindow/rendering/finalrenderviewporttab.h
255257
mainwindow/rendering/glscenelayer.cpp
256258
mainwindow/rendering/glscenelayer.h
257259
mainwindow/rendering/lightpathslayer.cpp
@@ -262,6 +264,8 @@ set (mainwindow_rendering_sources
262264
mainwindow/rendering/lightpathsviewportmanager.h
263265
mainwindow/rendering/materialdrophandler.cpp
264266
mainwindow/rendering/materialdrophandler.h
267+
mainwindow/rendering/openglviewporttab.cpp
268+
mainwindow/rendering/openglviewporttab.h
265269
mainwindow/rendering/pixelcolortracker.cpp
266270
mainwindow/rendering/pixelcolortracker.h
267271
mainwindow/rendering/pixelinspectorhandler.cpp

src/appleseed.studio/mainwindow/mainwindow.cpp

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
#include "mainwindow/project/attributeeditor.h"
4040
#include "mainwindow/project/projectexplorer.h"
4141
#include "mainwindow/pythonconsole/pythonconsolewidget.h"
42+
#include "mainwindow/rendering/finalrenderviewporttab.h"
4243
#include "mainwindow/rendering/materialdrophandler.h"
44+
#include "mainwindow/rendering/openglviewporttab.h"
4345
#include "mainwindow/rendering/renderlayer.h"
4446
#include "mainwindow/rendering/viewportwidget.h"
4547
#include "utility/settingskeys.h"
@@ -894,13 +896,16 @@ void MainWindow::set_rendering_widgets_enabled(const bool is_enabled, const Rend
894896
{
895897
ViewportTab* viewport_tab = viewport_tab_it->second;
896898

897-
// Clear frame.
898-
viewport_tab->set_clear_frame_button_enabled(
899-
is_enabled && is_project_open && rendering_mode == RenderingMode::NotRendering);
899+
if (viewport_tab == m_final_render_viewport_tab)
900+
{
901+
// Clear frame.
902+
m_final_render_viewport_tab->set_clear_frame_button_enabled(
903+
is_enabled && is_project_open && rendering_mode == RenderingMode::NotRendering);
900904

901-
// Set/clear rendering region.
902-
viewport_tab->set_render_region_buttons_enabled(
903-
is_enabled && is_project_open && rendering_mode != RenderingMode::FinalRendering);
905+
// Set/clear rendering region.
906+
m_final_render_viewport_tab->set_render_region_buttons_enabled(
907+
is_enabled && is_project_open && rendering_mode != RenderingMode::FinalRendering);
908+
}
904909

905910
// Scene picker.
906911
viewport_tab->get_scene_picking_handler()->set_enabled(
@@ -951,8 +956,30 @@ void MainWindow::recreate_viewport_tabs()
951956

952957
if (m_project_manager.is_project_open())
953958
{
954-
add_viewport_tab("Beauty", ViewportWidget::BaseLayer::FinalRender);
955-
add_viewport_tab("OpenGL", ViewportWidget::BaseLayer::OpenGL);
959+
// Create render tab.
960+
m_final_render_viewport_tab =
961+
new FinalRenderViewportTab(
962+
*m_project_explorer,
963+
*m_project_manager.get_project(),
964+
m_rendering_manager,
965+
m_ocio_config,
966+
m_application_settings);
967+
968+
connect(
969+
m_final_render_viewport_tab, SIGNAL(signal_set_render_region(const QRect&)),
970+
SLOT(slot_set_render_region(const QRect&)));
971+
972+
add_viewport_tab(m_final_render_viewport_tab, "Beauty");
973+
974+
// Create OpenGL tab.
975+
m_opengl_viewport_tab =
976+
new OpenGLViewportTab(
977+
*m_project_explorer,
978+
*m_project_manager.get_project(),
979+
m_rendering_manager,
980+
m_ocio_config,
981+
m_application_settings);
982+
add_viewport_tab(m_opengl_viewport_tab, "OpenGL");
956983
}
957984
}
958985

@@ -966,27 +993,17 @@ void MainWindow::remove_viewport_tabs()
966993

967994
while (m_ui->tab_render_channels->count() > 0)
968995
m_ui->tab_render_channels->removeTab(0);
996+
997+
m_final_render_viewport_tab = 0;
998+
m_opengl_viewport_tab = 0;
969999
}
9701000

971-
void MainWindow::add_viewport_tab(const QString& label, const ViewportWidget::BaseLayer base_layer)
1001+
void MainWindow::add_viewport_tab(ViewportTab* viewport_tab, const QString& label)
9721002
{
973-
// Create render tab.
974-
ViewportTab* viewport_tab =
975-
new ViewportTab(
976-
base_layer,
977-
*m_project_explorer,
978-
*m_project_manager.get_project(),
979-
m_rendering_manager,
980-
m_ocio_config,
981-
m_application_settings);
982-
983-
// Connect the render tab to the main window and the rendering manager.
1003+
// Connect the viewport tab to the main window and the rendering manager.
9841004
connect(
9851005
viewport_tab, SIGNAL(signal_viewport_widget_context_menu(const QPoint&)),
9861006
SLOT(slot_viewport_widget_context_menu(const QPoint&)));
987-
connect(
988-
viewport_tab, SIGNAL(signal_set_render_region(const QRect&)),
989-
SLOT(slot_set_render_region(const QRect&)));
9901007
connect(
9911008
viewport_tab, SIGNAL(signal_clear_render_region()),
9921009
SLOT(slot_clear_render_region()));
@@ -1015,7 +1032,7 @@ void MainWindow::add_viewport_tab(const QString& label, const ViewportWidget::Ba
10151032
viewport_tab, SIGNAL(signal_camera_changed()),
10161033
&m_rendering_manager, SLOT(slot_camera_changed()));
10171034

1018-
// Add the render tab to the tab bar.
1035+
// Add the viewport tab to the tab bar.
10191036
const int tab_index = m_ui->tab_render_channels->addTab(viewport_tab, label);
10201037

10211038
// Update mappings.
@@ -2054,9 +2071,7 @@ void MainWindow::slot_clear_frame()
20542071
// Clear all render widgets to black.
20552072
for (const std::pair<std::string, ViewportTab*>& kvp : m_viewport_tabs)
20562073
{
2057-
const auto viewport_widget = kvp.second->get_viewport_widget();
2058-
viewport_widget->get_render_layer()->clear();
2059-
viewport_widget->repaint();
2074+
kvp.second->clear();
20602075
}
20612076
}
20622077

src/appleseed.studio/mainwindow/mainwindow.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include "mainwindow/applicationsettingswindow.h"
3636
#include "mainwindow/falsecolorswindow.h"
3737
#include "mainwindow/rendering/renderingmanager.h"
38+
#include "mainwindow/rendering/finalrenderviewporttab.h"
39+
#include "mainwindow/rendering/openglviewporttab.h"
3840
#include "mainwindow/rendering/viewporttab.h"
3941
#include "mainwindow/renderingsettingswindow.h"
4042
#include "mainwindow/statusbar.h"
@@ -168,6 +170,9 @@ class MainWindow
168170
std::map<int, ViewportTab*> m_tab_index_to_viewport_tab;
169171
LightPathsTab* m_light_paths_tab;
170172

173+
FinalRenderViewportTab* m_final_render_viewport_tab;
174+
OpenGLViewportTab* m_opengl_viewport_tab;
175+
171176
struct StateBeforeProjectOpen
172177
{
173178
bool m_is_rendering;
@@ -210,7 +215,7 @@ class MainWindow
210215
// Render tabs.
211216
void recreate_viewport_tabs();
212217
void remove_viewport_tabs();
213-
void add_viewport_tab(const QString& label, const ViewportWidget::BaseLayer base_layer);
218+
void add_viewport_tab(ViewportTab* viewport_tab, const QString& label);
214219

215220
// Project file handling.
216221
renderer::ParamArray get_project_params(const char* configuration_name) const;
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
2+
//
3+
// This source file is part of appleseed.
4+
// Visit https://appleseedhq.net/ for additional information and resources.
5+
//
6+
// This software is released under the MIT license.
7+
//
8+
// Copyright (c) 2020 Kevin Masson, The appleseedhq Organization
9+
//
10+
// Permission is hereby granted, free of charge, to any person obtaining a copy
11+
// of this software and associated documentation files (the "Software"), to deal
12+
// in the Software without restriction, including without limitation the rights
13+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
// copies of the Software, and to permit persons to whom the Software is
15+
// furnished to do so, subject to the following conditions:
16+
//
17+
// The above copyright notice and this permission notice shall be included in
18+
// all copies or substantial portions of the Software.
19+
//
20+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26+
// THE SOFTWARE.
27+
//
28+
29+
// Interface header.
30+
#include "finalrenderviewporttab.h"
31+
32+
// appleseed.studio headers.
33+
#include "mainwindow/project/projectexplorer.h"
34+
#include "mainwindow/rendering/renderingmanager.h"
35+
36+
// appleseed.qtcommon headers.
37+
#include "utility/miscellaneous.h"
38+
39+
// Qt headers.
40+
#include <QToolBar>
41+
#include <QToolButton>
42+
43+
using namespace appleseed::qtcommon;
44+
using namespace foundation;
45+
using namespace renderer;
46+
namespace OCIO = OCIO_NAMESPACE;
47+
48+
namespace appleseed {
49+
namespace studio {
50+
51+
FinalRenderViewportTab::FinalRenderViewportTab(
52+
ProjectExplorer& project_explorer,
53+
Project& project,
54+
RenderingManager& rendering_manager,
55+
OCIO::ConstConfigRcPtr ocio_config,
56+
renderer::ParamArray application_settings)
57+
: ViewportTab(
58+
project_explorer,
59+
project,
60+
rendering_manager,
61+
ocio_config,
62+
application_settings)
63+
{
64+
get_viewport_widget()->set_base_layer(ViewportWidget::BaseLayer::FinalRender);
65+
66+
bool enable_camera_controller =
67+
m_rendering_manager.is_rendering()
68+
&& m_rendering_manager.get_rendering_mode() == RenderingManager::RenderingMode::InteractiveRendering;
69+
m_camera_controller.get()->set_enabled(enable_camera_controller);
70+
71+
create_toolbar();
72+
73+
get_viewport_widget()->update();
74+
}
75+
76+
void FinalRenderViewportTab::set_clear_frame_button_enabled(const bool enabled)
77+
{
78+
m_clear_frame_button->setEnabled(enabled);
79+
}
80+
81+
void FinalRenderViewportTab::set_render_region_buttons_enabled(const bool enabled)
82+
{
83+
m_set_render_region_button->setEnabled(enabled);
84+
m_clear_render_region_button->setEnabled(enabled);
85+
}
86+
87+
void FinalRenderViewportTab::update_size()
88+
{
89+
m_set_render_region_button->setChecked(false);
90+
91+
ViewportTab::update_size();
92+
}
93+
94+
void FinalRenderViewportTab::slot_set_render_region(const QRect& rect)
95+
{
96+
m_set_render_region_button->setChecked(false);
97+
emit signal_set_render_region(rect);
98+
}
99+
100+
void FinalRenderViewportTab::create_toolbar()
101+
{
102+
// Set Render Region button.
103+
m_set_render_region_button = new QToolButton();
104+
m_set_render_region_button->setIcon(load_icons("rendertab_set_render_region"));
105+
m_set_render_region_button->setShortcut(Qt::Key_R);
106+
m_set_render_region_button->setToolTip(combine_name_and_shortcut("Set Render Region", m_set_render_region_button->shortcut()));
107+
m_set_render_region_button->setCheckable(true);
108+
connect(
109+
m_set_render_region_button, SIGNAL(toggled(bool)),
110+
SLOT(slot_toggle_render_region(const bool)));
111+
m_toolbar->addWidget(m_set_render_region_button);
112+
113+
// Clear Render Region button.
114+
m_clear_render_region_button = new QToolButton();
115+
m_clear_render_region_button->setIcon(load_icons("rendertab_clear_render_region"));
116+
m_clear_render_region_button->setShortcut(Qt::Key_C);
117+
m_clear_render_region_button->setToolTip(combine_name_and_shortcut("Clear Render Region", m_clear_render_region_button->shortcut()));
118+
connect(
119+
m_clear_render_region_button, SIGNAL(clicked()),
120+
SIGNAL(signal_clear_render_region()));
121+
m_toolbar->addWidget(m_clear_render_region_button);
122+
123+
// Clear Frame button.
124+
m_clear_frame_button = new QToolButton();
125+
m_clear_frame_button->setIcon(load_icons("rendertab_clear_frame"));
126+
m_clear_frame_button->setShortcut(Qt::Key_X);
127+
m_clear_frame_button->setToolTip(combine_name_and_shortcut("Clear Frame", m_clear_frame_button->shortcut()));
128+
connect(
129+
m_clear_frame_button, SIGNAL(clicked()),
130+
SIGNAL(signal_clear_frame()));
131+
m_toolbar->addWidget(m_clear_frame_button);
132+
133+
m_toolbar->addSeparator();
134+
}
135+
136+
} // namespace studio
137+
} // namespace appleseed
138+
139+
#include "mainwindow/rendering/moc_cpp_finalrenderviewporttab.cxx"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
//
3+
// This source file is part of appleseed.
4+
// Visit https://appleseedhq.net/ for additional information and resources.
5+
//
6+
// This software is released under the MIT license.
7+
//
8+
// Copyright (c) 2020 Kevin Masson, The appleseedhq Organization
9+
//
10+
// Permission is hereby granted, free of charge, to any person obtaining a copy
11+
// of this software and associated documentation files (the "Software"), to deal
12+
// in the Software without restriction, including without limitation the rights
13+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
// copies of the Software, and to permit persons to whom the Software is
15+
// furnished to do so, subject to the following conditions:
16+
//
17+
// The above copyright notice and this permission notice shall be included in
18+
// all copies or substantial portions of the Software.
19+
//
20+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26+
// THE SOFTWARE.
27+
//
28+
29+
#pragma once
30+
31+
// appleseed.studio headers.
32+
#include "mainwindow/rendering/viewporttab.h"
33+
34+
// OpenColorIO headers.
35+
#include <OpenColorIO/OpenColorIO.h>
36+
namespace OCIO = OCIO_NAMESPACE;
37+
38+
// Forward declarations.
39+
namespace appleseed { namespace studio { class ProjectExplorer; } }
40+
namespace appleseed { namespace studio { class RenderingManager; } }
41+
namespace renderer { class Project; }
42+
class QToolButton;
43+
44+
namespace appleseed {
45+
namespace studio {
46+
47+
class FinalRenderViewportTab
48+
: public ViewportTab
49+
{
50+
Q_OBJECT
51+
52+
public:
53+
FinalRenderViewportTab(
54+
ProjectExplorer& project_explorer,
55+
renderer::Project& project,
56+
RenderingManager& rendering_manager,
57+
OCIO::ConstConfigRcPtr ocio_config,
58+
renderer::ParamArray application_settings);
59+
60+
void set_clear_frame_button_enabled(const bool enabled);
61+
void set_render_region_buttons_enabled(const bool enabled);
62+
63+
void update_size() override;
64+
65+
private slots:
66+
void slot_set_render_region(const QRect& rect);
67+
68+
private:
69+
QToolButton* m_set_render_region_button;
70+
QToolButton* m_clear_render_region_button;
71+
QToolButton* m_clear_frame_button;
72+
73+
void create_toolbar();
74+
};
75+
76+
} // namespace studio
77+
} // namespace appleseed

0 commit comments

Comments
 (0)