Skip to content

Commit

Permalink
step 3
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouhang95 committed Apr 22, 2024
1 parent 9a4c07a commit f80d911
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
16 changes: 13 additions & 3 deletions ui/zenoedit/viewport/cameracontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ void CameraControl::fakeMousePressEvent(QMouseEvent *event)
if (event->button() == Qt::MiddleButton) {
middle_button_pressed = true;
}
auto m_picker = this->m_picker.lock();
auto m_transformer = this->m_transformer.lock();
if (scene->camera->m_need_sync) {
scene->camera->m_need_sync = false;
if (bool(m_picker) && scene->camera->m_auto_radius) {
this->m_picker->set_picked_depth_callback([&] (float depth, int x, int y) {
m_picker->set_picked_depth_callback([&] (float depth, int x, int y) {
if (depth < 0.001f) {
return;
}
Expand All @@ -133,7 +135,7 @@ void CameraControl::fakeMousePressEvent(QMouseEvent *event)
});
int mid_x = int(this->res().x() * 0.5);
int mid_y = int(this->res().y() * 0.5);
this->m_picker->pick_depth(mid_x, mid_y);
m_picker->pick_depth(mid_x, mid_y);
}
}
int button = Qt::NoButton;
Expand Down Expand Up @@ -227,13 +229,15 @@ void CameraControl::lookTo(int dir) {
}

void CameraControl::clearTransformer() {
auto m_transformer = this->m_transformer.lock();
if (!m_transformer)
return;
m_transformer->clear();
}

void CameraControl::changeTransformOperation(const QString &node)
{
auto m_transformer = this->m_transformer.lock();
if (!m_transformer)
return;

Expand All @@ -256,6 +260,7 @@ void CameraControl::changeTransformOperation(const QString &node)

void CameraControl::changeTransformOperation(int mode)
{
auto m_transformer = this->m_transformer.lock();
if (!m_transformer)
return;

Expand All @@ -270,6 +275,7 @@ void CameraControl::changeTransformOperation(int mode)

void CameraControl::changeTransformCoordSys()
{
auto m_transformer = this->m_transformer.lock();
if (!m_transformer)
return;
m_transformer->changeCoordSys();
Expand All @@ -278,6 +284,7 @@ void CameraControl::changeTransformCoordSys()

void CameraControl::resizeTransformHandler(int dir)
{
auto m_transformer = this->m_transformer.lock();
if (!m_transformer)
return;
m_transformer->resizeHandler(dir);
Expand All @@ -286,6 +293,7 @@ void CameraControl::resizeTransformHandler(int dir)

void CameraControl::fakeMouseMoveEvent(QMouseEvent *event)
{
auto m_transformer = this->m_transformer.lock();
bool ctrl_pressed = event->modifiers() & Qt::ControlModifier;
bool alt_pressed = event->modifiers() & Qt::AltModifier;

Expand Down Expand Up @@ -467,6 +475,7 @@ void CameraControl::fakeWheelEvent(QWheelEvent *event) {
void CameraControl::fakeMouseDoubleClickEvent(QMouseEvent *event)
{
auto pos = event->pos();
auto m_picker = this->m_picker.lock();
if (!m_picker)
return;
auto scene = m_zenovis->getSession()->get_scene();
Expand Down Expand Up @@ -580,7 +589,8 @@ void CameraControl::fakeMouseReleaseEvent(QMouseEvent *event) {
middle_button_pressed = false;
}
if (event->button() == Qt::LeftButton) {

auto m_transformer = this->m_transformer.lock();
auto m_picker = this->m_picker.lock();
//if (Zenovis::GetInstance().m_bAddPoint == true) {
//float x = (float)event->x() / m_res.x();
//float y = (float)event->y() / m_res.y();
Expand Down
4 changes: 2 additions & 2 deletions ui/zenoedit/viewport/cameracontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class CameraControl : public QObject
QVector2D m_res;
QSet<int> m_pressedKeys;

std::shared_ptr<zeno::Picker> m_picker;
std::shared_ptr<zeno::FakeTransformer> m_transformer;
std::weak_ptr<zeno::Picker> m_picker;
std::weak_ptr<zeno::FakeTransformer> m_transformer;
Zenovis* m_zenovis;

bool middle_button_pressed = false;
Expand Down
3 changes: 3 additions & 0 deletions ui/zenoedit/viewport/viewportwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ void ViewportWidget::cleanUpView()
{
if (m_zenovis)
m_zenovis->cleanupView();

m_picker = nullptr;
m_fakeTrans = nullptr;
}

namespace {
Expand Down
5 changes: 4 additions & 1 deletion zeno/src/utils/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ ZENO_API void __impl_log_print(log_level_t level, source_location const &loc, st
//*os << ansiclr::fg[make_array(ansiclr::white, ansiclr::cyan, ansiclr::green,
//ansiclr::cyan | ansiclr::light, ansiclr::yellow | ansiclr::light,
//ansiclr::red | ansiclr::light)[linlev]];
*os << format("[{} {02d}:{02d}:{02d}.{03d}] ({}:{}) {}\n",
auto content = format("[{} {02d}:{02d}:{02d}.{03d}] ({}:{}) {}\n",
"TDICWE"[linlev],
mss / 1000 / 60 / 60 % 24, mss / 1000 / 60 % 60,
mss / 1000 % 60, mss % 1000,
loc.file_name(), loc.line(),
msg);
//*os << ansiclr::reset;
*os << content;
os->flush();
if (level == log_level_t::error)
std::cerr << content;
}

namespace {
Expand Down

0 comments on commit f80d911

Please sign in to comment.