Merged in opentoonz master to resolve conflicts

This commit is contained in:
manongjohn 2019-08-09 21:06:14 -04:00
commit 825aea606b
133 changed files with 3887 additions and 1341 deletions

View file

@ -3,8 +3,10 @@ pushd thirdparty/tiff-4.0.3
./configure && make
popd
cd toonz && mkdir build && cd build
QTVERSION=`ls /usr/local/Cellar/qt`
echo "QT Version detected: $QTVERSION"
cmake ../sources \
-DQT_PATH=/usr/local/Cellar/qt/5.12.2/lib/ \
-DQT_PATH=/usr/local/Cellar/qt/$QTVERSION/lib/ \
-DTIFF_INCLUDE_DIR=../../thirdparty/tiff-4.0.3/libtiff/ \
-DSUPERLU_INCLUDE_DIR=../../thirdparty/superlu/SuperLU_4.1/include/
make -j 2

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -22,7 +22,7 @@ PencilTestPopup {
}
#LargeSizedText {
font-size: 17;
font-size: 17px;
}
/* -----------------------------------------------------------------------------

View file

@ -46,7 +46,7 @@ QDialog {
background-color: @prefs-tree-bg-color;
alternate-background-color: @prefs-tree-bg-color;
border: 1 solid @accent;
font-size: 13;
font-size: 13px;
&::item {
border: 0; // remove indent on hover
padding: 3;

File diff suppressed because one or more lines are too long

View file

@ -203,7 +203,7 @@ elseif(BUILD_ENV_UNIXLIKE)
find_package(Qt5Widgets)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -lstdc++ -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++ -std=c++11")
endif()
add_definitions(

View file

@ -101,8 +101,7 @@ void Tokenizer::setBuffer(std::string buffer) {
const std::string ss[] = {"==", "!=", ">=", "<=", "||", "&&"};
const int m = tArrayCount(ss);
if (std::find(ss, ss + m, token) != ss + m)
if (std::find(std::begin(ss), std::end(ss), token) != std::end(ss))
i += 2;
else
token = std::string(1, s[i++]);
@ -167,4 +166,4 @@ Token Tokenizer::getTokenFromPos(int pos) const {
//===================================================================
} // TSyntax
} // namespace TSyntax

View file

@ -492,6 +492,9 @@ void TMacroFx::loadData(TIStream &is) {
m_fxs.push_back(fx);
}
}
// collecting params just after loading nodes since they may need on
// loading "super" tag in case it is linked with another macro fx
collectParams(this);
} else if (tagName == "ports") {
int i = 0;
while (is.matchTag(tagName)) {
@ -533,7 +536,6 @@ void TMacroFx::loadData(TIStream &is) {
throw TException("unexpected tag " + tagName);
is.closeChild();
}
collectParams(this);
}
//--------------------------------------------------

View file

@ -312,21 +312,6 @@ public:
return result;
}
Iterator find(const RowKey &r, const ColKey &c) {
Iterator result(this);
result.m_rowIt = m_table.find(r);
if (result.m_rowIt == m_table.end()) return;
result.m_it = result.m_rowIt->second.find(c);
if (result.m_it == result.m_rowIt->second.end())
result.m_rowIt = m_table.end();
return result;
}
Iterator erase(const RowKey &r, const ColKey &c) {
Iterator it(find(r, c));
return erase(it);
}
Iterator erase(const Iterator &it) {
Iterator result(it);
Row &row = it.m_rowIt->second;

View file

@ -135,7 +135,7 @@ const int TAG_IMAGE_UNIQUE_ID = 0xA420;
typedef struct {
unsigned short Tag;
char *Desc;
const char *Desc;
} TagTable_t;
const TagTable_t TagTable[] = {
@ -253,7 +253,7 @@ const int TAG_TABLE_SIZE = (sizeof(TagTable) / sizeof(TagTable_t));
const int TRUE = 1;
const int FALSE = 0;
}
} // namespace
//--------------------------------------------------------------------------
// Convert a 16 bit unsigned value from file's native byte order
@ -633,7 +633,7 @@ void JpgExifReader::ProcessExifDir(unsigned char *DirStart,
break;
case FMT_UNDEFINED:
// Undefined is typically an ascii string.
// Undefined is typically an ascii string.
case FMT_STRING:
// String arrays printed without function call (different from int
@ -683,7 +683,7 @@ void JpgExifReader::ProcessExifDir(unsigned char *DirStart,
case TAG_DATETIME_ORIGINAL:
// If we get a DATETIME_ORIGINAL, we use that one.
strncpy(ImageInfo.DateTime, (char *)ValuePtr, 19);
// Fallthru...
// Fallthru...
case TAG_DATETIME_DIGITIZED:
case TAG_DATETIME:
@ -737,7 +737,7 @@ void JpgExifReader::ProcessExifDir(unsigned char *DirStart,
// Copy the comment
{
int msiz = ExifLength - (ValuePtr - OffsetBase);
int msiz = ExifLength - (ValuePtr - OffsetBase);
if (msiz > ByteCount) msiz = ByteCount;
if (msiz > MAX_COMMENT_SIZE - 1) msiz = MAX_COMMENT_SIZE - 1;
if (msiz > 5 && memcmp(ValuePtr, "ASCII", 5) == 0) {

View file

@ -126,11 +126,11 @@ void TSpectrumParam::removeObserver(TParamObserver *obs) {
//---------------------------------------------------------
TSpectrumParam::TSpectrumParam(int keyCount, TSpectrum::ColorKey keys[])
TSpectrumParam::TSpectrumParam(std::vector<TSpectrum::ColorKey> const &keys)
: m_imp(new TSpectrumParamImp(this)) {
for (int i = 0; i < keyCount; i++) {
double v = keys[i].first;
TPixel32 pix = keys[i].second;
for (auto const &key : keys) {
double v = key.first;
TPixel32 pix = key.second;
TDoubleParamP dp(v);
TPixelParamP pp(pix);
pp->enableMatte(m_imp->m_isMatteEnabled);

View file

@ -135,7 +135,7 @@ void drawControlPoints(const TVectorRenderData &rd, TStroke *stroke,
//-----------------------------------------------------------------------------
void drawArrows(TStroke *stroke, bool onlyFirstPoint) {
static void drawArrows(TStroke *stroke, bool onlyFirstPoint) {
double length = stroke->getLength(0.0, 1.0);
int points = length / 20;
if (points < 2) points += 1;
@ -179,7 +179,8 @@ void drawArrows(TStroke *stroke, bool onlyFirstPoint) {
//-----------------------------------------------------------------------------
// Used for Guided Drawing
void drawFirstControlPoint(const TVectorRenderData &rd, TStroke *stroke) {
static void drawFirstControlPoint(const TVectorRenderData &rd,
TStroke *stroke) {
TPointD p = stroke->getPoint(0.0);
double length = stroke->getLength(0.0, 1.0);
int msecs = QTime::currentTime().msec();
@ -276,8 +277,8 @@ void tglDraw(const TVectorRenderData &rd, TRegion *r, bool pushAttribs) {
} else {
visible = false;
for (j = 0; j < colorCount && !visible; j++) {
TPixel32 color = style->getColorParamValue(j);
if (rd.m_cf) color = (*(rd.m_cf))(color);
TPixel32 color = style->getColorParamValue(j);
if (rd.m_cf) color = (*(rd.m_cf))(color);
if (color.m != 0) visible = true;
}
}
@ -434,7 +435,7 @@ bool isOThick(const TStroke *s) {
if (s->getControlPoint(i).thick != 0) return false;
return true;
}
}
} // namespace
void tglDraw(const TVectorRenderData &rd, const TStroke *s, bool pushAttribs) {
assert(s);
@ -554,8 +555,8 @@ static void tglDoDraw(const TVectorRenderData &rd, TRegion *r) {
else {
visible = false;
for (int j = 0; j < colorCount && !visible; j++) {
TPixel32 color = style->getColorParamValue(j);
if (rd.m_cf) color = (*(rd.m_cf))(color);
TPixel32 color = style->getColorParamValue(j);
if (rd.m_cf) color = (*(rd.m_cf))(color);
if (color.m != 0) visible = true;
}
}
@ -584,8 +585,8 @@ static bool tglDoDraw(const TVectorRenderData &rd, const TStroke *s) {
else {
visible = false;
for (int j = 0; j < style->getColorParamCount() && !visible; j++) {
TPixel32 color = style->getColorParamValue(j);
if (rd.m_cf) color = (*(rd.m_cf))(color);
TPixel32 color = style->getColorParamValue(j);
if (rd.m_cf) color = (*(rd.m_cf))(color);
if (color.m != 0) visible = true;
}
}
@ -676,7 +677,7 @@ rdRegions.m_alphaChannel = rdRegions.m_antiAliasing = false;*/
}
}
}
}
} // namespace
//------------------------------------------------------------------------------------

View file

@ -193,7 +193,8 @@ TPalette::TPalette()
, m_mutex(QMutex::Recursive)
, m_isLocked(false)
, m_askOverwriteFlag(false)
, m_shortcutScopeIndex(0) {
, m_shortcutScopeIndex(0)
, m_currentStyleId(1) {
QString tempName(QObject::tr("colors"));
std::wstring pageName = tempName.toStdWString();
Page *page = addPage(pageName);

View file

@ -4,6 +4,8 @@
extern "C" {
#endif
#include "ttwain_statePD.h"
int TTWAIN_LoadSourceManagerPD(void) { return 0; }
int TTWAIN_UnloadSourceManagerPD(void) { return 1; }

View file

@ -168,8 +168,6 @@ inline std::ostream &operator<<(std::ostream &out, const std::string &s) {
return out << s.c_str();
}
#define tArrayCount(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0]))
const std::string styleNameEasyInputWordsFileName = "stylename_easyinput.ini";
#endif //__T_COMMON_INCLUDED

View file

@ -5,6 +5,7 @@
#include "tgeometry.h"
#include <QStack>
#include <QList>
#undef DVAPI
#undef DVVAR

View file

@ -474,6 +474,21 @@ protected slots:
void onColorModeChanged(int);
};
//=============================================================================
//
// FullColorFillToolOptionsBox
//
//=============================================================================
class FullColorFillToolOptionsBox final : public ToolOptionsBox {
Q_OBJECT
public:
FullColorFillToolOptionsBox(QWidget *parent, TTool *tool,
TPaletteHandle *pltHandle,
ToolHandle *toolHandle);
};
//=============================================================================
//
// FillToolOptionsBox
@ -700,6 +715,48 @@ protected slots:
void updateColors();
};
//=============================================================================
//
// ZoomToolOptionsBox
//
//=============================================================================
class ZoomToolOptionsBox final : public ToolOptionsBox {
Q_OBJECT
public:
ZoomToolOptionsBox(QWidget *parent, TTool *tool, TPaletteHandle *pltHandle,
ToolHandle *toolHandle);
};
//=============================================================================
//
// RotateToolOptionsBox
//
//=============================================================================
class RotateToolOptionsBox final : public ToolOptionsBox {
Q_OBJECT
public:
RotateToolOptionsBox(QWidget *parent, TTool *tool, TPaletteHandle *pltHandle,
ToolHandle *toolHandle);
};
//=============================================================================
//
// HandToolOptionsBox
//
//=============================================================================
class HandToolOptionsBox final : public ToolOptionsBox {
Q_OBJECT
public:
HandToolOptionsBox(QWidget *parent, TTool *tool, TPaletteHandle *pltHandle,
ToolHandle *toolHandle);
};
//-----------------------------------------------------------------------------
class DVAPI ToolOptions final : public QFrame {

View file

@ -18,6 +18,7 @@
#endif
class KeyframesUndo;
class TSceneHandle;
class DVAPI KeyframeSetter {
TDoubleParamP m_param;
@ -101,7 +102,8 @@ public:
}
static void removeKeyframeAt(TDoubleParam *curve, double frame);
static void enableCycle(TDoubleParam *curve, bool enabled);
static void enableCycle(TDoubleParam *curve, bool enabled,
TSceneHandle *sceneHandle = nullptr);
};
#endif

View file

@ -81,6 +81,9 @@ void DVAPI rectFillInk(const TRasterCM32P &ras, const TRect &r, int color);
void DVAPI fillautoInks(TRasterCM32P &r, TRect &rect,
const TRasterCM32P &rbefore, TPalette *plt);
void DVAPI fullColorFill(const TRaster32P &ras, const FillParameters &params,
TTileSaverFullColor *saver = 0);
//=============================================================================
//! The class AreaFiller allows to fill a raster area, delimited by rect or
//! spline.

View file

@ -49,7 +49,8 @@ public:
// Current Palette (PaletteController) methods
virtual TColorStyle *getCurrentLevelStyle() const = 0;
virtual int getCurrentLevelStyleIndex() const = 0;
virtual void setCurrentLevelStyleIndex(int index) = 0;
virtual void setCurrentLevelStyleIndex(int index,
bool forceUpdate = false) = 0;
};
#endif // TAPPLICATION_H

View file

@ -44,7 +44,7 @@ public:
TColorStyle *getStyle() const;
void setPalette(TPalette *palette, int styleIndex = 1);
void setPalette(TPalette *palette, int styleIndex = -1);
void setStyleIndex(int index, bool forceEmit = false);

View file

@ -146,6 +146,7 @@ public:
void add(const TRasterP &ras, TRect rect) override;
const Tile *getTile(int index) const;
Tile *editTile(int index) const;
TTileSetFullColor *clone() const override;
};

View file

@ -170,7 +170,6 @@ protected:
class DVAPI Dialog : public QDialog {
Q_OBJECT
static QSettings *m_settings;
// If the dialog has button then is modal too.
bool m_hasButton;
QString m_name;
@ -183,7 +182,6 @@ protected:
QHBoxLayout *m_buttonLayout;
QList<QLabel *> m_labelList;
void resizeEvent(QResizeEvent *e) override;
void moveEvent(QMoveEvent *e) override;
public:
QVBoxLayout *m_topLayout;

View file

@ -3,6 +3,7 @@
#ifndef FUNCTION_SEGMENT_VIEWER_H
#define FUNCTION_SEGMENT_VIEWER_H
#include <array>
#include <QLabel>
#include <QComboBox>
@ -31,7 +32,7 @@ namespace DVGui {
class MeasuredDoubleLineEdit;
class ExpressionField;
class FileField;
}
} // namespace DVGui
//-----------------------------------------------------------------------------
@ -51,8 +52,8 @@ class FunctionSegmentViewer final : public QFrame, public TParamObserver {
DVGui::LineEdit *m_stepFld;
QStackedWidget *m_parametersPanel;
FunctionSegmentPage *m_pages[9];
int m_typeId[9];
std::array<FunctionSegmentPage *, 9> m_pages;
std::array<int, 9> m_typeId;
FunctionSheet *m_sheet;
TXsheetHandle *m_xshHandle;

View file

@ -124,6 +124,11 @@ public:
int getColumnIndexByCurve(TDoubleParam *param) const;
bool anyWidgetHasFocus();
// Obtains a pointer to the stage object containing the
// parameter of specified column. Returns nullptr for
// fx parameter columns.
TStageObject *getStageObject(int column);
protected:
void showEvent(QShowEvent *e) override;
void hideEvent(QHideEvent *e) override;

View file

@ -336,6 +336,31 @@ public:
void refresh() override;
};
//=============================================================================
class StageObjectChannelGroup final : public FunctionTreeModel::ChannelGroup {
public:
TStageObject *m_stageObject; //!< (not owned) Referenced stage object
FunctionTreeModel::ChannelGroup
*m_plasticGroup; //!< (not owned) Eventual plastic channels group
public:
StageObjectChannelGroup(TStageObject *pegbar);
~StageObjectChannelGroup();
QString getShortName() const override;
QString getLongName() const override;
QString getIdName() const override;
void *getInternalPointer() const override {
return static_cast<void *>(m_stageObject);
}
TStageObject *getStageObject() const { return m_stageObject; }
QVariant data(int role) const override;
};
//*****************************************************************************************
// FunctionTreeView declaration
//*****************************************************************************************

View file

@ -120,6 +120,8 @@ public:
void clearFocusColumnsAndGraph();
bool columnsOrGraphHasFocus();
void setSceneHandle(TSceneHandle *sceneHandle);
TSceneHandle *getSceneHandle() const { return m_sceneHandle; }
// SaveLoadQSettings
virtual void save(QSettings &settings) const override;
virtual void load(QSettings &settings) override;

View file

@ -365,6 +365,7 @@ public:
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
};
//*****************************************************
@ -384,6 +385,7 @@ public:
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
};
//*****************************************************
@ -408,6 +410,7 @@ public:
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
protected slots:
@ -441,6 +444,7 @@ public:
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
protected slots:
@ -479,6 +483,7 @@ public:
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
private:
void renameObject(const TStageObjectId &id, std::string name);
@ -517,6 +522,7 @@ public:
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
protected slots:
@ -575,6 +581,7 @@ public:
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
QPointF computePos() const;
protected slots:

View file

@ -190,6 +190,7 @@ class DVAPI ParamViewer final : public QFrame {
Q_OBJECT
TFxP m_fx;
TFxP m_actualFx;
QStackedWidget *m_tablePageSet;
QMap<std::string, int> m_tableFxIndex;
@ -253,6 +254,7 @@ class DVAPI FxSettings final : public QSplitter {
bool m_isCameraModeView;
int m_container_height;
int m_container_width;
public:
FxSettings(QWidget *parent, const TPixel32 &checkCol1,

View file

@ -101,7 +101,7 @@ void DVAPI convert(
false /*-- ConvertPopup
[].[].[]
[][] --*/
); //!< Converts a saved level to fullcolor, and saves the result.
); //!< Converts a saved level to fullcolor, and saves the result.
void DVAPI convertNaa2Tlv(
const TFilePath &source, //!< Level path to convert from.
@ -124,7 +124,7 @@ void DVAPI convertOldLevel2Tlv(
const TFrameId &to, //!< Last source frame to convert.
FrameTaskNotifier
*frameNotifier //!< Observer class for frame success notifications.
);
);
double DVAPI getQuantizedZoomFactor(double zf, bool forward);
@ -140,8 +140,9 @@ void DVAPI assignFillingInformation(TVectorImage &vi,
const std::vector<TFilledRegionInf> &regs);
void DVAPI getStrokeStyleInformationInArea(
const TVectorImageP &vi, std::vector<std::pair<int, int>>
&strokesInfo, // pair:strokeIndex, styleIndex
const TVectorImageP &vi,
std::vector<std::pair<int, int>>
&strokesInfo, // pair:strokeIndex, styleIndex
const TRectD &area);
//*********************************************************************************************
@ -221,7 +222,7 @@ public:
protected:
virtual bool zoom(
bool zoomin,
bool resetZoom) = 0; //!< Handler for zoom commands. Required.
bool resetView) = 0; //!< Handler for zoom commands. Required.
virtual bool fit() {
return false;
} //!< Handler for 'fit to image' commands.
@ -234,6 +235,15 @@ protected:
virtual bool setFlipY() {
return false;
} //!< Handler for 'flip viewer horizontally' commands.
virtual bool resetZoom() {
return false;
} //!< Handler for 'reset zoom' commands.
virtual bool resetRotation() {
return false;
} //!< Handler for 'reset rotation' commands.
virtual bool resetPosition() {
return false;
} //!< Handler for 'reset position' commands.
virtual bool toggleFullScreen(
bool quit = false) //! Handler for 'toggle fullscreen' commands.
{

View file

@ -60,7 +60,8 @@ enum CommandType {
ToolModifierCommandType,
ZoomCommandType,
MiscCommandType,
MenuCommandType
MenuCommandType,
VisualizationButtonCommandType
};
//-----------------------------------------------------------------------------

View file

@ -162,6 +162,8 @@ protected slots:
void onNameDisplayMode(QAction *);
void setIsLocked(bool lock);
void onSwitchToPage(int pageIndex);
};
#endif // PALETTEVIEWER_H

View file

@ -211,6 +211,7 @@ private:
signals:
void changeWindowTitleSignal();
void switchToPage(int);
};
//****************************************************************************

View file

@ -13,6 +13,7 @@
// Qt includes
#include <QOpenGLWidget>
#include <QTouchDevice>
#undef DVAPI
#undef DVVAR
@ -30,6 +31,8 @@
class TRasterImageP;
class TToonzImageP;
class TVectorImageP;
class QTouchEvent;
class QGestureEvent;
//----------------------------------------------------------------------------
@ -61,6 +64,18 @@ obsolete class until the shader fx being overhauled. 2016/6/22 Shun
*/
class DVAPI PlaneViewer : public GLWidgetForHighDpi {
Q_OBJECT
bool m_touchActive = false;
bool m_gestureActive = false;
QTouchDevice::DeviceType m_touchDevice = QTouchDevice::TouchScreen;
bool m_zooming = false;
bool m_panning = false;
double m_scaleFactor; // used for zoom gesture
bool m_stylusUsed = false;
bool m_firstDraw;
public:
PlaneViewer(QWidget *parent);
@ -99,8 +114,6 @@ public:
TAffine &viewAff() { return m_aff; }
const TAffine &viewAff() const { return m_aff; }
void resetView();
void zoomIn();
void zoomOut();
@ -123,6 +136,11 @@ public:
TRaster32P rasterBuffer();
void flushRasterBuffer();
public slots:
void resetView();
void fitView();
protected:
int m_xpos, m_ypos; //!< Mouse position on mouse operations.
TAffine m_aff; //!< Affine transform from world to widget coords.
@ -135,13 +153,25 @@ protected:
double m_zoomRange[2]; //!< Viewport zoom range (default: [-1024, 1024]).
TRect m_imageBounds;
double m_dpiX, m_dpiY;
protected:
virtual void contextMenuEvent(QContextMenuEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override;
virtual void wheelEvent(QWheelEvent *event) override;
virtual void keyPressEvent(QKeyEvent *event) override;
virtual void hideEvent(QHideEvent *event) override;
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
virtual void tabletEvent(QTabletEvent *e) override;
void touchEvent(QTouchEvent *e, int type);
void gestureEvent(QGestureEvent *e);
virtual bool event(QEvent *e) override;
void initializeGL() override final;
void resizeGL(int width, int height) override final;
@ -150,6 +180,7 @@ private:
bool m_firstResize;
int m_width;
int m_height;
QPointF m_firstPanPoint;
};
#endif // PLANE_VIEWER_H

View file

@ -106,7 +106,7 @@ public:
SchematicSceneViewer(QWidget *parent);
~SchematicSceneViewer();
void zoomQt(bool zoomin, bool resetZoom);
void zoomQt(bool zoomin, bool resetView);
QPointF getOldScenePos() { return m_oldScenePos; }
@ -120,10 +120,13 @@ protected:
protected slots:
void fitScene();
void centerOnCurrent();
void reorderScene();
public slots:
void normalizeScene();
void fitScene();
private:
Qt::MouseButton m_buttonState;

View file

@ -16,6 +16,8 @@
#include "tthread.h"
#include "trop.h"
#include <QTouchDevice>
using namespace TThread;
#undef DVAPI
@ -28,6 +30,13 @@ using namespace TThread;
#define DVVAR DV_IMPORT_VAR
#endif
//-----------------------------------------------------------------------------
// Forward declarations
class QTouchEvent;
class QGestureEvent;
//=============================================================================
class DVAPI BgPainter {
@ -113,6 +122,7 @@ class DVAPI SwatchViewer final : public QWidget {
TPointD m_pointPosDelta;
bool m_enabled;
bool m_firstEnabled;
int m_frame;
TThread::Executor m_executor;
TThread::Mutex m_mutex;
@ -129,6 +139,15 @@ class DVAPI SwatchViewer final : public QWidget {
bool m_computing;
bool m_touchActive = false;
bool m_gestureActive = false;
QTouchDevice::DeviceType m_touchDevice = QTouchDevice::TouchScreen;
bool m_zooming = false;
bool m_panning = false;
double m_scaleFactor; // used for zoom gesture
bool m_stylusUsed = false;
friend class ContentRender;
public:
@ -179,6 +198,8 @@ public slots:
void setEnable(bool enabled);
void updateSize(const QSize &size);
void setBgPainter(TPixel32 color1, TPixel32 color2 = TPixel32());
void resetView();
void fitView();
protected:
void computeContent();
@ -186,6 +207,7 @@ protected:
TPointD win2world(const TPoint &p) const;
void zoom(const TPoint &pos, double factor);
void zoom(bool forward, bool reset);
void pan(const TPoint &delta);
void updateRaster();
@ -194,6 +216,7 @@ protected:
void setAff(const TAffine &aff);
void contextMenuEvent(QContextMenuEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
@ -203,6 +226,15 @@ protected:
void resizeEvent(QResizeEvent *event) override;
void hideEvent(QHideEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void tabletEvent(QTabletEvent *e) override;
void touchEvent(QTouchEvent *e, int type);
void gestureEvent(QGestureEvent *e);
bool event(QEvent *e) override;
private:
QPointF m_firstPanPoint;
signals:
void pointPositionChanged(int index, const TPointD &p);
};

View file

@ -3,6 +3,7 @@
#ifndef VIEWCOMMANDIDS_H
#define VIEWCOMMANDIDS_H
#define V_ViewReset "T_ViewReset"
#define V_ZoomIn "T_Zoomin" // Can't change prefix due to retrocompatibility
#define V_ZoomOut "T_Zoomout"
#define V_ZoomReset "T_ZoomReset"
@ -11,5 +12,17 @@
#define V_ActualPixelSize "T_ActualPixelSize"
#define V_FlipX "T_FlipX"
#define V_FlipY "T_FlipY"
#define V_RotateReset "T_RotateReset"
#define V_PositionReset "T_PositionReset"
// folloing command ids are for command bar
#define VB_ViewReset "VB_ViewReset"
#define VB_ZoomFit "VB_ZoomFit"
#define VB_ZoomReset "VB_ZoomReset"
#define VB_RotateReset "VB_RotateReset"
#define VB_PositionReset "VB_PositionReset"
#define VB_ActualPixelSize "VB_ActualPixelSize"
#define VB_FlipX "VB_FlipX"
#define VB_FlipY "VB_FlipY"
#endif // VIEWCOMMANDIDS_H

View file

@ -132,13 +132,13 @@ public:
//! \return The insertion index in the page, or \p -1 on failure
int addStyle(int styleId); //!< Adds the specified style Id to the page (at
//! the \a back
//! of the page).
/*!
\warning The supplied style must have been allocated with \a new.
\warning Style ownership is surrendered to the palette.
\return The insertion index in the page, or \p -1 on failure.
In case of failure, the supplied style is \a deleted.
*/
//! of the page).
/*!
\warning The supplied style must have been allocated with \a new.
\warning Style ownership is surrendered to the palette.
\return The insertion index in the page, or \p -1 on failure.
In case of failure, the supplied style is \a deleted.
*/
int addStyle(TColorStyle *style); //!< Adds the specified style to the
//! palette, and assigns it
//! to this page.
@ -214,6 +214,8 @@ private:
int m_shortcutScopeIndex;
int m_currentStyleId;
public:
TPalette();
~TPalette();
@ -425,6 +427,9 @@ between RGBA color components.
void nextShortcutScope(bool invert);
void setCurrentStyleId(int id) { m_currentStyleId = id; }
int getCurrentStyleId() const { return m_currentStyleId; }
public:
// Deprecated functions

View file

@ -42,7 +42,7 @@ class DVAPI TSpectrumParam final : public TParam {
public:
TSpectrumParam();
TSpectrumParam(int keyCount, TSpectrum::ColorKey keys[]);
TSpectrumParam(std::vector<TSpectrum::ColorKey> const &keys);
TSpectrumParam(const TSpectrumParam &);
~TSpectrumParam();
@ -102,9 +102,9 @@ class DVAPI TSpectrumParamP final
: public TDerivedSmartPointerT<TSpectrumParam, TParam> {
public:
TSpectrumParamP() {}
TSpectrumParamP(int keyCount, TSpectrum::ColorKey keys[])
TSpectrumParamP(std::vector<TSpectrum::ColorKey> const &keys)
: TDerivedSmartPointerT<TSpectrumParam, TParam>(
new TSpectrumParam(keyCount, keys)) {}
new TSpectrumParam(keys)) {}
TSpectrumParamP(TSpectrumParam *p)
: TDerivedSmartPointerT<TSpectrumParam, TParam>(p) {}
TSpectrumParamP(const TParamP &p)

View file

@ -28,10 +28,10 @@ public:
bindParam(this, "min", m_min);
bindParam(this, "max", m_max);
bindParam(this, "evolution", m_evol);
TSpectrum::ColorKey colors[] = {
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(1, TPixel32::Transparent)};
m_colors = TSpectrumParamP(tArrayCount(colors), colors);
m_colors = TSpectrumParamP(colors);
bindParam(this, "colors", m_colors);
m_size->setValueRange(0, 200);
m_min->setValueRange(0, 1.0);
@ -57,15 +57,15 @@ public:
//==================================================================
void CloudsFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri) {
double scale = sqrt(fabs(ri.m_affine.det()));
int type = m_type->getValue();
double min = m_min->getValue(frame);
double max = m_max->getValue(frame);
double evolution = m_evol->getValue(frame);
double size = m_size->getValue(frame) / ri.m_shrinkX;
size = fabs(size);
double scale = sqrt(fabs(ri.m_affine.det()));
int type = m_type->getValue();
double min = m_min->getValue(frame);
double max = m_max->getValue(frame);
double evolution = m_evol->getValue(frame);
double size = m_size->getValue(frame) / ri.m_shrinkX;
size = fabs(size);
if (size < 0.01) size = 0.01;
TPointD pos = tile.m_pos;
TPointD pos = tile.m_pos;
doClouds(tile.getRaster(), m_colors, pos, evolution, size, min, max, type,
scale, frame);

View file

@ -13,13 +13,14 @@ class DiamondGradientFx final : public TStandardZeraryFx {
public:
DiamondGradientFx() : m_size(100.0) {
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.2, TPixel32::Yellow),
TSpectrum::ColorKey(0.4, TPixel32::Blue),
TSpectrum::ColorKey(0.6, TPixel32::Green),
TSpectrum::ColorKey(0.8, TPixel32::Magenta),
TSpectrum::ColorKey(1, TPixel32::Red)};
m_colors = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.2, TPixel32::Yellow),
TSpectrum::ColorKey(0.4, TPixel32::Blue),
TSpectrum::ColorKey(0.6, TPixel32::Green),
TSpectrum::ColorKey(0.8, TPixel32::Magenta),
TSpectrum::ColorKey(1, TPixel32::Red)};
m_colors = TSpectrumParamP(colors);
m_size->setMeasureName("fxLength");
bindParam(this, "colors", m_colors);
bindParam(this, "size", m_size);

View file

@ -25,14 +25,16 @@ typedef int int32_t;
extern "C" {
#endif
/*
extern void pri_funct_cv_start(int32_t i32_ys);
extern void pri_funct_cv_run(int32_t i32_y);
extern void pri_funct_cv_end(void);
extern void pri_funct_set_cp_title(const char *cp_title);
extern void pri_funct_msg_ttvr(const char *fmt, ...);
extern void pri_funct_msg_vr(const char *fmt, ...);
extern void pri_funct_err_bttvr(const char *fmt, ...);
extern void pri_funct_msg_ttvr(const char* fmt, ...);
extern void pri_funct_msg_vr(const char* fmt, ...);
extern void pri_funct_err_bttvr(const char* fmt, ...);
*/
#ifdef __cplusplus
}
@ -1046,7 +1048,7 @@ double calculator_geometry::get_d_radian(double d_xv, double d_yv) {
}
/* 第2象限 (第1象限に置き換えて... 0 <= angle < 90) */
else if ((d_xv <= 0.0) && (0.0 < d_yv)) {
d_radian = atan(-d_xv / d_yv) + M_PI_2;
d_radian = atan(-d_xv / d_yv) + M_PI / 2.0;
}
/* 第3象限 (第1象限に置き換えて... 0 <= angle < 90) */
else if ((d_xv < 0.0) && (d_yv <= 0.0)) {
@ -1054,7 +1056,7 @@ double calculator_geometry::get_d_radian(double d_xv, double d_yv) {
}
/* 第4象限 (第1象限に置き換えて... 0 <= angle < 90) */
else if ((0.0 <= d_xv) && (d_yv < 0.0)) {
d_radian = atan(d_xv / -d_yv) + M_PI + M_PI_2;
d_radian = atan(d_xv / -d_yv) + M_PI + M_PI / 2.0;
}
return d_radian;
}
@ -1712,11 +1714,10 @@ int pixel_line_node::expand_line(pixel_point_root *clp_pixel_point_root) {
/* 始点が端点ならば先へ伸ばす */
i32_body_point_count = this->_i32_point_count;
if (NULL == clp_one->get_clp_link_near(1)) { /* 2点目がないなら端点 */
if (OK !=
this->_expand_line_from_one(clp_pixel_point_root, i32_body_point_count,
this->get_clp_link_one(),
this->get_clp_link_another(),
d_radian_one)) {
if (OK != this->_expand_line_from_one(
clp_pixel_point_root, i32_body_point_count,
this->get_clp_link_one(), this->get_clp_link_another(),
d_radian_one)) {
pri_funct_err_bttvr(
"Error : this->_expand_line_from_one(-) returns NULL.");
return NG;
@ -1725,11 +1726,10 @@ int pixel_line_node::expand_line(pixel_point_root *clp_pixel_point_root) {
/* 終点が端点ならば先へ伸ばす */
if (NULL == clp_another->get_clp_link_near(1)) { /* 2点目がないなら端点 */
if (OK !=
this->_expand_line_from_another(
clp_pixel_point_root, i32_body_point_count,
this->get_clp_link_one(), this->get_clp_link_another(),
d_radian_another)) {
if (OK != this->_expand_line_from_another(
clp_pixel_point_root, i32_body_point_count,
this->get_clp_link_one(), this->get_clp_link_another(),
d_radian_another)) {
pri_funct_err_bttvr(
"Error : this->_expand_line_from_another(-) returns NULL.");
return NG;
@ -4176,7 +4176,7 @@ void pixel_select_curve_blur_root::exec(double d_xp, double d_yp,
if ((M_PI / 2.0 < d_radius) && (d_radius < M_PI * 3.0 / 2.0)) {
clp_start_point = clp_line->get_next_point_by_count(clp_near_point,
i32_blur_count / 2);
i_reverse_sw = true;
i_reverse_sw = true;
}
}
@ -5484,7 +5484,7 @@ void igs_line_blur_brush_curve_point_put_image_template_(
const int width // no_margin
,
const int channels, T *image_top // no_margin
) {
) {
for (int zz = 0; zz < channels; ++zz) {
image_top[yp * channels * width + xp * channels + zz] =
static_cast<T>(dp_pixel[zz]);
@ -5502,7 +5502,7 @@ void igs_line_blur_brush_curve_point_put_image_(
const int width // no_margin
,
const int channels, const int bits, void *out // no_margin
) {
) {
if ((xp < 0) && (width <= xp) && (yp < 0) && (height <= yp)) {
throw std::domain_error(
"Error : igs::line_blur::_brush_curve_point_put_image(-)");
@ -5624,8 +5624,7 @@ int igs_line_blur_brush_curve_blur_subpixel_(
}
int igs_line_blur_brush_curve_blur_all_(
bool mv_sw, bool pv_sw, bool cv_sw,
brush_curve_blur &cl_brush_curve_blur,
bool mv_sw, bool pv_sw, bool cv_sw, brush_curve_blur &cl_brush_curve_blur,
pixel_select_curve_blur_root &cl_pixel_select_curve_blur_root,
pixel_line_root &cl_pixel_line_root
@ -5637,7 +5636,7 @@ int igs_line_blur_brush_curve_blur_all_(
const int width // no_margin
,
const int channels, const int bits, void *out // no_margin
) {
) {
/* 処理ごとのメッセージ */
if (mv_sw) {
std::cout << "igs::line_blur::_brush_curve_blur_all()" << std::endl;
@ -5797,7 +5796,7 @@ void igs_line_blur_brush_smudge_put_image_(
const int width // no_margin
,
const int channels, const int bits, void *out // no_margin
) {
) {
/* 画像上に置いたブラシの範囲 */
double x1, y1, x2, y2;
cl_brush_smudge_circle.get_dp_area(d_xp, d_yp, &x1, &y1, &x2, &y2);
@ -5953,7 +5952,7 @@ void igs_line_blur_brush_smudge_all_(
const int width // no_margin
,
const int channels, const int bits, void *out // no_margin
) {
) {
/* 処理ごとのメッセージ */
if (mv_sw) {
std::cout << "igs::line_expand::_brush_smudge_all()" << std::endl;
@ -6082,7 +6081,7 @@ void igs_line_blur_image_get_(const bool mv_sw, const bool cv_sw,
pri_funct_cv_end();
}
}
}
} // namespace
#include <iostream>
#include <stdexcept>
@ -6099,7 +6098,8 @@ void igs::line_blur::convert(
,
const int width // no_margin
,
const int channels, const int bits
const int channels,
const int bits
/* Action */
,
@ -6138,7 +6138,7 @@ void igs::line_blur::convert(
const bool debug_save_sw /* false=OFF */
,
const int brush_action /* 0 =Curve Blur ,1=Smudge Brush */
) {
) {
/* --- 動作クラスコンストラクション --- */
thinnest_ui16_image cl_thinnest_ui16_image;
pixel_point_root cl_pixel_point_root;
@ -6253,11 +6253,10 @@ void igs::line_blur::convert(
/****** ベクトルリスト処理 start ******/
/* 細線化した画像をリストにする */
if (OK !=
cl_pixel_point_root.alloc_mem_and_list_node(
cl_thinnest_ui16_image.get_i32_xs(),
cl_thinnest_ui16_image.get_i32_ys(),
cl_thinnest_ui16_image.get_ui16p_src_channel())) {
if (OK != cl_pixel_point_root.alloc_mem_and_list_node(
cl_thinnest_ui16_image.get_i32_xs(),
cl_thinnest_ui16_image.get_i32_ys(),
cl_thinnest_ui16_image.get_ui16p_src_channel())) {
throw std::domain_error(
"Error : cl_pixel_point_root.alloc_mem_and_list_node() returns NG");
}
@ -6281,9 +6280,8 @@ void igs::line_blur::convert(
throw std::domain_error(
"Error : cl_pixel_line_root.save_another_point(-) returns NG");
}
if (OK !=
cl_pixel_line_root.save_not_include(&(cl_pixel_point_root),
"tmp11_not_include.txt")) {
if (OK != cl_pixel_line_root.save_not_include(&(cl_pixel_point_root),
"tmp11_not_include.txt")) {
throw std::domain_error(
"Error : cl_pixel_line_root.save_not_include(-) returns NG");
}
@ -6335,15 +6333,13 @@ void igs::line_blur::convert(
throw std::domain_error(
"Error : cl_pixel_line_root.save_expand_lines(-) returns NG");
}
if (OK !=
cl_pixel_line_root.save_one_expand_point(
"tmp16_one_expand_point.txt")) {
if (OK != cl_pixel_line_root.save_one_expand_point(
"tmp16_one_expand_point.txt")) {
throw std::domain_error(
"Error : cl_pixel_line_root.save_one_expand_point(-) returns NG");
}
if (OK !=
cl_pixel_line_root.save_another_expand_point(
"tmp17_another_expand_point.txt")) {
if (OK != cl_pixel_line_root.save_another_expand_point(
"tmp17_another_expand_point.txt")) {
throw std::domain_error(
"Error : cl_pixel_line_root.save_another_expand_point(-) returns NG");
}

View file

@ -1,5 +1,3 @@
#pragma once
#ifndef igs_line_blur_h
#define igs_line_blur_h
@ -20,7 +18,8 @@ IGS_LINE_BLUR_EXPORT void convert(
,
const int width // no_margin
,
const int channels, const int bits
const int channels,
const int bits
/* Action Geometry */
,
@ -59,8 +58,8 @@ IGS_LINE_BLUR_EXPORT void convert(
const bool debug_save_sw /* false=OFF */
,
const int brush_action /* 0 =Curve Blur ,1=Smudge Brush */
);
}
);
}
} // namespace igs
#endif /* !igs_line_blur_h */

View file

@ -20,7 +20,8 @@ IGS_LINE_BLUR_EXPORT void convert(
,
const int width // no_margin
,
const int channels, const int bits
const int channels,
const int bits
/* Action Geometry */
,
@ -59,9 +60,9 @@ IGS_LINE_BLUR_EXPORT void convert(
const bool debug_save_sw /* false=OFF */
,
const int brush_action /* 0 =Curve Blur ,1=Smudge Brush */
);
}
);
}
} // namespace igs
#endif /* !igs_line_blur_h */
@ -93,14 +94,14 @@ extern "C" {
#endif
/*
extern void pri_funct_cv_start( int32_t i32_ys );
extern void pri_funct_cv_run( int32_t i32_y );
extern void pri_funct_cv_end( void );
extern void pri_funct_cv_start(int32_t i32_ys);
extern void pri_funct_cv_run(int32_t i32_y);
extern void pri_funct_cv_end(void);
extern void pri_funct_set_cp_title(const char *cp_title );
extern void pri_funct_msg_ttvr( const char* fmt, ...);
extern void pri_funct_msg_vr( const char* fmt, ...);
extern void pri_funct_err_bttvr( const char* fmt, ...);
extern void pri_funct_set_cp_title(const char *cp_title);
extern void pri_funct_msg_ttvr(const char* fmt, ...);
extern void pri_funct_msg_vr(const char* fmt, ...);
extern void pri_funct_err_bttvr(const char* fmt, ...);
*/
#ifdef __cplusplus
@ -253,6 +254,7 @@ void pri_funct_err_bttvr(const char *fmt, ...) {
#ifndef _list_node_h_
#define _list_node_h_
#include <stdio.h>
class list_node {
@ -761,9 +763,9 @@ public:
void mem_free(void);
private:
int _i_mv_sw, /* Method Verbose */
_i_pv_sw, /* Parameter Verbose */
_i_cv_sw; /* Counter Verbose */
bool _i_mv_sw; /* Method Verbose */
bool _i_pv_sw; /* Parameter Verbose */
bool _i_cv_sw; /* Counter Verbose */
int32_t _i32_size_by_pixel, _i32_subpixel_divide;
double _d_ratio;
@ -1780,11 +1782,10 @@ int pixel_line_node::expand_line(pixel_point_root *clp_pixel_point_root) {
/* 始点が端点ならば先へ伸ばす */
i32_body_point_count = this->_i32_point_count;
if (NULL == clp_one->get_clp_link_near(1)) { /* 2点目がないなら端点 */
if (OK !=
this->_expand_line_from_one(clp_pixel_point_root, i32_body_point_count,
this->get_clp_link_one(),
this->get_clp_link_another(),
d_radian_one)) {
if (OK != this->_expand_line_from_one(
clp_pixel_point_root, i32_body_point_count,
this->get_clp_link_one(), this->get_clp_link_another(),
d_radian_one)) {
pri_funct_err_bttvr(
"Error : this->_expand_line_from_one(-) returns NULL.");
return NG;
@ -1793,11 +1794,10 @@ int pixel_line_node::expand_line(pixel_point_root *clp_pixel_point_root) {
/* 終点が端点ならば先へ伸ばす */
if (NULL == clp_another->get_clp_link_near(1)) { /* 2点目がないなら端点 */
if (OK !=
this->_expand_line_from_another(
clp_pixel_point_root, i32_body_point_count,
this->get_clp_link_one(), this->get_clp_link_another(),
d_radian_another)) {
if (OK != this->_expand_line_from_another(
clp_pixel_point_root, i32_body_point_count,
this->get_clp_link_one(), this->get_clp_link_another(),
d_radian_another)) {
pri_funct_err_bttvr(
"Error : this->_expand_line_from_another(-) returns NULL.");
return NG;
@ -4244,7 +4244,7 @@ void pixel_select_curve_blur_root::exec(double d_xp, double d_yp,
if ((M_PI / 2.0 < d_radius) && (d_radius < M_PI * 3.0 / 2.0)) {
clp_start_point = clp_line->get_next_point_by_count(clp_near_point,
i32_blur_count / 2);
i_reverse_sw = true;
i_reverse_sw = true;
}
}
@ -5208,15 +5208,15 @@ int thinnest_ui16_image::exec05_thin(void) {
/* メモリ開放 */
void thinnest_ui16_image::mem_free(void) {
#if 0
if (NULL != this->_ui16p_channel[0]) {
if (this->_i_mv_sw) {
pri_funct_msg_ttvr( "thinnest_ui16_image::mem_free()" );
}
if (NULL != this->_ui16p_channel[0]) {
if (this->_i_mv_sw) {
pri_funct_msg_ttvr( "thinnest_ui16_image::mem_free()" );
}
free( this->_ui16p_channel[0]);/* ここで落ちる2014-5-16 */
this->_ui16p_channel[0] = NULL;
this->_ui16p_channel[1] = NULL;
}
free( this->_ui16p_channel[0]);/* ここで落ちる2014-5-16 */
this->_ui16p_channel[0] = NULL;
this->_ui16p_channel[1] = NULL;
}
#endif
if (NULL != this->memory_free_this_) {
if (this->_i_mv_sw) {
@ -5552,7 +5552,7 @@ void igs_line_blur_brush_curve_point_put_image_template_(
const int width // no_margin
,
const int channels, T *image_top // no_margin
) {
) {
for (int zz = 0; zz < channels; ++zz) {
image_top[yp * channels * width + xp * channels + zz] =
static_cast<T>(dp_pixel[zz]);
@ -5570,7 +5570,7 @@ void igs_line_blur_brush_curve_point_put_image_(
const int width // no_margin
,
const int channels, const int bits, void *out // no_margin
) {
) {
if ((xp < 0) && (width <= xp) && (yp < 0) && (height <= yp)) {
throw std::domain_error(
"Error : igs::line_blur::_brush_curve_point_put_image(-)");
@ -5692,8 +5692,7 @@ int igs_line_blur_brush_curve_blur_subpixel_(
}
int igs_line_blur_brush_curve_blur_all_(
bool mv_sw, bool pv_sw, bool cv_sw,
brush_curve_blur &cl_brush_curve_blur,
bool mv_sw, bool pv_sw, bool cv_sw, brush_curve_blur &cl_brush_curve_blur,
pixel_select_curve_blur_root &cl_pixel_select_curve_blur_root,
pixel_line_root &cl_pixel_line_root
@ -5705,7 +5704,7 @@ int igs_line_blur_brush_curve_blur_all_(
const int width // no_margin
,
const int channels, const int bits, void *out // no_margin
) {
) {
/* 処理ごとのメッセージ */
if (mv_sw) {
std::cout << "igs::line_blur::_brush_curve_blur_all()" << std::endl;
@ -5865,7 +5864,7 @@ void igs_line_blur_brush_smudge_put_image_(
const int width // no_margin
,
const int channels, const int bits, void *out // no_margin
) {
) {
/* 画像上に置いたブラシの範囲 */
double x1, y1, x2, y2;
cl_brush_smudge_circle.get_dp_area(d_xp, d_yp, &x1, &y1, &x2, &y2);
@ -6021,7 +6020,7 @@ void igs_line_blur_brush_smudge_all_(
const int width // no_margin
,
const int channels, const int bits, void *out // no_margin
) {
) {
/* 処理ごとのメッセージ */
if (mv_sw) {
std::cout << "igs::line_expand::_brush_smudge_all()" << std::endl;
@ -6150,11 +6149,10 @@ void igs_line_blur_image_get_(const bool mv_sw, const bool cv_sw,
pri_funct_cv_end();
}
}
}
} // namespace
#include <iostream>
#include <stdexcept>
#include "igs_line_blur.h" // "thinnest_ui16_image.h" "pixel_point_root.h" "pixel_line_root.h" "brush_curve_blur.h" "brush_smudge_circle.h" "pixel_select_same_way.h" "pixel_select_curve_blur.h" "igs_line_blur.h"
void igs::line_blur::convert(
@ -6168,7 +6166,8 @@ void igs::line_blur::convert(
,
const int width // no_margin
,
const int channels, const int bits
const int channels,
const int bits
/* Action */
,
@ -6207,7 +6206,7 @@ void igs::line_blur::convert(
const bool debug_save_sw /* false=OFF */
,
const int brush_action /* 0 =Curve Blur ,1=Smudge Brush */
) {
) {
/* --- 動作クラスコンストラクション --- */
thinnest_ui16_image cl_thinnest_ui16_image;
pixel_point_root cl_pixel_point_root;
@ -6322,11 +6321,10 @@ void igs::line_blur::convert(
/****** ベクトルリスト処理 start ******/
/* 細線化した画像をリストにする */
if (OK !=
cl_pixel_point_root.alloc_mem_and_list_node(
cl_thinnest_ui16_image.get_i32_xs(),
cl_thinnest_ui16_image.get_i32_ys(),
cl_thinnest_ui16_image.get_ui16p_src_channel())) {
if (OK != cl_pixel_point_root.alloc_mem_and_list_node(
cl_thinnest_ui16_image.get_i32_xs(),
cl_thinnest_ui16_image.get_i32_ys(),
cl_thinnest_ui16_image.get_ui16p_src_channel())) {
throw std::domain_error(
"Error : cl_pixel_point_root.alloc_mem_and_list_node() returns NG");
}
@ -6350,9 +6348,8 @@ void igs::line_blur::convert(
throw std::domain_error(
"Error : cl_pixel_line_root.save_another_point(-) returns NG");
}
if (OK !=
cl_pixel_line_root.save_not_include(&(cl_pixel_point_root),
"tmp11_not_include.txt")) {
if (OK != cl_pixel_line_root.save_not_include(&(cl_pixel_point_root),
"tmp11_not_include.txt")) {
throw std::domain_error(
"Error : cl_pixel_line_root.save_not_include(-) returns NG");
}
@ -6404,15 +6401,13 @@ void igs::line_blur::convert(
throw std::domain_error(
"Error : cl_pixel_line_root.save_expand_lines(-) returns NG");
}
if (OK !=
cl_pixel_line_root.save_one_expand_point(
"tmp16_one_expand_point.txt")) {
if (OK != cl_pixel_line_root.save_one_expand_point(
"tmp16_one_expand_point.txt")) {
throw std::domain_error(
"Error : cl_pixel_line_root.save_one_expand_point(-) returns NG");
}
if (OK !=
cl_pixel_line_root.save_another_expand_point(
"tmp17_another_expand_point.txt")) {
if (OK != cl_pixel_line_root.save_another_expand_point(
"tmp17_another_expand_point.txt")) {
throw std::domain_error(
"Error : cl_pixel_line_root.save_another_expand_point(-) returns NG");
}
@ -6459,70 +6454,57 @@ void igs::line_blur::convert(
cl_thinnest_ui16_image.mem_free();
}
//
/*------------------------------------------------------------------*/
#include <sstream> /* std::ostringstream */
#include "tfxparam.h"
#include "stdfx.h"
#include "tfxattributes.h"
#include "ino_common.h"
#include "igs_line_blur.h"
//------------------------------------------------------------
class ino_line_blur final : public TStandardRasterFx {
FX_PLUGIN_DECLARATION(ino_line_blur)
TRasterFxPort m_input;
TIntEnumParamP m_b_action_mode;
TDoubleParamP m_b_blur_count;
TDoubleParamP m_b_blur_power;
TIntEnumParamP m_b_blur_subpixel;
TDoubleParamP m_b_blur_near_ref;
TDoubleParamP m_b_blur_near_len;
TDoubleParamP m_v_smooth_retry;
TDoubleParamP m_v_near_ref;
TDoubleParamP m_v_near_len;
TDoubleParamP m_b_smudge_thick;
TDoubleParamP m_b_smudge_remain;
public:
ino_line_blur()
: m_b_action_mode(new TIntEnumParam(0, "Blur"))
, m_b_blur_count(51)
, m_b_blur_power(1.0)
, m_b_blur_subpixel(new TIntEnumParam())
, m_b_blur_near_ref(5)
, m_b_blur_near_len(160)
, m_v_smooth_retry(100)
, m_v_near_ref(4)
, m_v_near_len(160)
, m_b_smudge_thick(7)
, m_b_smudge_remain(0.85) {
addInputPort("Source", this->m_input);
bindParam(this, "action_mode", this->m_b_action_mode);
bindParam(this, "blur_count", this->m_b_blur_count);
bindParam(this, "blur_power", this->m_b_blur_power);
bindParam(this, "blur_subpixel", this->m_b_blur_subpixel);
bindParam(this, "blur_near_ref", this->m_b_blur_near_ref);
bindParam(this, "blur_near_len", this->m_b_blur_near_len);
bindParam(this, "vector_smooth_retry", this->m_v_smooth_retry);
bindParam(this, "vector_near_ref", this->m_v_near_ref);
bindParam(this, "vector_near_len", this->m_v_near_len);
bindParam(this, "smudge_thick", this->m_b_smudge_thick);
bindParam(this, "smudge_remain", this->m_b_smudge_remain);
this->m_b_action_mode->addItem(1, "Smudge");
this->m_b_blur_count->setValueRange(1, 100);
this->m_b_blur_power->setValueRange(0.1, 10.0);
this->m_b_blur_subpixel->addItem(1, "1");
@ -6532,27 +6514,41 @@ public:
this->m_b_blur_subpixel->setValue(2);
this->m_b_blur_near_ref->setValueRange(1, 100);
this->m_b_blur_near_len->setValueRange(1, 1000);
this->m_v_smooth_retry->setValueRange(1, 1000);
this->m_v_near_ref->setValueRange(1, 100);
this->m_v_near_len->setValueRange(1, 1000);
// this->m_b_smudge_thick->setMeasureName("fxLength");
this->m_b_smudge_thick->setValueRange(1, 100);
this->m_b_smudge_remain->setValueRange(0.0, 1.0);
}
//------------------------------------------------------------
double get_render_real_radius(const double frame, const TAffine affine) {
double rad = this->m_b_blur_count->getValue(frame);
/*--- 単位について考察必要 ---*/
// rad *= ino::pixel_per_mm();
/*--- Geometryを反映させる ---*/
// TAffine aff(affine);
return rad;
}
void get_render_enlarge(const double frame, const TAffine affine,
TRectD &bBox) {
const int margin =
static_cast<int>(ceil(this->get_render_real_radius(frame, affine)));
if (0 < margin) {
bBox = bBox.enlarge(static_cast<double>(margin));
}
}
bool doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info) {
if (false == this->m_input.isConnected()) {
bBox = TRectD();
return false;
}
const bool ret = this->m_input->doGetBBox(frame, bBox, info);
this->get_render_enlarge(frame, info.m_affine, bBox);
return ret;
}
int getMemoryRequirement(const TRectD &rect, double frame,
const TRenderSettings &info) {
TRectD bBox(rect);
this->get_render_enlarge(frame, info.m_affine, bBox);
return TRasterFx::memorySize(bBox, info.m_bpp);
}
void transform(double frame, int port, const TRectD &rectOnOutput,
@ -6560,6 +6556,7 @@ public:
TRenderSettings &infoOnInput) {
rectOnInput = rectOnOutput;
infoOnInput = infoOnOutput;
this->get_render_enlarge(frame, infoOnOutput.m_affine, rectOnInput);
}
bool canHandle(const TRenderSettings &info, double frame) {
// return true;/* geometry処理済の画像に加工することになる */
@ -6567,36 +6564,23 @@ public:
}
void doCompute(TTile &tile, double frame, const TRenderSettings &rend_sets);
};
FX_PLUGIN_IDENTIFIER(ino_line_blur, "inoLineBlurFx");
//------------------------------------------------------------
namespace {
void fx_(const TRasterP in_ras // with margin
void fx_(const TRasterP in_ras // no margin
,
TRasterP out_ras // no margin
,
const int action_mode
,
const int blur_count, const double blur_power, const int blur_subpixel,
const int blur_near_ref, const int blur_near_len
,
const int vector_smooth_retry, const int vector_near_ref,
const int vector_near_len
,
const int action_mode, const int blur_count, const double blur_power,
const int blur_subpixel, const int blur_near_ref,
const int blur_near_len, const int vector_smooth_retry,
const int vector_near_ref, const int vector_near_len,
const int smudge_thick, const double smudge_remain) {
TRasterGR8P out_buffer(out_ras->getLy(),
out_ras->getLx() * ino::channels() *
((TRaster64P)in_ras ? sizeof(unsigned short)
: sizeof(unsigned char)));
out_buffer->lock();
igs::line_blur::convert(
in_ras->getRawData() // const void *in_no_margin (BGRA)
,
out_buffer->getRawData() // void *out_no_margin (BGRA)
out_ras->getRawData() // void *out_no_margin (BGRA)
,
in_ras->getLy() // const int height_no_margin
,
@ -6605,18 +6589,10 @@ void fx_(const TRasterP in_ras // with margin
ino::channels() // const int channels
,
ino::bits(in_ras) // const int bits
,
blur_count, blur_power, blur_subpixel, blur_near_ref, blur_near_len
,
smudge_thick, smudge_remain
,
vector_smooth_retry, vector_near_ref, vector_near_len
,
false /* bool mv_sw false=OFF */
blur_count, blur_power, blur_subpixel, blur_near_ref, blur_near_len,
smudge_thick, smudge_remain, vector_smooth_retry, vector_near_ref,
vector_near_len, false /* bool mv_sw false=OFF */
,
false /* bool pv_sw false=OFF */
,
@ -6627,130 +6603,72 @@ void fx_(const TRasterP in_ras // with margin
false /* bool debug_save_sw false=OFF */
,
action_mode);
ino::arr_to_ras(out_buffer->getRawData(), ino::channels(), out_ras, 0);
out_buffer->unlock();
}
}
//------------------------------------------------------------
void ino_line_blur::doCompute(TTile &tile, double frame,
const TRenderSettings &rend_sets) {
/*------ 接続していなければ処理しない ----------------------*/
} // namespace
void ino_line_blur::doCompute(
TTile &tile /* 注意:doGetBBox(-)が返す範囲の画像 */
,
double frame, const TRenderSettings &rend_sets) {
/*--- 接続していなければ処理しない -------------------------*/
if (!this->m_input.isConnected()) {
tile.getRaster()->clear(); /* 塗りつぶしクリア */
return;
}
/*------ サポートしていないPixelタイプはエラーを投げる -----*/
/*--- サポートしていないPixelタイプはエラーを投げる --------*/
if (!((TRaster32P)tile.getRaster()) && !((TRaster64P)tile.getRaster())) {
throw TRopException("unsupported input pixel type");
}
/*------ パラメータを得る ------*/
const int action_mode = this->m_b_action_mode->getValue();
const int blur_count = this->m_b_blur_count->getValue(frame);
const double blur_power = this->m_b_blur_power->getValue(frame);
const int blur_subpixel = this->m_b_blur_subpixel->getValue();
const int blur_near_ref = this->m_b_blur_near_ref->getValue(frame);
const int blur_near_len = this->m_b_blur_near_len->getValue(frame);
/*--- パラメータを得る -------------------------------------*/
const int action_mode = this->m_b_action_mode->getValue();
const int blur_count = this->m_b_blur_count->getValue(frame);
const double blur_power = this->m_b_blur_power->getValue(frame);
const int blur_subpixel = this->m_b_blur_subpixel->getValue();
const int blur_near_ref = this->m_b_blur_near_ref->getValue(frame);
const int blur_near_len = this->m_b_blur_near_len->getValue(frame);
const int vector_smooth_retry = this->m_v_smooth_retry->getValue(frame);
const int vector_near_ref = this->m_v_near_ref->getValue(frame);
const int vector_near_len = this->m_v_near_len->getValue(frame);
const int smudge_thick = this->m_b_smudge_thick->getValue(frame);
const double smudge_remain = this->m_b_smudge_remain->getValue(frame);
/*------ 表示の範囲を得る ----------------------------------*/
const int smudge_thick = this->m_b_smudge_thick->getValue(frame);
const double smudge_remain = this->m_b_smudge_remain->getValue(frame);
/*--- 表示の範囲を得る -------------------------------------*/
TRectD bBox =
TRectD(tile.m_pos /* Render画像上(Pixel単位)の位置 */
,
TDimensionD(/* Render画像上(Pixel単位)のサイズ */
tile.getRaster()->getLx(), tile.getRaster()->getLy()));
/* ------ marginなし画像生成 ------------------------------ */
TTile enlarge_tile;
/*--- doGetBBox(-)が返す範囲の画像を生成 -------------------*/
TTile in_tile;
this->m_input->allocateAndCompute(
enlarge_tile, bBox.getP00(),
in_tile, bBox.getP00(),
TDimensionI(/* Pixel単位に四捨五入 */
static_cast<int>(bBox.getLx() + 0.5),
static_cast<int>(bBox.getLy() + 0.5)),
tile.getRaster(), frame, rend_sets);
/* ------ 保存すべき画像メモリを塗りつぶしクリア ---------- */
tile.getRaster()->clear(); /* 塗りつぶしクリア */
/* ------ (app_begin)log記憶 ------------------------------ */
const bool log_sw = ino::log_enable_sw();
if (log_sw) {
std::ostringstream os;
os << "params"
<< " action_mode " << action_mode
<< " blur_count " << blur_count << " blur_power " << blur_power
<< " blur_subpixel " << blur_subpixel << " blur_near_ref "
<< blur_near_ref << " blur_near_len " << blur_near_len
<< " vector_smooth_retry " << vector_smooth_retry
<< " vector_near_ref " << vector_near_ref << " vector_near_len "
<< vector_near_len
<< " smudge_thick " << smudge_thick << " smudge_remain "
<< smudge_remain
<< " tile"
<< " pos " << tile.m_pos << " w " << tile.getRaster()->getLx() << " h "
<< tile.getRaster()->getLy() << " in_tile"
<< " w " << enlarge_tile.getRaster()->getLx() << " h "
<< enlarge_tile.getRaster()->getLy() << " pixbits "
<< ino::pixel_bits(tile.getRaster()) << " frame " << frame
<< " m_affine " << rend_sets.m_affine;
}
/* ------ fx処理 ------------------------------------------ */
/*--- 保存すべき画像メモリを塗りつぶしクリア ---------------*/
tile.getRaster()->clear();
/*--- 画像処理 ---------------------------------------------*/
try {
tile.getRaster()->lock();
fx_(enlarge_tile.getRaster() // in with margin
fx_(in_tile.getRaster() // in no margin
,
tile.getRaster() // out with no margin
,
action_mode
,
blur_count, blur_power, blur_subpixel, blur_near_ref, blur_near_len
,
vector_smooth_retry, vector_near_ref, vector_near_len
tile.getRaster() // out no margin
,
action_mode, blur_count, blur_power, blur_subpixel, blur_near_ref,
blur_near_len, vector_smooth_retry, vector_near_ref, vector_near_len,
smudge_thick, smudge_remain);
tile.getRaster()->unlock();
}
/* ------ error処理 --------------------------------------- */
/*--- error処理 --------------------------------------------*/
catch (std::bad_alloc &e) {
tile.getRaster()->unlock();
if (log_sw) {
std::string str("std::bad_alloc <");
str += e.what();
str += '>';
}
throw;
} catch (std::exception &e) {
tile.getRaster()->unlock();
if (log_sw) {
std::string str("exception <");
str += e.what();
str += '>';
}
throw;
} catch (...) {
tile.getRaster()->unlock();
if (log_sw) {
std::string str("other exception");
}
throw;
}
}
#endif

View file

@ -250,18 +250,20 @@ Iwa_TiledParticlesFx::Iwa_TiledParticlesFx()
animation_val->addItem(ANIM_SR_CYCLE, "Column Swing - Random Start");
bindParam(this, "step", step_val);
step_val->setValueRange(1, (std::numeric_limits<int>::max)());
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::Red),
TSpectrum::ColorKey(1, TPixel32::Red)};
gencol_val = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::Red),
TSpectrum::ColorKey(1, TPixel32::Red)};
gencol_val = TSpectrumParamP(colors);
bindParam(this, "birth_color", gencol_val);
bindParam(this, "birth_color_ctrl", gencol_ctrl_val);
bindParam(this, "birth_color_spread", gencol_spread_val);
gencol_spread_val->setValueRange(0.0, (std::numeric_limits<int>::max)());
bindParam(this, "birth_color_fade", genfadecol_val);
genfadecol_val->setValueRange(0.0, 100.0);
TSpectrum::ColorKey colors1[] = {TSpectrum::ColorKey(0, TPixel32::Green),
TSpectrum::ColorKey(1, TPixel32::Green)};
fincol_val = TSpectrumParamP(tArrayCount(colors1), colors1);
std::vector<TSpectrum::ColorKey> colors1 = {
TSpectrum::ColorKey(0, TPixel32::Green),
TSpectrum::ColorKey(1, TPixel32::Green)};
fincol_val = TSpectrumParamP(colors1);
bindParam(this, "fadein_color", fincol_val);
bindParam(this, "fadein_color_ctrl", fincol_ctrl_val);
bindParam(this, "fadein_color_spread", fincol_spread_val);
@ -270,9 +272,10 @@ Iwa_TiledParticlesFx::Iwa_TiledParticlesFx()
finrangecol_val->setValueRange(0.0, (std::numeric_limits<double>::max)());
bindParam(this, "fadein_color_fade", finfadecol_val);
finfadecol_val->setValueRange(0.0, 100.0);
TSpectrum::ColorKey colors2[] = {TSpectrum::ColorKey(0, TPixel32::Blue),
TSpectrum::ColorKey(1, TPixel32::Blue)};
foutcol_val = TSpectrumParamP(tArrayCount(colors2), colors2);
std::vector<TSpectrum::ColorKey> colors2 = {
TSpectrum::ColorKey(0, TPixel32::Blue),
TSpectrum::ColorKey(1, TPixel32::Blue)};
foutcol_val = TSpectrumParamP(colors2);
bindParam(this, "fadeout_color", foutcol_val);
bindParam(this, "fadeout_color_ctrl", foutcol_ctrl_val);
bindParam(this, "fadeout_color_spread", foutcol_spread_val);

View file

@ -195,11 +195,11 @@ public:
TRasterP rasIn = tileIn.getRaster();
// Compute the warper tile
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.5, TPixel32::Black),
TSpectrum::ColorKey(1, TPixel32::White)};
TSpectrumParamP wavecolors = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.5, TPixel32::Black),
TSpectrum::ColorKey(1, TPixel32::White)};
TSpectrumParamP wavecolors = TSpectrumParamP(colors);
// Build the multiradial
warperInfo.m_affine = warperInfo.m_affine * TRotation(angle);

View file

@ -12,10 +12,11 @@ class MultiToneFx final : public TStandardRasterFx {
public:
MultiToneFx() {
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.5, TPixel32::Yellow),
TSpectrum::ColorKey(1, TPixel32::Red)};
m_colors = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.5, TPixel32::Yellow),
TSpectrum::ColorKey(1, TPixel32::Red)};
m_colors = TSpectrumParamP(colors);
bool ret = m_colors->isKeyframe(0);
bindParam(this, "colors", m_colors);

View file

@ -228,18 +228,20 @@ ParticlesFx::ParticlesFx()
animation_val->addItem(ANIM_SR_CYCLE, "Column Swing - Random Start");
bindParam(this, "step", step_val);
step_val->setValueRange(1, (std::numeric_limits<int>::max)());
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::Red),
TSpectrum::ColorKey(1, TPixel32::Red)};
gencol_val = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::Red),
TSpectrum::ColorKey(1, TPixel32::Red)};
gencol_val = TSpectrumParamP(colors);
bindParam(this, "birth_color", gencol_val);
bindParam(this, "birth_color_ctrl", gencol_ctrl_val);
bindParam(this, "birth_color_spread", gencol_spread_val);
gencol_spread_val->setValueRange(0.0, (std::numeric_limits<int>::max)());
bindParam(this, "birth_color_fade", genfadecol_val);
genfadecol_val->setValueRange(0.0, 100.0);
TSpectrum::ColorKey colors1[] = {TSpectrum::ColorKey(0, TPixel32::Green),
TSpectrum::ColorKey(1, TPixel32::Green)};
fincol_val = TSpectrumParamP(tArrayCount(colors1), colors1);
std::vector<TSpectrum::ColorKey> colors1 = {
TSpectrum::ColorKey(0, TPixel32::Green),
TSpectrum::ColorKey(1, TPixel32::Green)};
fincol_val = TSpectrumParamP(colors1);
bindParam(this, "fadein_color", fincol_val);
bindParam(this, "fadein_color_ctrl", fincol_ctrl_val);
bindParam(this, "fadein_color_spread", fincol_spread_val);
@ -248,9 +250,10 @@ ParticlesFx::ParticlesFx()
finrangecol_val->setValueRange(0.0, (std::numeric_limits<double>::max)());
bindParam(this, "fadein_color_fade", finfadecol_val);
finfadecol_val->setValueRange(0.0, 100.0);
TSpectrum::ColorKey colors2[] = {TSpectrum::ColorKey(0, TPixel32::Blue),
TSpectrum::ColorKey(1, TPixel32::Blue)};
foutcol_val = TSpectrumParamP(tArrayCount(colors2), colors2);
std::vector<TSpectrum::ColorKey> colors2 = {
TSpectrum::ColorKey(0, TPixel32::Blue),
TSpectrum::ColorKey(1, TPixel32::Blue)};
foutcol_val = TSpectrumParamP(colors2);
bindParam(this, "fadeout_color", foutcol_val);
bindParam(this, "fadeout_color_ctrl", foutcol_ctrl_val);
bindParam(this, "fadeout_color_spread", foutcol_spread_val);

View file

@ -191,10 +191,10 @@ public:
TRasterP rasIn = tileIn.getRaster();
// Compute the warper tile
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(1, TPixel32::Black)};
TSpectrumParamP cloudscolors = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(1, TPixel32::Black)};
TSpectrumParamP cloudscolors = TSpectrumParamP(colors);
// Build the warper
warperInfo.m_affine = warperInfo.m_affine;

View file

@ -197,11 +197,11 @@ public:
TRasterP rasIn = tileIn.getRaster();
// Compute the warper tile
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.5, TPixel32::Black),
TSpectrum::ColorKey(1, TPixel32::White)};
TSpectrumParamP ripplecolors = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.5, TPixel32::Black),
TSpectrum::ColorKey(1, TPixel32::White)};
TSpectrumParamP ripplecolors = TSpectrumParamP(colors);
// Build the multiradial
warperInfo.m_affine = warperInfo.m_affine * TTranslation(center) *

View file

@ -17,11 +17,11 @@ class SquareGradientFx final : public TStandardZeraryFx {
public:
SquareGradientFx() : m_size(200.0) {
m_size->setMeasureName("fxLength");
TSpectrum::ColorKey colors[] = {
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::White),
// TSpectrum::ColorKey(0.5,TPixel32::Yellow),
TSpectrum::ColorKey(1, TPixel32::Red)};
m_colors = TSpectrumParamP(tArrayCount(colors), colors);
m_colors = TSpectrumParamP(colors);
bindParam(this, "colors", m_colors);
bindParam(this, "size", m_size);
m_size->setValueRange(0, std::numeric_limits<double>::max());

View file

@ -89,13 +89,13 @@ TPixel32 colors[] = {
TPixel32::Yellow,
transparent};
*/
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::Magenta),
TSpectrum::ColorKey(0.25, TPixel32::Black),
TSpectrum::ColorKey(0.5, TPixel32::Red),
TSpectrum::ColorKey(0.75, TPixel32::Yellow),
TSpectrum::ColorKey(1, transparent)};
m_spectrum = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::Magenta),
TSpectrum::ColorKey(0.25, TPixel32::Black),
TSpectrum::ColorKey(0.5, TPixel32::Red),
TSpectrum::ColorKey(0.75, TPixel32::Yellow),
TSpectrum::ColorKey(1, transparent)};
m_spectrum = TSpectrumParamP(colors);
bindParam(this, "colors", m_spectrum);
bindParam(this, "freq", m_freq);
@ -128,7 +128,7 @@ void doComputeT(TRasterPT<T> raster, TPointD posTrasf, const TAffine &aff,
TPointD posAux = posTrasf;
T *pix = raster->pixels(y);
for (int x = 0; x < raster->getLx(); x++) {
double ang = 0.0;
double ang = 0.0;
if (posAux.x != 0 || posAux.y != 0) ang = atan2(posAux.y, posAux.x);
double r = sqrt(posAux.x * posAux.x + posAux.y * posAux.y);
double v = 0.5 * (1 + sin(r * freq + ang + phase));
@ -141,7 +141,7 @@ void doComputeT(TRasterPT<T> raster, TPointD posTrasf, const TAffine &aff,
}
raster->unlock();
}
}
} // namespace
//==================================================================
@ -184,11 +184,12 @@ public:
, m_wave_phase(0.0) // args, "Cycle")
// , m_colors (0) //args, "Colors")
{
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.33, TPixel32::Yellow),
TSpectrum::ColorKey(0.66, TPixel32::Red),
TSpectrum::ColorKey(1, TPixel32::White)};
m_colors = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.33, TPixel32::Yellow),
TSpectrum::ColorKey(0.66, TPixel32::Red),
TSpectrum::ColorKey(1, TPixel32::White)};
m_colors = TSpectrumParamP(colors);
bindParam(this, "period", m_period);
bindParam(this, "count", m_count);
@ -303,13 +304,13 @@ void doComputeT(TRasterPT<T> ras, TPointD posTrasf,
T *endPix = pix + ras->getLx();
while (pix < endPix) {
if (w_amplitude) shift = w_amplitude * sin(w_freq * posAux.y + w_phase);
double radius = posAux.x + shift;
double t = 1;
double radius = posAux.x + shift;
double t = 1;
if (fabs(radius) < maxRadius) {
t = (radius + maxRadius + cycle) * freq;
t -= floor(t);
} else if (radius < 0)
t = 0;
t = 0;
double polinomfactor = (-2 * t + 3) * (t * t);
// pos.x += 1.0;
*pix++ = spectrum.getPremultipliedValue(polinomfactor);
@ -321,7 +322,7 @@ void doComputeT(TRasterPT<T> ras, TPointD posTrasf,
}
ras->unlock();
}
}
} // namespace
//==================================================================
@ -337,10 +338,10 @@ void LinearGradientFx::doCompute(TTile &tile, double frame,
double w_phase = m_wave_phase->getValue(frame);
w_freq *= 0.01 * M_PI_180;
TSpectrum::ColorKey colors[] = {
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, m_color1->getValue(frame)),
TSpectrum::ColorKey(1, m_color2->getValue(frame))};
TSpectrumParamP m_colors = TSpectrumParamP(tArrayCount(colors), colors);
TSpectrumParamP m_colors = TSpectrumParamP(colors);
TAffine aff = ri.m_affine.inv();
TPointD posTrasf = aff * tile.m_pos;
@ -465,12 +466,12 @@ public:
// , m_colors (0) //args, "Colors")
{
m_period->setMeasureName("fxLength");
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.33, TPixel32::Yellow),
TSpectrum::ColorKey(0.66, TPixel32::Red),
TSpectrum::ColorKey(1, TPixel32::White)};
m_colors = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.33, TPixel32::Yellow),
TSpectrum::ColorKey(0.66, TPixel32::Red),
TSpectrum::ColorKey(1, TPixel32::White)};
m_colors = TSpectrumParamP(colors);
bindParam(this, "period", m_period);
bindParam(this, "count", m_count);
@ -532,12 +533,12 @@ void RadialGradientFx::doCompute(TTile &tile, double frame,
if (innerperiod < period)
inner = innerperiod / period;
else
inner = 1 - TConsts::epsilon;
TSpectrum::ColorKey colors[] = {
inner = 1 - TConsts::epsilon;
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, m_color1->getValue(frame)),
TSpectrum::ColorKey(inner, m_color1->getValue(frame)),
TSpectrum::ColorKey(1, m_color2->getValue(frame))};
TSpectrumParamP m_colors = TSpectrumParamP(tArrayCount(colors), colors);
TSpectrumParamP m_colors = TSpectrumParamP(colors);
TAffine aff = ri.m_affine.inv();
TPointD posTrasf = aff * tile.m_pos;
multiRadial(tile.getRaster(), posTrasf, m_colors, period, count, cycle, aff,
@ -631,7 +632,7 @@ void doComputeT(TRasterPT<T> raster, TPointD posTrasf, const TAffine &aff,
}
if (result > 1) result = 1;
if (result < 0) result = 0;
*pix++ = blend(T::Black, pixelColor, result);
*pix++ = blend(T::Black, pixelColor, result);
posAux.x += aff.a11;
posAux.y += aff.a21;
}
@ -640,7 +641,7 @@ void doComputeT(TRasterPT<T> raster, TPointD posTrasf, const TAffine &aff,
}
raster->unlock();
}
}
} // namespace
//==================================================================

View file

@ -43,10 +43,11 @@ public:
bindParam(this, "int", m_int);
bindParam(this, "range", m_range);
bindParam(this, "bool", m_bool);
TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.5, TPixel32::Yellow),
TSpectrum::ColorKey(1, TPixel32::Red)};
m_colors = TSpectrumParamP(tArrayCount(colors), colors);
std::vector<TSpectrum::ColorKey> colors = {
TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.5, TPixel32::Yellow),
TSpectrum::ColorKey(1, TPixel32::Red)};
m_colors = TSpectrumParamP(colors);
bindParam(this, "spectrum", m_colors);
bindParam(this, "string", m_string);
addInputPort("Source", m_input);

View file

@ -29,6 +29,10 @@
#include "tvectorrenderdata.h"
#include "tofflinegl.h"
#if defined(LINUX)
#include <QGuiApplication>
#endif
using namespace std;
using namespace TCli;
@ -355,6 +359,10 @@ void convert(const TFilePath &source, const TFilePath &dest,
//------------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(LINUX)
QGuiApplication app(argc, argv);
#endif
TEnv::setRootVarName(rootVarName);
TEnv::setSystemVarPrefix(systemVarPrefix);
TFilePath fp = TEnv::getStuffDir();

View file

@ -3,6 +3,7 @@ set(MOC_HEADERS
edittoolgadgets.h
filltool.h
fullcolorbrushtool.h
fullcolorfilltool.h
plastictool.h
skeletonsubtools.h
tooloptionscontrols.h
@ -58,6 +59,7 @@ set(SOURCES
filltool.cpp
fullcolorbrushtool.cpp
fullcolorerasertool.cpp
fullcolorfilltool.cpp
geometrictool.cpp
hooktool.cpp
hookselection.cpp

View file

@ -143,6 +143,9 @@ FullColorBrushTool::FullColorBrushTool(std::string name)
m_prop.bind(m_preset);
m_preset.setId("BrushPreset");
m_modifierEraser.setId("RasterEraser");
m_modifierLockAlpha.setId("LockAlpha");
m_pressure.setId("PressureSensitivity");
m_brushTimer.start();
}

View file

@ -0,0 +1,223 @@
#include "fullcolorfilltool.h"
#include "toonz/stage2.h"
#include "tools/cursors.h"
#include "toonz/txshlevelhandle.h"
#include "toonz/trasterimageutils.h"
#include "toonz/ttileset.h"
#include "toonz/ttilesaver.h"
#include "toonz/levelproperties.h"
#include "toonz/preferences.h"
#include "toonz/txsheethandle.h"
#include "tools/toolhandle.h"
#include "tools/toolutils.h"
#include "tenv.h"
#include "tpalette.h"
#include "tsystem.h"
using namespace ToolUtils;
TEnv::IntVar FullColorMinFillDepth("InknpaintFullColorMinFillDepth", 4);
TEnv::IntVar FullColorMaxFillDepth("InknpaintFullColorMaxFillDepth", 12);
namespace {
//=============================================================================
// FullColorFillUndo
//-----------------------------------------------------------------------------
class FullColorFillUndo final : public TFullColorRasterUndo {
FillParameters m_params;
bool m_saveboxOnly;
public:
FullColorFillUndo(TTileSetFullColor *tileSet, const FillParameters &params,
TXshSimpleLevel *sl, const TFrameId &fid, bool saveboxOnly)
: TFullColorRasterUndo(tileSet, sl, fid, false, false, 0)
, m_params(params)
, m_saveboxOnly(saveboxOnly) {}
void redo() const override {
TRasterImageP image = getImage();
if (!image) return;
TRaster32P r;
if (m_saveboxOnly) {
TRectD temp = image->getBBox();
TRect ttemp = convert(temp);
r = image->getRaster()->extract(ttemp);
} else
r = image->getRaster();
fullColorFill(r, m_params);
TTool::Application *app = TTool::getApplication();
if (app) {
app->getCurrentXsheet()->notifyXsheetChanged();
notifyImageChanged();
}
}
int getSize() const override {
return sizeof(*this) + TFullColorRasterUndo::getSize();
}
QString getToolName() override {
return QString("Fill Tool : %1")
.arg(QString::fromStdWString(m_params.m_fillType));
}
int getHistoryType() override { return HistoryType::FillTool; }
};
//=============================================================================
// doFill
//-----------------------------------------------------------------------------
void doFill(const TImageP &img, const TPointD &pos, FillParameters &params,
bool isShiftFill, TXshSimpleLevel *sl, const TFrameId &fid) {
TTool::Application *app = TTool::getApplication();
if (!app || !sl) return;
if (TRasterImageP ri = TRasterImageP(img)) {
TPoint offs(0, 0);
TRaster32P ras = ri->getRaster();
// only accept 32bpp images for now
if (!ras.getPointer() || ras->isEmpty()) return;
ras->lock();
TTileSetFullColor *tileSet = new TTileSetFullColor(ras->getSize());
TTileSaverFullColor tileSaver(ras, tileSet);
TDimension imageSize = ras->getSize();
TPointD p(imageSize.lx % 2 ? 0.0 : 0.5, imageSize.ly % 2 ? 0.0 : 0.5);
/*-- params.m_p = convert(pos-p)では、マイナス座標でずれが生じる --*/
TPointD tmp_p = pos - p;
params.m_p = TPoint((int)floor(tmp_p.x + 0.5), (int)floor(tmp_p.y + 0.5));
params.m_p += ras->getCenter();
params.m_p -= offs;
params.m_shiftFill = isShiftFill;
TRect rasRect(ras->getSize());
if (!rasRect.contains(params.m_p)) {
ras->unlock();
return;
}
fullColorFill(ras, params, &tileSaver);
if (tileSaver.getTileSet()->getTileCount() != 0) {
static int count = 0;
TSystem::outputDebug("RASTERFILL" + std::to_string(count++) + "\n");
if (offs != TPoint())
for (int i = 0; i < tileSet->getTileCount(); i++) {
TTileSet::Tile *t = tileSet->editTile(i);
t->m_rasterBounds = t->m_rasterBounds + offs;
}
TUndoManager::manager()->add(
new FullColorFillUndo(tileSet, params, sl, fid,
Preferences::instance()->getFillOnlySavebox()));
}
sl->getProperties()->setDirtyFlag(true);
ras->unlock();
}
TTool *t = app->getCurrentTool()->getTool();
if (t) t->notifyImageChanged();
}
};
//=============================================================================
// FullColorFillTool
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
FullColorFillTool::FullColorFillTool()
: TTool("T_Fill"), m_fillDepth("Fill Depth", 0, 15, 4, 12) {
bind(TTool::RasterImage);
m_prop.bind(m_fillDepth);
}
void FullColorFillTool::updateTranslation() {
m_fillDepth.setQStringName(tr("Fill Depth"));
}
FillParameters FullColorFillTool::getFillParameters() const {
FillParameters params;
int styleId = TTool::getApplication()->getCurrentLevelStyleIndex();
params.m_styleId = styleId;
params.m_minFillDepth = (int)m_fillDepth.getValue().first;
params.m_maxFillDepth = (int)m_fillDepth.getValue().second;
if (m_level) params.m_palette = m_level->getPalette();
return params;
}
void FullColorFillTool::leftButtonDown(const TPointD &pos,
const TMouseEvent &e) {
m_clickPoint = pos;
TXshLevel *xl = TTool::getApplication()->getCurrentLevel()->getLevel();
m_level = xl ? xl->getSimpleLevel() : 0;
FillParameters params = getFillParameters();
doFill(getImage(true), pos, params, e.isShiftPressed(), m_level.getPointer(),
getCurrentFid());
invalidate();
}
void FullColorFillTool::leftButtonDrag(const TPointD &pos,
const TMouseEvent &e) {
FillParameters params = getFillParameters();
if (m_clickPoint == pos) return;
if (!m_level || !params.m_palette) return;
TImageP img = getImage(true);
TPixel32 fillColor =
params.m_palette->getStyle(params.m_styleId)->getMainColor();
if (TRasterImageP ri = img) {
TRaster32P ras = ri->getRaster();
if (!ras) return;
TPointD center = ras->getCenterD();
TPoint ipos = convert(pos + center);
if (!ras->getBounds().contains(ipos)) return;
TPixel32 pix = ras->pixels(ipos.y)[ipos.x];
if (pix == fillColor) {
invalidate();
return;
}
} else
return;
doFill(img, pos, params, e.isShiftPressed(), m_level.getPointer(),
getCurrentFid());
invalidate();
}
bool FullColorFillTool::onPropertyChanged(std::string propertyName) {
// Fill Depth
if (propertyName == m_fillDepth.getName()) {
FullColorMinFillDepth = (int)m_fillDepth.getValue().first;
FullColorMaxFillDepth = (int)m_fillDepth.getValue().second;
}
return true;
}
void FullColorFillTool::onActivate() {
static bool firstTime = true;
if (firstTime) {
m_fillDepth.setValue(TDoublePairProperty::Value(FullColorMinFillDepth,
FullColorMaxFillDepth));
firstTime = false;
}
}
int FullColorFillTool::getCursorId() const {
int ret = ToolCursor::FillCursor;
if (ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg)
ret = ret | ToolCursor::Ex_Negate;
return ret;
}
FullColorFillTool FullColorRasterFillTool;

View file

@ -0,0 +1,45 @@
#pragma once
#ifndef FULLCOLORFILLTOOL_H
#define FULLCOLORFILLTOOL_H
// TnzCore includes
#include "tproperty.h"
// TnzTools includes
#include "tools/tool.h"
#include "toonz/fill.h"
#include "toonz/txshsimplelevel.h"
#include <QCoreApplication>
#include <QObject>
class FullColorFillTool final : public QObject, public TTool {
Q_DECLARE_TR_FUNCTIONS(FullColorFillTool)
TXshSimpleLevelP m_level;
TDoublePairProperty m_fillDepth;
TPropertyGroup m_prop;
TPointD m_clickPoint;
public:
FullColorFillTool();
ToolType getToolType() const override { return TTool::LevelWriteTool; }
void updateTranslation() override;
TPropertyGroup *getProperties(int targetType) override { return &m_prop; }
FillParameters getFillParameters() const;
void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override;
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
bool onPropertyChanged(std::string propertyName) override;
void onActivate() override;
int getCursorId() const override;
};
#endif // FULLCOLORFILLTOOL_H

View file

@ -401,18 +401,11 @@ bool PaintBrushTool::onPropertyChanged(std::string propertyName) {
// Selective
else if (propertyName == m_onlyEmptyAreas.getName()) {
if (m_onlyEmptyAreas.getValue() && m_colorType.getValue() == LINES) {
m_colorType.setValue(AREAS);
PaintBrushColorType = ::to_string(m_colorType.getValue());
}
PaintBrushSelective = (int)(m_onlyEmptyAreas.getValue());
}
// Areas, Lines etc.
else if (propertyName == m_colorType.getName()) {
if (m_colorType.getValue() == LINES) {
PaintBrushSelective = (int)(m_onlyEmptyAreas.getValue());
}
PaintBrushColorType = ::to_string(m_colorType.getValue());
/*--- ColorModelのCursor更新のためにSIGNALを出す ---*/
TTool::getApplication()->getCurrentTool()->notifyToolChanged();
@ -428,7 +421,7 @@ void PaintBrushTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) {
TImageP image(getImage(true));
if (m_colorType.getValue() == LINES) m_colorTypeBrush = INK;
if (m_colorType.getValue() == AREAS) m_colorTypeBrush = PAINT;
if (m_colorType.getValue() == ALL) m_colorTypeBrush = INKNPAINT;
if (m_colorType.getValue() == ALL) m_colorTypeBrush = INKNPAINT;
if (TToonzImageP ti = image) {
TRasterCM32P ras = ti->getRaster();
@ -534,7 +527,7 @@ void PaintBrushTool::onDeactivate() {
//-----------------------------------------------------------------------------
/*!
* onDeactivateでもMouseReleaseと同じ終了処理を行う
*/
*/
void PaintBrushTool::finishBrush() {
if (TToonzImageP ti = (TToonzImageP)getImage(true)) {
if (m_rasterTrack) {

View file

@ -63,14 +63,15 @@ StylePickerTool::StylePickerTool()
void StylePickerTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) {
m_oldStyleId = m_currentStyleId =
getApplication()->getCurrentLevelStyleIndex();
pick(pos, e);
pick(pos, e, false);
}
void StylePickerTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {
pick(pos, e);
}
void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e) {
void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e,
bool isDragging) {
// Area = 0, Line = 1, All = 2
int modeValue = m_colorType.getIndex();
@ -132,7 +133,8 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e) {
->getSelection()
->selectNone();
/*-- StyleIdの移動 --*/
getApplication()->setCurrentLevelStyleIndex(superPicked_StyleId);
getApplication()->setCurrentLevelStyleIndex(superPicked_StyleId,
!isDragging);
return;
}
}
@ -181,7 +183,12 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e) {
if (styleSelection) styleSelection->selectNone();
}
getApplication()->setCurrentLevelStyleIndex(styleId);
// When clicking and switching between studio palette and level palette, the
// signal broadcastColorStyleSwitched is not emitted if the picked style is
// previously selected one.
// Therefore here I set the "forceEmit" flag to true in order to emit the
// signal whenever the picking with mouse press.
getApplication()->setCurrentLevelStyleIndex(styleId, !isDragging);
}
void StylePickerTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {

View file

@ -36,7 +36,7 @@ public:
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
void pick(const TPointD &pos, const TMouseEvent &e);
void pick(const TPointD &pos, const TMouseEvent &e, bool isDragging = true);
void mouseMove(const TPointD &pos, const TMouseEvent &e) override;

View file

@ -25,6 +25,7 @@
#include "toonzqt/gutil.h"
#include "toonzqt/dvscrollwidget.h"
#include "toonzqt/lutcalibrator.h"
#include "toonzqt/viewcommandids.h"
// TnzLib includes
#include "toonz/tobjecthandle.h"
@ -124,7 +125,8 @@ ToolOptionsBox::ToolOptionsBox(QWidget *parent, bool isScrollable)
ToolOptionsBox::~ToolOptionsBox() {
std::for_each(m_controls.begin(), m_controls.end(),
std::default_delete<ToolOptionControl>());
std::for_each(m_labels.begin(), m_labels.end(), std::default_delete<QLabel>());
std::for_each(m_labels.begin(), m_labels.end(),
std::default_delete<QLabel>());
}
//-----------------------------------------------------------------------------
@ -217,6 +219,17 @@ void ToolOptionControlBuilder::visit(TDoubleProperty *p) {
control->addAction(a);
QObject::connect(a, SIGNAL(triggered()), control, SLOT(decrease()));
}
if (p->getName() == "ModifierSize") {
QAction *a;
a = cm->getAction("A_IncreaseMaxBrushThickness");
control->addAction(a);
QObject::connect(a, SIGNAL(triggered()), control,
SLOT(increaseFractional()));
a = cm->getAction("A_DecreaseMaxBrushThickness");
control->addAction(a);
QObject::connect(a, SIGNAL(triggered()), control,
SLOT(decreaseFractional()));
}
if (p->getName() == "Hardness:") {
QAction *a;
a = cm->getAction("A_IncreaseBrushHardness");
@ -522,7 +535,7 @@ ArrowToolOptionsBox::ArrowToolOptionsBox(
m_nsPosField =
new PegbarChannelField(m_tool, TStageObject::T_Y, "field", frameHandle,
objHandle, xshHandle, this);
m_zField = new PegbarChannelField(m_tool, TStageObject::T_Z, "field",
m_zField = new PegbarChannelField(m_tool, TStageObject::T_Z, "field",
frameHandle, objHandle, xshHandle, this);
m_noScaleZField = new NoScaleField(m_tool, "field");
@ -653,7 +666,7 @@ ArrowToolOptionsBox::ArrowToolOptionsBox(
m_zField->setPrecision(4);
m_noScaleZField->setPrecision(4);
bool splined = isCurrentObjectSplined();
bool splined = isCurrentObjectSplined();
if (splined != m_splined) m_splined = splined;
setSplined(m_splined);
@ -1051,7 +1064,7 @@ void ArrowToolOptionsBox::onStageObjectChange() { updateStatus(); }
//-----------------------------------------------------------------------------
/*! update the object list in combobox
*/
*/
void ArrowToolOptionsBox::updateStageObjectComboItems() {
// clear items
m_currentStageObjectCombo->clear();
@ -1080,7 +1093,7 @@ void ArrowToolOptionsBox::updateStageObjectComboItems() {
//------------------------------------------------------------------------------
/*! syncronize the current item in the combobox to the selected stage object
*/
*/
void ArrowToolOptionsBox::syncCurrentStageObjectComboItem() {
TStageObjectId curObjId = m_objHandle->getObjectId();
@ -1103,7 +1116,7 @@ void ArrowToolOptionsBox::syncCurrentStageObjectComboItem() {
//------------------------------------------------------------------------------
/*!change the current stage object when user changes it via combobox by hand
*/
*/
void ArrowToolOptionsBox::onCurrentStageObjectComboActivated(int index) {
int code = m_currentStageObjectCombo->itemData(index).toInt();
TStageObjectId id;
@ -1281,7 +1294,7 @@ SelectionToolOptionsBox::SelectionToolOptionsBox(QWidget *parent, TTool *tool,
// assert(ret);
bool ret = connect(m_scaleXField, SIGNAL(valueChange(bool)),
SLOT(onScaleXValueChanged(bool)));
ret = ret && connect(m_scaleYField, SIGNAL(valueChange(bool)),
ret = ret && connect(m_scaleYField, SIGNAL(valueChange(bool)),
SLOT(onScaleYValueChanged(bool)));
if (m_setSaveboxCheckbox)
ret = ret && connect(m_setSaveboxCheckbox, SIGNAL(toggled(bool)),
@ -1609,7 +1622,7 @@ PaintbrushToolOptionsBox::PaintbrushToolOptionsBox(QWidget *parent, TTool *tool,
dynamic_cast<ToolOptionCheckbox *>(m_controls.value("Selective"));
if (m_colorMode->getProperty()->getValue() == L"Lines")
m_selectiveMode->setEnabled(false);
m_selectiveMode->setVisible(false);
bool ret = connect(m_colorMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(onColorModeChanged(int)));
@ -1629,7 +1642,26 @@ void PaintbrushToolOptionsBox::updateStatus() {
void PaintbrushToolOptionsBox::onColorModeChanged(int index) {
const TEnumProperty::Range &range = m_colorMode->getProperty()->getRange();
bool enabled = range[index] != L"Lines";
m_selectiveMode->setEnabled(enabled);
m_selectiveMode->setVisible(enabled);
}
//=============================================================================
//
// FullColorFillToolOptionsBox
//
//=============================================================================
FullColorFillToolOptionsBox::FullColorFillToolOptionsBox(
QWidget *parent, TTool *tool, TPaletteHandle *pltHandle,
ToolHandle *toolHandle)
: ToolOptionsBox(parent) {
TPropertyGroup *props = tool->getProperties(0);
assert(props->getPropertyCount() > 0);
ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
m_layout->addStretch(0);
}
//=============================================================================
@ -1673,11 +1705,11 @@ FillToolOptionsBox::FillToolOptionsBox(QWidget *parent, TTool *tool,
bool ret = connect(m_colorMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(onColorModeChanged(int)));
ret = ret && connect(m_toolType, SIGNAL(currentIndexChanged(int)), this,
ret = ret && connect(m_toolType, SIGNAL(currentIndexChanged(int)), this,
SLOT(onToolTypeChanged(int)));
ret = ret && connect(m_onionMode, SIGNAL(toggled(bool)), this,
ret = ret && connect(m_onionMode, SIGNAL(toggled(bool)), this,
SLOT(onOnionModeToggled(bool)));
ret = ret && connect(m_multiFrameMode, SIGNAL(toggled(bool)), this,
ret = ret && connect(m_multiFrameMode, SIGNAL(toggled(bool)), this,
SLOT(onMultiFrameModeToggled(bool)));
assert(ret);
if (m_colorMode->getProperty()->getValue() == L"Lines") {
@ -2276,9 +2308,9 @@ TapeToolOptionsBox::TapeToolOptionsBox(QWidget *parent, TTool *tool,
bool ret = connect(m_typeMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(onToolTypeChanged(int)));
ret = ret && connect(m_toolMode, SIGNAL(currentIndexChanged(int)), this,
ret = ret && connect(m_toolMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(onToolModeChanged(int)));
ret = ret && connect(m_joinStrokesMode, SIGNAL(toggled(bool)), this,
ret = ret && connect(m_joinStrokesMode, SIGNAL(toggled(bool)), this,
SLOT(onJoinStrokesModeChanged()));
assert(ret);
}
@ -2326,7 +2358,7 @@ void TapeToolOptionsBox::onJoinStrokesModeChanged() {
//-----------------------------------------------------------------------------
/*! Label with background color
*/
*/
class RGBLabel final : public QWidget {
QColor m_color;
@ -2365,10 +2397,11 @@ protected:
p.setPen(Qt::black);
p.setBrush(Qt::NoBrush);
p.drawText(rect(), Qt::AlignCenter, QString("R:%1 G:%2 B:%3")
.arg(m_color.red())
.arg(m_color.green())
.arg(m_color.blue()));
p.drawText(rect(), Qt::AlignCenter,
QString("R:%1 G:%2 B:%3")
.arg(m_color.red())
.arg(m_color.green())
.arg(m_color.blue()));
}
};
@ -2636,6 +2669,74 @@ void ShiftTraceToolOptionBox::onAfterRadioBtnClicked() {
stTool->setCurrentGhostIndex(1);
}
//=============================================================================
// ZoomToolOptionBox
//-----------------------------------------------------------------------------
ZoomToolOptionsBox::ZoomToolOptionsBox(QWidget *parent, TTool *tool,
TPaletteHandle *pltHandle,
ToolHandle *toolHandle)
: ToolOptionsBox(parent) {
setFrameStyle(QFrame::StyledPanel);
setFixedHeight(26);
QAction *resetZoomAction = CommandManager::instance()->getAction(V_ZoomReset);
QPushButton *button = new QPushButton(tr("Reset Zoom"));
button->setFixedHeight(20);
button->addAction(resetZoomAction);
connect(button, SIGNAL(clicked()), resetZoomAction, SLOT(trigger()));
m_layout->addStretch(1);
m_layout->addWidget(button, 0);
}
//=============================================================================
// RotateToolOptionBox
//-----------------------------------------------------------------------------
RotateToolOptionsBox::RotateToolOptionsBox(QWidget *parent, TTool *tool,
TPaletteHandle *pltHandle,
ToolHandle *toolHandle)
: ToolOptionsBox(parent) {
setFrameStyle(QFrame::StyledPanel);
setFixedHeight(26);
QAction *resetRotationAction =
CommandManager::instance()->getAction(V_RotateReset);
QPushButton *button = new QPushButton(tr("Reset Rotation"));
button->setFixedHeight(20);
button->addAction(resetRotationAction);
connect(button, SIGNAL(clicked()), resetRotationAction, SLOT(trigger()));
m_layout->addStretch(1);
m_layout->addWidget(button, 0);
}
//=============================================================================
// HandToolOptionBox
//-----------------------------------------------------------------------------
HandToolOptionsBox::HandToolOptionsBox(QWidget *parent, TTool *tool,
TPaletteHandle *pltHandle,
ToolHandle *toolHandle)
: ToolOptionsBox(parent) {
setFrameStyle(QFrame::StyledPanel);
setFixedHeight(26);
QAction *resetPositionAction =
CommandManager::instance()->getAction(V_PositionReset);
QPushButton *button = new QPushButton(tr("Reset Position"));
button->setFixedHeight(20);
button->addAction(resetPositionAction);
connect(button, SIGNAL(clicked()), resetPositionAction, SLOT(trigger()));
m_layout->addStretch(1);
m_layout->addWidget(button, 0);
}
//=============================================================================
// ToolOptions
//-----------------------------------------------------------------------------
@ -2711,7 +2812,7 @@ void ToolOptions::onToolSwitched() {
TTool *tool = app->getCurrentTool()->getTool();
if (tool) {
// c'e' un tool corrente
ToolOptionsBox *panel = 0;
ToolOptionsBox *panel = 0;
std::map<TTool *, ToolOptionsBox *>::iterator it = m_panels.find(tool);
if (it == m_panels.end()) {
// ... senza panel associato
@ -2727,9 +2828,13 @@ void ToolOptions::onToolSwitched() {
panel = new TypeToolOptionsBox(0, tool, currPalette, currTool);
else if (tool->getName() == T_PaintBrush)
panel = new PaintbrushToolOptionsBox(0, tool, currPalette, currTool);
else if (tool->getName() == T_Fill)
panel = new FillToolOptionsBox(0, tool, currPalette, currTool);
else if (tool->getName() == T_Eraser)
else if (tool->getName() == T_Fill) {
if (tool->getTargetType() & TTool::RasterImage)
panel =
new FullColorFillToolOptionsBox(0, tool, currPalette, currTool);
else
panel = new FillToolOptionsBox(0, tool, currPalette, currTool);
} else if (tool->getName() == T_Eraser)
panel = new EraserToolOptionsBox(0, tool, currPalette, currTool);
else if (tool->getName() == T_Tape)
panel = new TapeToolOptionsBox(0, tool, currPalette, currTool);
@ -2746,6 +2851,12 @@ void ToolOptions::onToolSwitched() {
app->getPaletteController());
else if (tool->getName() == "T_ShiftTrace")
panel = new ShiftTraceToolOptionBox(this, tool);
else if (tool->getName() == T_Zoom)
panel = new ZoomToolOptionsBox(0, tool, currPalette, currTool);
else if (tool->getName() == T_Rotate)
panel = new RotateToolOptionsBox(0, tool, currPalette, currTool);
else if (tool->getName() == T_Hand)
panel = new HandToolOptionsBox(0, tool, currPalette, currTool);
else
panel = tool->createOptionsBox(); // Only this line should remain out
// of that if/else monstrosity

View file

@ -192,7 +192,7 @@ void ToolOptionSlider::onValueChanged(bool isDragging) {
//-----------------------------------------------------------------------------
void ToolOptionSlider::increase() {
void ToolOptionSlider::increase(double step) {
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
// active only if the belonging combo-viewer is visible
if (!isInVisibleViewer(this)) return;
@ -201,7 +201,7 @@ void ToolOptionSlider::increase() {
double minValue, maxValue;
getRange(minValue, maxValue);
value += 1;
value += step;
if (value > maxValue) value = maxValue;
setValue(value);
@ -213,7 +213,11 @@ void ToolOptionSlider::increase() {
//-----------------------------------------------------------------------------
void ToolOptionSlider::decrease() {
void ToolOptionSlider::increaseFractional() { increase(0.06); }
//-----------------------------------------------------------------------------
void ToolOptionSlider::decrease(double step) {
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
// active only if the belonging combo-viewer is visible
if (!isInVisibleViewer(this)) return;
@ -222,7 +226,7 @@ void ToolOptionSlider::decrease() {
double minValue, maxValue;
getRange(minValue, maxValue);
value -= 1;
value -= step;
if (value < minValue) value = minValue;
setValue(value);
@ -232,6 +236,10 @@ void ToolOptionSlider::decrease() {
repaint();
}
//-----------------------------------------------------------------------------
void ToolOptionSlider::decreaseFractional() { decrease(0.06); }
//=============================================================================
ToolOptionPairSlider::ToolOptionPairSlider(TTool *tool,

View file

@ -119,8 +119,10 @@ public:
protected slots:
void onValueChanged(bool isDragging);
void increase();
void decrease();
void increase(double step = 1.0);
void decrease(double step = 1.0);
void increaseFractional();
void decreaseFractional();
};
//-----------------------------------------------------------------------------

View file

@ -244,7 +244,7 @@ void ColorModelViewer::contextMenuEvent(QContextMenuEvent *event) {
menu.addSeparator();
QString shortcut = QString::fromStdString(
CommandManager::instance()->getShortcutFromId(V_ZoomReset));
CommandManager::instance()->getShortcutFromId(V_ViewReset));
QAction *reset = menu.addAction(tr("Reset View") + "\t " + shortcut);
connect(reset, SIGNAL(triggered()), m_imageViewer, SLOT(resetView()));

View file

@ -130,7 +130,8 @@ void TColumnSelection::explodeChild() {
static bool canMergeColumns(int column, int mColumn, bool forMatchlines) {
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
if (xsh->getColumn(column)->isLocked()) return false;
if (!xsh || !xsh->getColumn(column) || xsh->getColumn(column)->isLocked())
return false;
int start, end;
xsh->getCellRange(column, start, end);

View file

@ -29,6 +29,7 @@
#include "toonz/palettecontroller.h"
#include "toonz/toonzfolders.h"
#include "toonz/preferences.h"
#include "toonz/tproject.h"
// TnzQt includes
#include "toonzqt/menubarcommand.h"
@ -616,11 +617,13 @@ void ComboViewerPanel::changeWindowTitle() {
// if the frame type is "scene editing"
if (app->getCurrentFrame()->isEditingScene()) {
QString sceneName = QString::fromStdWString(scene->getSceneName());
TProject *project = scene->getProject();
QString projectName = QString::fromStdString(project->getName().getName());
QString sceneName = QString::fromStdWString(scene->getSceneName());
if (sceneName.isEmpty()) sceneName = tr("Untitled");
if (app->getCurrentScene()->getDirtyFlag()) sceneName += QString(" *");
name = tr("Scene: ") + sceneName;
if (app->getCurrentScene()->getDirtyFlag()) sceneName += QString("*");
name = tr("Scene: ") + sceneName + tr(" :: Project: ") + projectName;
if (frame >= 0)
name =
name + tr(" :: Frame: ") + tr(std::to_string(frame + 1).c_str());

View file

@ -316,7 +316,7 @@ CommandBarListTree::CommandBarListTree(QWidget* parent) : QTreeWidget(parent) {
addFolder(ShortcutTree::tr("Right-click Menu Commands"),
RightClickMenuCommandType);
addFolder(ShortcutTree::tr("Tool Modifiers"), ToolModifierCommandType);
addFolder(ShortcutTree::tr("Visualization"), ZoomCommandType);
addFolder(ShortcutTree::tr("Visualization"), VisualizationButtonCommandType);
addFolder(ShortcutTree::tr("Misc"), MiscCommandType);
addFolder(ShortcutTree::tr("RGBA Channels"), RGBACommandType);

View file

@ -70,9 +70,8 @@ void doUpdateXSheet(TXshSimpleLevel *sl, std::vector<TFrameId> oldFids,
cells[i].m_level->getType() == CHILD_XSHLEVEL) {
TXshChildLevel *level = cells[i].m_level->getChildLevel();
// make sure we haven't already checked the level
if (level &&
std::find(childLevels.begin(), childLevels.end(), level) ==
childLevels.end()) {
if (level && std::find(childLevels.begin(), childLevels.end(),
level) == childLevels.end()) {
childLevels.push_back(level);
TXsheet *subXsh = level->getXsheet();
doUpdateXSheet(sl, oldFids, newFids, subXsh, childLevels);
@ -101,8 +100,8 @@ void doUpdateXSheet(TXshSimpleLevel *sl, std::vector<TFrameId> oldFids,
//-----------------------------------------------------------------------------
void updateXSheet(TXshSimpleLevel *sl, std::vector<TFrameId> oldFids,
std::vector<TFrameId> newFids) {
static void updateXSheet(TXshSimpleLevel *sl, std::vector<TFrameId> oldFids,
std::vector<TFrameId> newFids) {
std::vector<TXshChildLevel *> childLevels;
TXsheet *xsh =
TApp::instance()->getCurrentScene()->getScene()->getTopXsheet();
@ -145,7 +144,7 @@ void makeSpaceForFids(TXshSimpleLevel *sl,
if (Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled())
updateXSheet(sl, oldFids, fids);
sl->renumber(fids);
sl->setDirtyFlag(true);
sl->setDirtyFlag(true);
}
}
@ -250,10 +249,10 @@ bool pasteAreasWithoutUndo(const QMimeData *data, TXshSimpleLevel *sl,
affine *= sc;
int i;
TRectD boxD;
if (rects.size() > 0) boxD = rects[0];
if (rects.size() > 0) boxD = rects[0];
if (strokes.size() > 0) boxD = strokes[0].getBBox();
for (i = 0; i < rects.size(); i++) boxD += rects[i];
for (i = 0; i < strokes.size(); i++) boxD += strokes[i].getBBox();
for (i = 0; i < strokes.size(); i++) boxD += strokes[i].getBBox();
boxD = affine * boxD;
TRect box = ToonzImageUtils::convertWorldToRaster(boxD, ti);
TPoint pos = box.getP00();
@ -309,10 +308,10 @@ bool pasteAreasWithoutUndo(const QMimeData *data, TXshSimpleLevel *sl,
affine *= sc;
int i;
TRectD boxD;
if (rects.size() > 0) boxD = rects[0];
if (rects.size() > 0) boxD = rects[0];
if (strokes.size() > 0) boxD = strokes[0].getBBox();
for (i = 0; i < rects.size(); i++) boxD += rects[i];
for (i = 0; i < strokes.size(); i++) boxD += strokes[i].getBBox();
for (i = 0; i < strokes.size(); i++) boxD += strokes[i].getBBox();
boxD = affine * boxD;
TRect box = TRasterImageUtils::convertWorldToRaster(boxD, ri);
TPoint pos = box.getP00();
@ -604,13 +603,13 @@ public:
int i;
TRectD boxD;
if (rects.size() > 0) boxD = rects[0];
if (rects.size() > 0) boxD = rects[0];
if (strokes.size() > 0) boxD = strokes[0].getBBox();
for (i = 0; i < rects.size(); i++) boxD += rects[i];
for (i = 0; i < strokes.size(); i++) boxD += strokes[i].getBBox();
boxD = affine * boxD;
TRect box = ToonzImageUtils::convertWorldToRaster(boxD, ti);
TPoint pos = box.getP00();
for (i = 0; i < strokes.size(); i++) boxD += strokes[i].getBBox();
boxD = affine * boxD;
TRect box = ToonzImageUtils::convertWorldToRaster(boxD, ti);
TPoint pos = box.getP00();
TRasterCM32P app = ras;
TRop::over(ti->getRaster(), app, pos, affine);
ToolUtils::updateSaveBox(m_level, *it);
@ -639,13 +638,13 @@ public:
affine *= sc;
int i;
TRectD boxD;
if (rects.size() > 0) boxD = rects[0];
if (rects.size() > 0) boxD = rects[0];
if (strokes.size() > 0) boxD = strokes[0].getBBox();
for (i = 0; i < rects.size(); i++) boxD += rects[i];
for (i = 0; i < strokes.size(); i++) boxD += strokes[i].getBBox();
boxD = affine * boxD;
TRect box = TRasterImageUtils::convertWorldToRaster(boxD, ri);
TPoint pos = box.getP00();
for (i = 0; i < strokes.size(); i++) boxD += strokes[i].getBBox();
boxD = affine * boxD;
TRect box = TRasterImageUtils::convertWorldToRaster(boxD, ri);
TPoint pos = box.getP00();
TRasterCM32P app = ras;
if (app)
TRop::over(ri->getRaster(), app, ri->getPalette(), pos, affine);
@ -985,7 +984,7 @@ public:
updateXSheet(m_sl.getPointer(), newFrames, m_oldLevelFrameId);
}
m_sl->renumber(m_oldLevelFrameId);
m_sl->setDirtyFlag(true);
m_sl->setDirtyFlag(true);
TApp::instance()
->getPaletteController()
->getCurrentLevelPalette()
@ -1309,8 +1308,8 @@ public:
m_level->renumber(fids);
TSelection *selection = TSelection::getCurrent();
if (selection) selection->selectNone();
m_level->setDirtyFlag(true);
TApp::instance()->getCurrentLevel()->notifyLevelChange();
m_level->setDirtyFlag(true);
TApp::instance()->getCurrentLevel()->notifyLevelChange();
}
void undo() const override {
std::vector<TFrameId> fids;
@ -1725,7 +1724,7 @@ public:
// TImageCache::instance()->add("UndoInsertEmptyFrames"+QString::number((UINT)this),
// img);
TImageCache::instance()->add(
"UndoInsertEmptyFrames" + QString::number((uintptr_t) this), img);
"UndoInsertEmptyFrames" + QString::number((uintptr_t)this), img);
}
}
m_updateXSheet =
@ -1735,7 +1734,7 @@ public:
~UndoInsertEmptyFrames() {
// TImageCache::instance()->remove("UndoInsertEmptyFrames"+QString::number((UINT)this));
TImageCache::instance()->remove("UndoInsertEmptyFrames" +
QString::number((uintptr_t) this));
QString::number((uintptr_t)this));
}
void undo() const override {
@ -1747,7 +1746,7 @@ public:
updateXSheet(m_level.getPointer(), newFrames, m_oldFrames);
}
m_level->renumber(m_oldFrames);
m_level->setDirtyFlag(true);
m_level->setDirtyFlag(true);
TApp::instance()->getCurrentLevel()->notifyLevelChange();
}
@ -1762,7 +1761,7 @@ public:
// (TToonzImageP)TImageCache::instance()->get("UndoInsertEmptyFrames"+QString::number((UINT)this),
// true);
TToonzImageP image = (TToonzImageP)TImageCache::instance()->get(
"UndoInsertEmptyFrames" + QString::number((uintptr_t) this), true);
"UndoInsertEmptyFrames" + QString::number((uintptr_t)this), true);
if (!image) return;
for (it = m_frames.begin(); it != m_frames.end(); ++it)
m_level->setFrame(*it, image);
@ -2039,7 +2038,7 @@ public:
m_level->renumber(m_oldFrames);
TSelection *selection = TSelection::getCurrent();
if (selection) selection->selectNone();
m_level->setDirtyFlag(true);
m_level->setDirtyFlag(true);
TApp::instance()->getCurrentLevel()->notifyLevelChange();
}
void redo() const override {
@ -2205,7 +2204,7 @@ public:
updateXSheet(m_level.getPointer(), newFrames, m_oldFrames);
}
m_level->renumber(m_oldFrames);
m_level->setDirtyFlag(true);
m_level->setDirtyFlag(true);
TApp::instance()->getCurrentLevel()->notifyLevelChange();
}
void redo() const override {

View file

@ -137,6 +137,7 @@ TPanel *OpenFloatingPanel::getOrOpenFloatingPanel(
QString::fromStdString(panelType));
if (!panel) return 0; // it should never happen
// panel->setWindowTitle(QObject::tr(m_title.toStdString().c_str()));
panel->restoreFloatingPanelState();
panel->setFloating(true);
panel->show();
panel->raise();

View file

@ -59,6 +59,7 @@ FxParamEditorPopup::FxParamEditorPopup()
}
//=============================================================================
/*
OpenPopupCommandHandler<FxParamEditorPopup> openFxParamEditorPopup(
MI_FxParamEditor);
*/

View file

@ -39,6 +39,7 @@
#include <QMouseEvent>
#include <QWheelEvent>
#include <QOpenGLFramebufferObject>
#include <QGestureEvent>
//===================================================================================
@ -118,8 +119,8 @@ class FlipZoomer final : public ImageUtils::ShortcutZoomer {
public:
FlipZoomer(ImageViewer *parent) : ShortcutZoomer(parent) {}
bool zoom(bool zoomin, bool resetZoom) override {
static_cast<ImageViewer *>(getWidget())->zoomQt(zoomin, resetZoom);
bool zoom(bool zoomin, bool resetView) override {
static_cast<ImageViewer *>(getWidget())->zoomQt(zoomin, resetView);
return true;
}
@ -128,6 +129,11 @@ public:
return true;
}
bool resetZoom() override {
static_cast<ImageViewer *>(getWidget())->resetZoom();
return true;
}
bool toggleFullScreen(bool quit) override {
if (ImageUtils::FullScreenWidget *fsWidget =
dynamic_cast<ImageUtils::FullScreenWidget *>(
@ -218,7 +224,8 @@ ImageViewer::ImageViewer(QWidget *parent, FlipBook *flipbook,
, m_isColorModel(false)
, m_histogramPopup(0)
, m_isRemakingPreviewFx(false)
, m_rectRGBPick(false) {
, m_rectRGBPick(false)
, m_firstImage(true) {
m_visualSettings.m_sceneProperties =
TApp::instance()->getCurrentScene()->getScene()->getProperties();
m_visualSettings.m_drawExternalBG = true;
@ -227,6 +234,11 @@ ImageViewer::ImageViewer(QWidget *parent, FlipBook *flipbook,
setMouseTracking(true);
setAttribute(Qt::WA_AcceptTouchEvents);
grabGesture(Qt::SwipeGesture);
grabGesture(Qt::PanGesture);
grabGesture(Qt::PinchGesture);
if (m_isHistogramEnable)
m_histogramPopup = new HistogramPopup(tr("Flipbook Histogram"));
@ -237,8 +249,6 @@ ImageViewer::ImageViewer(QWidget *parent, FlipBook *flipbook,
//-----------------------------------------------------------------------------
void ImageViewer::contextMenuEvent(QContextMenuEvent *event) {
if (!m_flipbook) return;
QAction *action;
if (m_isColorModel) {
@ -248,56 +258,59 @@ void ImageViewer::contextMenuEvent(QContextMenuEvent *event) {
QMenu *menu = new QMenu(this);
if (m_flipbook->getPreviewedFx()) {
if (!(windowState() & Qt::WindowFullScreen)) {
action = menu->addAction(tr("Clone Preview"));
if (m_flipbook) {
if (m_flipbook->getPreviewedFx()) {
if (!(windowState() & Qt::WindowFullScreen)) {
action = menu->addAction(tr("Clone Preview"));
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(MI_ClonePreview)));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(clonePreview()));
}
if (m_flipbook->isFreezed()) {
action = menu->addAction(tr("Unfreeze Preview"));
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(MI_FreezePreview)));
connect(action, SIGNAL(triggered()), m_flipbook,
SLOT(unfreezePreview()));
} else {
action = menu->addAction(tr("Freeze Preview"));
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(MI_FreezePreview)));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(freezePreview()));
}
action = menu->addAction(tr("Regenerate Preview"));
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(MI_ClonePreview)));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(clonePreview()));
CommandManager::instance()->getKeyFromId(MI_RegeneratePreview)));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerate()));
action = menu->addAction(tr("Regenerate Frame Preview"));
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(MI_RegenerateFramePr)));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerateFrame()));
menu->addSeparator();
}
if (m_flipbook->isFreezed()) {
action = menu->addAction(tr("Unfreeze Preview"));
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(MI_FreezePreview)));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(unfreezePreview()));
} else {
action = menu->addAction(tr("Freeze Preview"));
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(MI_FreezePreview)));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(freezePreview()));
action = menu->addAction(tr("Load / Append Images"));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(loadImages()));
// history of the loaded paths of flipbook
action = CommandManager::instance()->getAction(MI_LoadRecentImage);
menu->addAction(action);
action->setParent(m_flipbook);
if (m_flipbook->isSavable()) {
action = menu->addAction(tr("Save Images"));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(saveImages()));
}
action = menu->addAction(tr("Regenerate Preview"));
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(MI_RegeneratePreview)));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerate()));
action = menu->addAction(tr("Regenerate Frame Preview"));
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(MI_RegenerateFramePr)));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerateFrame()));
menu->addSeparator();
}
action = menu->addAction(tr("Load / Append Images"));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(loadImages()));
// history of the loaded paths of flipbook
action = CommandManager::instance()->getAction(MI_LoadRecentImage);
menu->addAction(action);
action->setParent(m_flipbook);
if (m_flipbook->isSavable()) {
action = menu->addAction(tr("Save Images"));
connect(action, SIGNAL(triggered()), m_flipbook, SLOT(saveImages()));
}
menu->addSeparator();
QAction *reset = menu->addAction(tr("Reset View"));
reset->setShortcut(
QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomReset)));
QKeySequence(CommandManager::instance()->getKeyFromId(V_ViewReset)));
connect(reset, SIGNAL(triggered()), SLOT(resetView()));
QAction *fit = menu->addAction(tr("Fit To Window"));
@ -305,42 +318,45 @@ void ImageViewer::contextMenuEvent(QContextMenuEvent *event) {
QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomFit)));
connect(fit, SIGNAL(triggered()), SLOT(fitView()));
if (m_flipbook) {
#ifdef _WIN32
if (ImageUtils::FullScreenWidget *fsWidget =
dynamic_cast<ImageUtils::FullScreenWidget *>(parentWidget())) {
bool isFullScreen = (fsWidget->windowState() & Qt::WindowFullScreen) != 0;
if (ImageUtils::FullScreenWidget *fsWidget =
dynamic_cast<ImageUtils::FullScreenWidget *>(parentWidget())) {
bool isFullScreen = (fsWidget->windowState() & Qt::WindowFullScreen) != 0;
action = menu->addAction(isFullScreen ? tr("Exit Full Screen Mode")
: tr("Full Screen Mode"));
action = menu->addAction(isFullScreen ? tr("Exit Full Screen Mode")
: tr("Full Screen Mode"));
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(V_ShowHideFullScreen)));
connect(action, SIGNAL(triggered()), fsWidget, SLOT(toggleFullScreen()));
}
action->setShortcut(QKeySequence(
CommandManager::instance()->getKeyFromId(V_ShowHideFullScreen)));
connect(action, SIGNAL(triggered()), fsWidget, SLOT(toggleFullScreen()));
}
#endif
bool addedSep = false;
bool addedSep = false;
if (m_isHistogramEnable &&
visibleRegion().contains(event->pos() * getDevPixRatio())) {
menu->addSeparator();
addedSep = true;
action = menu->addAction(tr("Show Histogram"));
connect(action, SIGNAL(triggered()), SLOT(showHistogram()));
}
if (m_isHistogramEnable &&
visibleRegion().contains(event->pos() * getDevPixRatio())) {
menu->addSeparator();
addedSep = true;
action = menu->addAction(tr("Show Histogram"));
connect(action, SIGNAL(triggered()), SLOT(showHistogram()));
}
if (m_visualSettings.m_doCompare) {
if (!addedSep) menu->addSeparator();
action = menu->addAction(tr("Swap Compared Images"));
connect(action, SIGNAL(triggered()), SLOT(swapCompared()));
if (m_visualSettings.m_doCompare) {
if (!addedSep) menu->addSeparator();
action = menu->addAction(tr("Swap Compared Images"));
connect(action, SIGNAL(triggered()), SLOT(swapCompared()));
}
}
menu->exec(event->globalPos());
action = CommandManager::instance()->getAction(MI_LoadRecentImage);
action->setParent(0);
if (m_flipbook) {
action = CommandManager::instance()->getAction(MI_LoadRecentImage);
action->setParent(0);
}
delete menu;
update();
@ -372,10 +388,19 @@ ImageViewer::~ImageViewer() {
//-----------------------------------------------------------------------------
/*! Set current image to \b image and update. If Histogram is visible set its
* image.
*/
*/
void ImageViewer::setImage(TImageP image) {
m_image = image;
if (m_image && m_firstImage) {
m_firstImage = false;
fitView();
// when the viewer size is large enough, limit the zoom ratio to 100% so
// that the image is shown in actual pixel size without jaggies due to
// resampling.
if (fabs(m_viewAff.det()) > 1.0) resetView();
}
if (m_isHistogramEnable && m_histogramPopup->isVisible())
m_histogramPopup->setImage(image);
if (!isColorModel())
@ -557,7 +582,7 @@ void ImageViewer::paintGL() {
} else if (m_draggingZoomSelection || m_rectRGBPick) {
fromPos = TPoint(m_pressedMousePos.x - width() * 0.5,
height() * 0.5 - m_pressedMousePos.y);
toPos = TPoint(m_pos.x() - width() * 0.5, height() * 0.5 - m_pos.y());
toPos = TPoint(m_pos.x() - width() * 0.5, height() * 0.5 - m_pos.y());
}
if (fromPos != TPoint() || toPos != TPoint()) {
if (m_rectRGBPick) {
@ -596,7 +621,7 @@ void ImageViewer::paintGL() {
//------------------------------------------------------------------------------
/*! Add to current trasformation matrix a \b delta traslation.
*/
*/
void ImageViewer::panQt(const QPoint &delta) {
if (delta == QPoint()) return;
@ -660,6 +685,14 @@ void ImageViewer::zoomQt(bool forward, bool reset) {
//-----------------------------------------------------------------------------
void ImageViewer::resetZoom() {
double oldZoomScale = sqrt(m_viewAff.det());
setViewAff(TScale(1.0 / oldZoomScale) * m_viewAff);
update();
}
//-----------------------------------------------------------------------------
void ImageViewer::dragCompare(const QPoint &dp) {
if (m_compareSettings.m_dragCompareX)
m_compareSettings.m_compareX += ((double)dp.x()) / width();
@ -730,9 +763,15 @@ void ImageViewer::updateCursor(const TPoint &curPos) {
//---------------------------------------------------------------------------------------------
/*! If middle button is pressed pan the image. Update current mouse position.
*/
*/
void ImageViewer::mouseMoveEvent(QMouseEvent *event) {
if (!m_image) return;
if (m_gestureActive && m_touchDevice == QTouchDevice::TouchScreen &&
!m_stylusUsed) {
return;
}
QPoint curQPos = event->pos() * getDevPixRatio();
TPoint curPos = TPoint(curQPos.x(), curQPos.y());
@ -819,7 +858,7 @@ void ImageViewer::mouseMoveEvent(QMouseEvent *event) {
//---------------------------------------------------------------------------------------------
/*! notify the color picked by rgb picker to palette controller
*/
*/
void ImageViewer::setPickedColorToStyleEditor(const TPixel32 &color) {
// do not modify the style #0
TPaletteHandle *ph =
@ -831,7 +870,7 @@ void ImageViewer::setPickedColorToStyleEditor(const TPixel32 &color) {
//---------------------------------------------------------------------------------------------
/*! rgb picking
*/
*/
void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) {
if (!m_isHistogramEnable) return;
if (!m_histogramPopup->isVisible()) return;
@ -875,7 +914,7 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) {
//---------------------------------------------------------------------------------------------
/*! rectangular rgb picking. The picked color will be an average of pixels in
* specified rectangle
*/
*/
void ImageViewer::rectPickColor(bool putValueToStyleEditor) {
if (!m_isHistogramEnable) return;
if (!m_histogramPopup->isVisible()) return;
@ -939,6 +978,13 @@ int ImageViewer::getDragType(const TPoint &pos, const TRect &loadbox) {
//-------------------------------------------------------------------------------
void ImageViewer::mouseDoubleClickEvent(QMouseEvent *event) {
if (!m_image) return;
// qDebug() << "[mouseDoubleClickEvent]";
if (m_gestureActive && !m_stylusUsed) {
m_gestureActive = false;
fitView();
return;
}
if (m_visualSettings.m_defineLoadbox && m_flipbook) {
m_flipbook->setLoadbox(TRect());
update();
@ -950,6 +996,13 @@ void ImageViewer::mouseDoubleClickEvent(QMouseEvent *event) {
void ImageViewer::mousePressEvent(QMouseEvent *event) {
if (!m_image) return;
// qDebug() << "[mousePressEvent]";
if (m_gestureActive && m_touchDevice == QTouchDevice::TouchScreen &&
!m_stylusUsed) {
return;
}
m_pos = event->pos() * getDevPixRatio();
m_pressedMousePos = TPoint(m_pos.x(), m_pos.y());
m_mouseButton = event->button();
@ -995,7 +1048,7 @@ void ImageViewer::mousePressEvent(QMouseEvent *event) {
//-----------------------------------------------------------------------------
/*! Reset current mouse position and current mouse button event.
*/
*/
void ImageViewer::mouseReleaseEvent(QMouseEvent *event) {
if (!m_image) return;
if (m_draggingZoomSelection && !m_visualSettings.m_defineLoadbox) {
@ -1026,19 +1079,64 @@ void ImageViewer::mouseReleaseEvent(QMouseEvent *event) {
m_mouseButton = Qt::NoButton;
m_compareSettings.m_dragCompareX = m_compareSettings.m_dragCompareY = false;
m_gestureActive = false;
m_zooming = false;
m_panning = false;
m_stylusUsed = false;
event->ignore();
}
//-----------------------------------------------------------------------------
/*! Apply zoom.
*/
*/
void ImageViewer::wheelEvent(QWheelEvent *event) {
if (!m_image) return;
if (event->orientation() == Qt::Horizontal) return;
int delta = event->delta() > 0 ? 120 : -120;
QPoint center(event->pos().x() * getDevPixRatio() - width() / 2,
-event->pos().y() * getDevPixRatio() + height() / 2);
zoomQt(center, exp(0.001 * delta));
int delta = 0;
switch (event->source()) {
case Qt::MouseEventNotSynthesized: {
if (event->modifiers() & Qt::AltModifier)
delta = event->angleDelta().x();
else
delta = event->angleDelta().y();
break;
}
case Qt::MouseEventSynthesizedBySystem: {
QPoint numPixels = event->pixelDelta();
QPoint numDegrees = event->angleDelta() / 8;
if (!numPixels.isNull()) {
delta = event->pixelDelta().y();
} else if (!numDegrees.isNull()) {
QPoint numSteps = numDegrees / 15;
delta = numSteps.y();
}
break;
}
default: // Qt::MouseEventSynthesizedByQt,
// Qt::MouseEventSynthesizedByApplication
{
std::cout << "not supported event: Qt::MouseEventSynthesizedByQt, "
"Qt::MouseEventSynthesizedByApplication"
<< std::endl;
break;
}
} // end switch
if (abs(delta) > 0) {
if ((m_gestureActive == true &&
m_touchDevice == QTouchDevice::TouchScreen) ||
m_gestureActive == false) {
int delta = event->delta() > 0 ? 120 : -120;
QPoint center(event->pos().x() * getDevPixRatio() - width() / 2,
-event->pos().y() * getDevPixRatio() + height() / 2);
zoomQt(center, exp(0.001 * delta));
}
}
event->accept();
}
//-----------------------------------------------------------------------------
@ -1168,9 +1266,182 @@ void ImageViewer::onContextAboutToBeDestroyed() {
doneCurrent();
}
//------------------------------------------------------------------
void ImageViewer::tabletEvent(QTabletEvent *e) {
// qDebug() << "[tabletEvent]";
if (e->type() == QTabletEvent::TabletPress) {
m_stylusUsed = e->pointerType() ? true : false;
} else if (e->type() == QTabletEvent::TabletRelease) {
m_stylusUsed = false;
}
e->accept();
}
//------------------------------------------------------------------
void ImageViewer::gestureEvent(QGestureEvent *e) {
// qDebug() << "[gestureEvent]";
m_gestureActive = false;
if (QGesture *swipe = e->gesture(Qt::SwipeGesture)) {
m_gestureActive = true;
} else if (QGesture *pan = e->gesture(Qt::PanGesture)) {
m_gestureActive = true;
}
if (QGesture *pinch = e->gesture(Qt::PinchGesture)) {
QPinchGesture *gesture = static_cast<QPinchGesture *>(pinch);
QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
QPoint firstCenter = gesture->centerPoint().toPoint();
if (m_touchDevice == QTouchDevice::TouchScreen)
firstCenter = mapFromGlobal(firstCenter);
if (gesture->state() == Qt::GestureStarted) {
m_gestureActive = true;
} else if (gesture->state() == Qt::GestureFinished) {
m_gestureActive = false;
m_zooming = false;
m_scaleFactor = 0.0;
} else {
if (changeFlags & QPinchGesture::ScaleFactorChanged) {
double scaleFactor = gesture->scaleFactor();
// the scale factor makes for too sensitive scaling
// divide the change in half
if (scaleFactor > 1) {
double decimalValue = scaleFactor - 1;
decimalValue /= 1.5;
scaleFactor = 1 + decimalValue;
} else if (scaleFactor < 1) {
double decimalValue = 1 - scaleFactor;
decimalValue /= 1.5;
scaleFactor = 1 - decimalValue;
}
if (!m_zooming) {
double delta = scaleFactor - 1;
m_scaleFactor += delta;
if (m_scaleFactor > .2 || m_scaleFactor < -.2) {
m_zooming = true;
}
}
if (m_zooming) {
const QPoint center(
firstCenter.x() * getDevPixRatio() - width() / 2,
-firstCenter.y() * getDevPixRatio() + height() / 2);
zoomQt(center, scaleFactor);
m_panning = false;
}
m_gestureActive = true;
}
if (changeFlags & QPinchGesture::CenterPointChanged) {
QPointF centerDelta = (gesture->centerPoint() * getDevPixRatio()) -
(gesture->lastCenterPoint() * getDevPixRatio());
if (centerDelta.manhattanLength() > 1) {
// panQt(centerDelta.toPoint());
}
m_gestureActive = true;
}
}
}
e->accept();
}
void ImageViewer::touchEvent(QTouchEvent *e, int type) {
// qDebug() << "[touchEvent]";
if (type == QEvent::TouchBegin) {
m_touchActive = true;
m_firstPanPoint = e->touchPoints().at(0).pos();
// obtain device type
m_touchDevice = e->device()->type();
} else if (m_touchActive) {
// touchpads must have 2 finger panning for tools and navigation to be
// functional on other devices, 1 finger panning is preferred
if ((e->touchPoints().count() == 2 &&
m_touchDevice == QTouchDevice::TouchPad) ||
(e->touchPoints().count() == 1 &&
m_touchDevice == QTouchDevice::TouchScreen)) {
QTouchEvent::TouchPoint panPoint = e->touchPoints().at(0);
if (!m_panning) {
QPointF deltaPoint = panPoint.pos() - m_firstPanPoint;
// minimize accidental and jerky zooming/rotating during 2 finger
// panning
if ((deltaPoint.manhattanLength() > 100) && !m_zooming) {
m_panning = true;
}
}
if (m_panning) {
QPoint curPos = panPoint.pos().toPoint() * getDevPixRatio();
QPoint lastPos = panPoint.lastPos().toPoint() * getDevPixRatio();
QPoint centerDelta = curPos - lastPos;
panQt(centerDelta);
}
}
}
if (type == QEvent::TouchEnd || type == QEvent::TouchCancel) {
m_touchActive = false;
m_panning = false;
}
e->accept();
}
bool ImageViewer::event(QEvent *e) {
/*
switch (e->type()) {
case QEvent::TabletPress: {
QTabletEvent *te = static_cast<QTabletEvent *>(e);
qDebug() << "[event] TabletPress: pointerType(" << te->pointerType()
<< ") device(" << te->device() << ")";
} break;
case QEvent::TabletRelease:
qDebug() << "[event] TabletRelease";
break;
case QEvent::TouchBegin:
qDebug() << "[event] TouchBegin";
break;
case QEvent::TouchEnd:
qDebug() << "[event] TouchEnd";
break;
case QEvent::TouchCancel:
qDebug() << "[event] TouchCancel";
break;
case QEvent::MouseButtonPress:
qDebug() << "[event] MouseButtonPress";
break;
case QEvent::MouseButtonDblClick:
qDebug() << "[event] MouseButtonDblClick";
break;
case QEvent::MouseButtonRelease:
qDebug() << "[event] MouseButtonRelease";
break;
case QEvent::Gesture:
qDebug() << "[event] Gesture";
break;
default:
break;
}
*/
if (e->type() == QEvent::Gesture && CommandManager::instance()
->getAction(MI_TouchGestureControl)
->isChecked()) {
gestureEvent(static_cast<QGestureEvent *>(e));
return true;
}
if ((e->type() == QEvent::TouchBegin || e->type() == QEvent::TouchEnd ||
e->type() == QEvent::TouchCancel || e->type() == QEvent::TouchUpdate) &&
CommandManager::instance()
->getAction(MI_TouchGestureControl)
->isChecked()) {
touchEvent(static_cast<QTouchEvent *>(e), e->type());
m_gestureActive = true;
return true;
}
return GLWidgetForHighDpi::event(e);
}
//-----------------------------------------------------------------------------
/*! load image from history
*/
*/
class LoadRecentFlipbookImagesCommandHandler final : public MenuItemHandler {
public:
LoadRecentFlipbookImagesCommandHandler()
@ -1198,7 +1469,7 @@ public:
//-----------------------------------------------------------------------------
/*! clear the history
*/
*/
class ClearRecentFlipbookImagesCommandHandler final : public MenuItemHandler {
public:
ClearRecentFlipbookImagesCommandHandler()

View file

@ -6,6 +6,8 @@
#include "toonz/imagepainter.h"
#include "toonzqt/glwidget_for_highdpi.h"
#include <QTouchDevice>
//-----------------------------------------------------------------------------
// Forward declarations
@ -13,7 +15,8 @@ class FlipBook;
class HistogramPopup;
class QOpenGLFramebufferObject;
class LutCalibrator;
class QTouchEvent;
class QGestureEvent;
//-----------------------------------------------------------------------------
//====================
@ -50,6 +53,7 @@ class ImageViewer final : public GLWidgetForHighDpi {
QPoint m_pos;
bool m_isHistogramEnable;
HistogramPopup *m_histogramPopup;
bool m_firstImage;
bool m_isColorModel;
// when fx parameter is modified with showing the fx preview,
@ -60,6 +64,15 @@ class ImageViewer final : public GLWidgetForHighDpi {
QOpenGLFramebufferObject *m_fbo = NULL;
LutCalibrator *m_lutCalibrator = NULL;
bool m_touchActive = false;
bool m_gestureActive = false;
QTouchDevice::DeviceType m_touchDevice = QTouchDevice::TouchScreen;
bool m_zooming = false;
bool m_panning = false;
double m_scaleFactor; // used for zoom gesture
bool m_stylusUsed = false;
int getDragType(const TPoint &pos, const TRect &loadBox);
void updateLoadbox(const TPoint &curPos);
void updateCursor(const TPoint &curPos);
@ -96,6 +109,7 @@ public:
*/
void hideHistogram();
void zoomQt(bool forward, bool reset);
void resetZoom();
void setIsRemakingPreviewFx(bool on) {
m_isRemakingPreviewFx = on;
@ -127,6 +141,11 @@ protected:
void dragCompare(const QPoint &dp);
void tabletEvent(QTabletEvent *e);
void touchEvent(QTouchEvent *e, int type);
void gestureEvent(QGestureEvent *e);
bool event(QEvent *e);
public slots:
void updateImageViewer();
@ -135,6 +154,9 @@ public slots:
void showHistogram();
void swapCompared();
void onContextAboutToBeDestroyed();
private:
QPointF m_firstPanPoint;
};
#endif // IMAGEVIEWER_INCLUDE

View file

@ -190,7 +190,7 @@ public:
//
TFilePath process(ToonzScene *scene, ToonzScene *srcScene,
TFilePath srcPath) override {
TFilePath actualSrcPath = srcPath;
TFilePath actualSrcPath = srcPath;
if (srcScene) actualSrcPath = srcScene->decodeFilePath(srcPath);
if (!isImportEnabled()) {
@ -1350,7 +1350,7 @@ bool IoCmd::saveScene(const TFilePath &path, int flags) {
TApp *app = TApp::instance();
assert(!path.isEmpty());
TFilePath scenePath = path;
TFilePath scenePath = path;
if (scenePath.getType() == "") scenePath = scenePath.withType("tnz");
if (scenePath.getType() != "tnz") {
error(
@ -1376,21 +1376,45 @@ bool IoCmd::saveScene(const TFilePath &path, int flags) {
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
TXsheet *xsheet = 0;
if (saveSubxsheet) xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
// If the scene will be saved in the different folder, check out the scene
// cast.
// if the cast contains the level specified with $scenefolder alias,
// open a warning popup notifying that such level will lose link.
// in case of saving subxsheet, the current scene will not be switched to the
// saved one
// so the level paths are needed to be reverted after saving
QHash<TXshLevel *, TFilePath> orgLevelPaths;
auto revertOrgLevelPaths = [&] {
QHash<TXshLevel *, TFilePath>::const_iterator i =
orgLevelPaths.constBegin();
while (i != orgLevelPaths.constEnd()) {
if (TXshSimpleLevel *sil = i.key()->getSimpleLevel())
sil->setPath(i.value(), true);
else if (TXshPaletteLevel *pal = i.key()->getPaletteLevel())
pal->setPath(i.value());
else if (TXshSoundLevel *sol = i.key()->getSoundLevel())
sol->setPath(i.value());
++i;
}
};
if (!overwrite) {
bool ret = takeCareSceneFolderItemsOnSaveSceneAs(scene, scenePath);
if (!ret) return false;
bool ret = takeCareSceneFolderItemsOnSaveSceneAs(scene, scenePath, xsheet,
orgLevelPaths);
if (!ret) {
revertOrgLevelPaths();
return false;
}
}
TFilePath oldFullPath = scene->decodeFilePath(scene->getScenePath());
TFilePath newFullPath = scene->decodeFilePath(scenePath);
QApplication::setOverrideCursor(Qt::WaitCursor);
TXsheet *xsheet = 0;
if (saveSubxsheet) xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
if (app->getCurrentScene()->getDirtyFlag())
scene->getContentHistory(true)->modifiedNow();
@ -1414,11 +1438,6 @@ bool IoCmd::saveScene(const TFilePath &path, int flags) {
try {
scene->save(scenePath, xsheet);
TApp::instance()
->getPaletteController()
->getCurrentLevelPalette()
->notifyPaletteChanged(); // non toglieva l'asterisco alla
// paletta...forse non va qua? vinz
} catch (const TSystemException &se) {
DVGui::warning(QString::fromStdWString(se.getMessage()));
} catch (...) {
@ -1427,7 +1446,11 @@ bool IoCmd::saveScene(const TFilePath &path, int flags) {
cp->assign(&oldCP);
if (!overwrite) app->getCurrentScene()->notifyNameSceneChange();
// in case of saving subxsheet, revert the level paths after saving
revertOrgLevelPaths();
if (!overwrite && !saveSubxsheet)
app->getCurrentScene()->notifyNameSceneChange();
FileBrowser::refreshFolder(scenePath.getParentDir());
IconGenerator::instance()->invalidate(scenePath);
@ -1440,8 +1463,13 @@ bool IoCmd::saveScene(const TFilePath &path, int flags) {
app->getCurrentScene()->setDirtyFlag(false);
History::instance()->addItem(scenePath);
RecentFiles::instance()->addFilePath(toQString(scenePath),
RecentFiles::Scene);
RecentFiles::instance()->addFilePath(
toQString(scenePath), RecentFiles::Scene,
QString::fromStdString(app->getCurrentScene()
->getScene()
->getProject()
->getName()
.getName()));
QApplication::restoreOverrideCursor();
@ -1463,8 +1491,8 @@ bool IoCmd::saveScene() {
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
if (scene->isUntitled()) {
static SaveSceneAsPopup *popup = 0;
if (!popup) popup = new SaveSceneAsPopup();
int ret = popup->exec();
if (!popup) popup = new SaveSceneAsPopup();
int ret = popup->exec();
if (ret == QDialog::Accepted) {
TApp::instance()->getCurrentScene()->setDirtyFlag(false);
return true;
@ -1728,8 +1756,8 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile,
if (checkSaveOldScene)
if (!saveSceneIfNeeded(QApplication::tr("Load Scene"))) return false;
assert(!path.isEmpty());
TFilePath scenePath = path;
bool importScene = false;
TFilePath scenePath = path;
bool importScene = false;
if (scenePath.getType() == "") scenePath = scenePath.withType("tnz");
if (scenePath.getType() != "tnz") {
QString msg;
@ -1823,9 +1851,8 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile,
// import if needed
TProjectManager *pm = TProjectManager::instance();
TProjectP currentProject = pm->getCurrentProject();
if (!scene->getProject() ||
scene->getProject()->getProjectPath() !=
currentProject->getProjectPath()) {
if (!scene->getProject() || scene->getProject()->getProjectPath() !=
currentProject->getProjectPath()) {
ResourceImportDialog resourceLoader;
// resourceLoader.setImportEnabled(true);
ResourceImporter importer(scene, currentProject.getPointer(),
@ -1884,8 +1911,9 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile,
TApp::instance()->getCurrentScene()->setDirtyFlag(false);
History::instance()->addItem(scenePath);
if (updateRecentFile)
RecentFiles::instance()->addFilePath(toQString(scenePath),
RecentFiles::Scene);
RecentFiles::instance()->addFilePath(
toQString(scenePath), RecentFiles::Scene,
QString::fromStdString(scene->getProject()->getName().getName()));
QApplication::restoreOverrideCursor();
int forbiddenLevelCount = 0;
@ -2100,10 +2128,10 @@ static int loadPSDResource(IoCmd::LoadResourceArguments &args,
int &row1 = args.row1;
int &col1 = args.col1;
int count = 0;
TApp *app = TApp::instance();
ToonzScene *scene = app->getCurrentScene()->getScene();
TXsheet *xsh = scene->getXsheet();
int count = 0;
TApp *app = TApp::instance();
ToonzScene *scene = app->getCurrentScene()->getScene();
TXsheet *xsh = scene->getXsheet();
if (row0 == -1) row0 = app->getCurrentFrame()->getFrameIndex();
if (col0 == -1) col0 = app->getCurrentColumn()->getColumnIndex();
@ -2488,8 +2516,8 @@ bool IoCmd::exposeLevel(TXshSimpleLevel *sl, int row, int col,
if (!insert && !overWrite)
insertEmptyColumn = beforeCellsInsert(
xsh, row, col, fids.size(), TXshColumn::toColumnType(sl->getType()));
ExposeType type = eNone;
if (insert) type = eShiftCells;
ExposeType type = eNone;
if (insert) type = eShiftCells;
if (overWrite) type = eOverWrite;
ExposeLevelUndo *undo =
new ExposeLevelUndo(sl, row, col, frameCount, insertEmptyColumn, type);
@ -2574,36 +2602,80 @@ bool IoCmd::importLipSync(TFilePath levelPath, QList<TFrameId> frameList,
// if the cast contains the level specified with $scenefolder alias,
// open a warning popup notifying that such level will lose link.
// return false if cancelled.
bool IoCmd::takeCareSceneFolderItemsOnSaveSceneAs(ToonzScene *scene,
const TFilePath &newPath) {
TFilePath oldFullPath = scene->decodeFilePath(scene->getScenePath());
TFilePath newFullPath = scene->decodeFilePath(newPath);
bool IoCmd::takeCareSceneFolderItemsOnSaveSceneAs(
ToonzScene *scene, const TFilePath &newPath, TXsheet *subxsh,
QHash<TXshLevel *, TFilePath> &orgLevelPaths) {
auto setPathToLevel = [&](TXshLevel *level, TFilePath fp) {
// in case of saving subxsheet, the current scene will not be switched to
// the saved one
// so the level paths are needed to be reverted after saving
if (subxsh) orgLevelPaths.insert(level, level->getPath());
if (TXshSimpleLevel *sil = level->getSimpleLevel())
sil->setPath(fp, true);
else if (TXshPaletteLevel *pal = level->getPaletteLevel())
pal->setPath(fp);
else if (TXshSoundLevel *sol = level->getSoundLevel())
sol->setPath(fp);
};
TFilePath oldSceneFolder =
scene->decodeFilePath(scene->getScenePath()).getParentDir();
TFilePath newSceneFolder = scene->decodeFilePath(newPath).getParentDir();
// in case of saving in the same folder
if (oldFullPath.getParentDir() == newFullPath.getParentDir()) return true;
if (oldSceneFolder == newSceneFolder) return true;
TLevelSet *levelSet = scene->getLevelSet();
std::vector<TXshLevel *> levels;
// in case of saving subxsheet, checking only used levels.
if (subxsh) {
std::set<TXshLevel *> saveSet;
subxsh->getUsedLevels(saveSet);
levels = std::vector<TXshLevel *>(saveSet.begin(), saveSet.end());
}
// in case of saving the scene (i.e. top xsheet)
else
levelSet->listLevels(levels);
QList<TXshLevel *> sceneFolderLevels;
levelSet->listLevels(levels);
QString str;
for (int i = 0; i < levels.size(); i++) {
TXshLevel *level = levels.at(i);
int count = 0;
for (TXshLevel *level : levels) {
if (!level->getPath().isEmpty() &&
TFilePath("$scenefolder").isAncestorOf(level->getPath())) {
sceneFolderLevels.append(level);
str.append(" " + QString::fromStdWString(level->getName()) + " (" +
level->getPath().getQString() + ")\n");
TFilePath levelFullPath = scene->decodeFilePath(level->getPath());
// check if the path can be re-coded with the new scene folder path
if (newSceneFolder.isAncestorOf(levelFullPath)) {
// just replace the path without warning
TFilePath fp =
TFilePath("$scenefolder") + (levelFullPath - newSceneFolder);
setPathToLevel(level, fp);
}
// if re-coding is not possible, then it needs to ask user's preference
else {
sceneFolderLevels.append(level);
if (count < 10) {
str.append(" " + QString::fromStdWString(level->getName()) + " (" +
level->getPath().getQString() + ")\n");
}
count++;
}
}
}
// list maximum 10 levels
if (count > 10)
str.append(QObject::tr(" + %1 more level(s) \n").arg(count - 10));
// in case there is no items with $scenefolder
if (sceneFolderLevels.isEmpty()) return true;
str = QObject::tr(
"The following level(s) use path with $scenefolder alias.\n\n") +
str + QObject::tr(
"\nThey will not be opened properly when you load the "
"scene next time.\nWhat do you want to do?");
str +
QObject::tr(
"\nThey will not be opened properly when you load the "
"scene next time.\nWhat do you want to do?");
int ret = DVGui::MsgBox(
str, QObject::tr("Copy the levels to correspondent paths"),
@ -2616,7 +2688,7 @@ bool IoCmd::takeCareSceneFolderItemsOnSaveSceneAs(ToonzScene *scene,
for (int i = 0; i < sceneFolderLevels.size(); i++) {
TXshLevel *level = sceneFolderLevels.at(i);
TFilePath fp = level->getPath() - TFilePath("$scenefolder");
fp = fp.withParentDir(newFullPath.getParentDir());
fp = fp.withParentDir(newSceneFolder);
// check the level existence
if (TSystem::doesExistFileOrLevel(fp)) {
bool overwrite = (policy == YES_FOR_ALL);
@ -2663,15 +2735,7 @@ bool IoCmd::takeCareSceneFolderItemsOnSaveSceneAs(ToonzScene *scene,
// decode and code again
TFilePath fp =
scene->codeFilePath(scene->decodeFilePath(level->getPath()));
TXshSimpleLevel *sil = level->getSimpleLevel();
TXshPaletteLevel *pal = level->getPaletteLevel();
TXshSoundLevel *sol = level->getSoundLevel();
if (sil)
sil->setPath(fp);
else if (pal)
pal->setPath(fp);
else if (sol)
sol->setPath(fp);
setPathToLevel(level, fp);
}
Preferences::instance()->setPathAliasPriority(oldPriority);
}

View file

@ -31,6 +31,7 @@ class TXshSoundLevel;
class ToonzScene;
class TCamera;
class TPropertyGroup;
class TXsheet;
namespace DVGui {
class ProgressDialog;
@ -221,9 +222,8 @@ int loadResources(
//! access and finalization.
//!< Loads a group of resources by path.
//! \return The actually loaded levels count.
int xFrom = -1,
int xTo = -1, std::wstring levelName = L"", int step = -1, int inc = -1,
int frameCount = -1, bool doesFileActuallyExist = true,
int xFrom = -1, int xTo = -1, std::wstring levelName = L"", int step = -1,
int inc = -1, int frameCount = -1, bool doesFileActuallyExist = true,
CacheTlvBehavior cachingBehavior = ON_DEMAND);
int loadResourceFolders(
@ -231,7 +231,7 @@ int loadResourceFolders(
LoadResourceArguments::ScopedBlock *sb =
0 //!< Load block. May be nonzero in order to extend block data
//! access and finalization.
); //!< Loads the specified folders in current xsheet.
); //!< Loads the specified folders in current xsheet.
//! \return The actually loaded levels count.
bool exposeLevel(TXshSimpleLevel *sl, int row, int col, bool insert = false,
bool overWrite = false);
@ -256,8 +256,9 @@ bool importLipSync(TFilePath levelPath, QList<TFrameId> frameList,
// cast.
// if the cast contains the level specified with $scenefolder alias,
// open a warning popup notifying that such level will lose link.
bool takeCareSceneFolderItemsOnSaveSceneAs(ToonzScene *scene,
const TFilePath &newPath);
bool takeCareSceneFolderItemsOnSaveSceneAs(
ToonzScene *scene, const TFilePath &newPath, TXsheet *subxsh,
QHash<TXshLevel *, TFilePath> &orgLevelPaths);
} // namespace IoCmd

View file

@ -32,6 +32,7 @@
#include "toonz/tscenehandle.h"
#include "toonz/toonzscene.h"
#include "toonz/txshleveltypes.h"
#include "toonz/tproject.h"
// TnzBase includes
#include "tenv.h"
@ -484,14 +485,19 @@ void MainWindow::changeWindowTitle() {
ToonzScene *scene = app->getCurrentScene()->getScene();
if (!scene) return;
QString name = QString::fromStdWString(scene->getSceneName());
TProject *project = scene->getProject();
QString projectName = QString::fromStdString(project->getName().getName());
QString sceneName = QString::fromStdWString(scene->getSceneName());
if (sceneName.isEmpty()) sceneName = tr("Untitled");
if (app->getCurrentScene()->getDirtyFlag()) sceneName += QString("*");
/*--- レイアウトファイル名を頭に表示させる ---*/
if (!m_layoutName.isEmpty()) name.prepend(m_layoutName + " : ");
if (!m_layoutName.isEmpty()) sceneName.prepend(m_layoutName + " : ");
if (name.isEmpty()) name = tr("Untitled");
name += " : " + QString::fromStdString(TEnv::getApplicationFullName());
QString name = sceneName + " [" + projectName + "] : " +
QString::fromStdString(TEnv::getApplicationFullName());
setWindowTitle(name);
}
@ -521,7 +527,7 @@ Room *MainWindow::getRoom(int index) const {
//-----------------------------------------------------------------------------
/*! Roomを名前から探す
*/
*/
Room *MainWindow::getRoomByName(QString &roomName) {
for (int i = 0; i < getRoomCount(); i++) {
Room *room = dynamic_cast<Room *>(m_stackedWidget->widget(i));
@ -1148,7 +1154,7 @@ void MainWindow::onMenuCheckboxChanged() {
#endif
else if (cm->getAction(MI_RasterizePli) == action) {
if (!QGLPixelBuffer::hasOpenGLPbuffers()) isChecked = 0;
RasterizePliToggleAction = isChecked;
RasterizePliToggleAction = isChecked;
} else if (cm->getAction(MI_SafeArea) == action)
SafeAreaToggleAction = isChecked;
else if (cm->getAction(MI_ViewColorcard) == action)
@ -1428,6 +1434,13 @@ QAction *MainWindow::createViewerAction(const char *id, const QString &name,
//-----------------------------------------------------------------------------
QAction *MainWindow::createVisualizationButtonAction(const char *id,
const QString &name) {
return createAction(id, name, "", VisualizationButtonCommandType);
}
//-----------------------------------------------------------------------------
QAction *MainWindow::createMiscAction(const char *id, const QString &name,
const char *defaultShortcut) {
QAction *action = new DVAction(name, this);
@ -2094,8 +2107,11 @@ void MainWindow::defineActions() {
createViewerAction(V_ZoomIn, tr("Zoom In"), "+");
createViewerAction(V_ZoomOut, tr("Zoom Out"), "-");
createViewerAction(V_ZoomReset, tr("Reset View"), "Alt+0");
createViewerAction(V_ViewReset, tr("Reset View"), "Alt+0");
createViewerAction(V_ZoomFit, tr("Fit to Window"), "Alt+9");
createViewerAction(V_ZoomReset, tr("Reset Zoom"), "");
createViewerAction(V_RotateReset, tr("Reset Rotation"), "");
createViewerAction(V_PositionReset, tr("Reset Position"), "");
createViewerAction(V_ActualPixelSize, tr("Actual Pixel Size"), "N");
createViewerAction(V_FlipX, tr("Flip Viewer Horizontally"), "");
createViewerAction(V_FlipY, tr("Flip Viewer Vertically"), "");
@ -2105,6 +2121,21 @@ void MainWindow::defineActions() {
tr("Full Screen Mode"),
tr("Exit Full Screen Mode"));
// Following actions are for adding "Visualization" menu items to the command
// bar. They are separated from the original actions in order to avoid
// assigning shortcut keys. They must be triggered only from pressing buttons
// in the command bar. Assinging shortcut keys and registering as MenuItem
// will break a logic of ShortcutZoomer. So here we register separate items
// and bypass the command.
createVisualizationButtonAction(VB_ViewReset, tr("Reset View"));
createVisualizationButtonAction(VB_ZoomFit, tr("Fit to Window"));
createVisualizationButtonAction(VB_ZoomReset, tr("Reset Zoom"));
createVisualizationButtonAction(VB_RotateReset, tr("Reset Rotation"));
createVisualizationButtonAction(VB_PositionReset, tr("Reset Position"));
createVisualizationButtonAction(VB_ActualPixelSize, tr("Actual Pixel Size"));
createVisualizationButtonAction(VB_FlipX, tr("Flip Viewer Horizontally"));
createVisualizationButtonAction(VB_FlipY, tr("Flip Viewer Vertically"));
QAction *refreshAct =
createMiscAction(MI_RefreshTree, tr("Refresh Folder Tree"), "");
refreshAct->setIconText(tr("Refresh"));
@ -2152,6 +2183,10 @@ void MainWindow::defineActions() {
createToolOptionsAction("A_ToolOption_JoinVectors", tr("Join Vectors"), "");
createToolOptionsAction("A_ToolOption_ShowOnlyActiveSkeleton",
tr("Show Only Active Skeleton"), "");
createToolOptionsAction("A_ToolOption_RasterEraser",
tr("Brush Tool - Eraser (Raster option)"), "");
createToolOptionsAction("A_ToolOption_LockAlpha",
tr("Brush Tool - Lock Alpha"), "");
// Option Menu
createToolOptionsAction("A_ToolOption_BrushPreset", tr("Brush Preset"), "");
@ -2313,7 +2348,8 @@ void MainWindow::onQuit() { close(); }
// RecentFiles
//=============================================================================
RecentFiles::RecentFiles() : m_recentScenes(), m_recentLevels() {}
RecentFiles::RecentFiles()
: m_recentScenes(), m_recentSceneProjects(), m_recentLevels() {}
//-----------------------------------------------------------------------------
@ -2328,17 +2364,25 @@ RecentFiles::~RecentFiles() {}
//-----------------------------------------------------------------------------
void RecentFiles::addFilePath(QString path, FileType fileType) {
void RecentFiles::addFilePath(QString path, FileType fileType,
QString projectName) {
QList<QString> files =
(fileType == Scene) ? m_recentScenes : (fileType == Level)
? m_recentLevels
: m_recentFlipbookImages;
(fileType == Scene)
? m_recentScenes
: (fileType == Level) ? m_recentLevels : m_recentFlipbookImages;
int i;
for (i = 0; i < files.size(); i++)
if (files.at(i) == path) files.removeAt(i);
if (files.at(i) == path) {
files.removeAt(i);
if (fileType == Scene) m_recentSceneProjects.removeAt(i);
}
files.insert(0, path);
if (fileType == Scene) m_recentSceneProjects.insert(0, projectName);
int maxSize = 10;
if (files.size() > maxSize) files.removeAt(maxSize);
if (files.size() > maxSize) {
files.removeAt(maxSize);
if (fileType == Scene) m_recentSceneProjects.removeAt(maxSize);
}
if (fileType == Scene)
m_recentScenes = files;
@ -2354,9 +2398,10 @@ void RecentFiles::addFilePath(QString path, FileType fileType) {
//-----------------------------------------------------------------------------
void RecentFiles::moveFilePath(int fromIndex, int toIndex, FileType fileType) {
if (fileType == Scene)
if (fileType == Scene) {
m_recentScenes.move(fromIndex, toIndex);
else if (fileType == Level)
m_recentSceneProjects.move(fromIndex, toIndex);
} else if (fileType == Level)
m_recentLevels.move(fromIndex, toIndex);
else
m_recentFlipbookImages.move(fromIndex, toIndex);
@ -2366,9 +2411,10 @@ void RecentFiles::moveFilePath(int fromIndex, int toIndex, FileType fileType) {
//-----------------------------------------------------------------------------
void RecentFiles::removeFilePath(int index, FileType fileType) {
if (fileType == Scene)
if (fileType == Scene) {
m_recentScenes.removeAt(index);
else if (fileType == Level)
m_recentSceneProjects.removeAt(index);
} else if (fileType == Level)
m_recentLevels.removeAt(index);
saveRecentFiles();
}
@ -2384,10 +2430,26 @@ QString RecentFiles::getFilePath(int index, FileType fileType) const {
//-----------------------------------------------------------------------------
QString RecentFiles::getFileProject(int index) const {
if (index >= m_recentScenes.size() || index >= m_recentSceneProjects.size())
return "-";
return m_recentSceneProjects[index];
}
QString RecentFiles::getFileProject(QString fileName) const {
for (int index = 0; index < m_recentScenes.size(); index++)
if (m_recentScenes[index] == fileName) return m_recentSceneProjects[index];
return "-";
}
//-----------------------------------------------------------------------------
void RecentFiles::clearRecentFilesList(FileType fileType) {
if (fileType == Scene)
if (fileType == Scene) {
m_recentScenes.clear();
else if (fileType == Level)
m_recentSceneProjects.clear();
} else if (fileType == Level)
m_recentLevels.clear();
else
m_recentFlipbookImages.clear();
@ -2411,6 +2473,22 @@ void RecentFiles::loadRecentFiles() {
QString scene = settings.value(QString("Scenes")).toString();
if (!scene.isEmpty()) m_recentScenes.append(scene);
}
// Load scene's projects info. This is for display purposes only. For
// backwards compatibility it is stored and maintained separately.
QList<QVariant> sceneProjects =
settings.value(QString("SceneProjects")).toList();
if (!sceneProjects.isEmpty()) {
for (i = 0; i < sceneProjects.size(); i++)
m_recentSceneProjects.append(sceneProjects.at(i).toString());
} else {
QString sceneProject = settings.value(QString("SceneProjects")).toString();
if (!sceneProject.isEmpty()) m_recentSceneProjects.append(sceneProject);
}
// Should be 1-to-1. If we're short, append projects list with "-".
while (m_recentSceneProjects.size() < m_recentScenes.size())
m_recentSceneProjects.append("-");
QList<QVariant> levels = settings.value(QString("Levels")).toList();
if (!levels.isEmpty()) {
for (i = 0; i < levels.size(); i++) {
@ -2448,6 +2526,7 @@ void RecentFiles::saveRecentFiles() {
TFilePath fp = ToonzFolder::getMyModuleDir() + TFilePath("RecentFiles.ini");
QSettings settings(toQString(fp), QSettings::IniFormat);
settings.setValue(QString("Scenes"), QVariant(m_recentScenes));
settings.setValue(QString("SceneProjects"), QVariant(m_recentSceneProjects));
settings.setValue(QString("Levels"), QVariant(m_recentLevels));
settings.setValue(QString("FlipbookImages"),
QVariant(m_recentFlipbookImages));
@ -2457,9 +2536,9 @@ void RecentFiles::saveRecentFiles() {
QList<QString> RecentFiles::getFilesNameList(FileType fileType) {
QList<QString> files =
(fileType == Scene) ? m_recentScenes : (fileType == Level)
? m_recentLevels
: m_recentFlipbookImages;
(fileType == Scene)
? m_recentScenes
: (fileType == Level) ? m_recentLevels : m_recentFlipbookImages;
QList<QString> names;
int i;
for (i = 0; i < files.size(); i++) {
@ -2486,9 +2565,9 @@ void RecentFiles::refreshRecentFilesMenu(FileType fileType) {
menu->setEnabled(false);
else {
CommandId clearActionId =
(fileType == Scene) ? MI_ClearRecentScene : (fileType == Level)
? MI_ClearRecentLevel
: MI_ClearRecentImage;
(fileType == Scene)
? MI_ClearRecentScene
: (fileType == Level) ? MI_ClearRecentLevel : MI_ClearRecentImage;
menu->setActions(names);
menu->addSeparator();
QAction *clearAction = CommandManager::instance()->getAction(clearActionId);

View file

@ -175,6 +175,9 @@ private:
const QString &defaultShortcut);
QAction *createViewerAction(const char *id, const QString &name,
const QString &defaultShortcut);
// For command bar, no shortcut keys
QAction *createVisualizationButtonAction(const char *id, const QString &name);
QAction *createMiscAction(const char *id, const QString &name,
const char *defaultShortcut);
QAction *createToolOptionsAction(const char *id, const QString &name,
@ -208,6 +211,7 @@ signals:
class RecentFiles {
friend class StartupPopup;
QList<QString> m_recentScenes;
QList<QString> m_recentSceneProjects;
QList<QString> m_recentLevels;
QList<QString> m_recentFlipbookImages;
@ -219,10 +223,12 @@ public:
static RecentFiles *instance();
~RecentFiles();
void addFilePath(QString path, FileType fileType);
void addFilePath(QString path, FileType fileType, QString projectName = 0);
void moveFilePath(int fromIndex, int toIndex, FileType fileType);
void removeFilePath(int fromIndex, FileType fileType);
QString getFilePath(int index, FileType fileType) const;
QString getFileProject(QString fileName) const;
QString getFileProject(int index) const;
void clearRecentFilesList(FileType fileType);
void loadRecentFiles();
void saveRecentFiles();

View file

@ -6,6 +6,7 @@
#include "tapp.h"
#include "mainwindow.h"
#include "tenv.h"
#include "saveloadqsettings.h"
#include "toonzqt/gutil.h"
@ -29,6 +30,7 @@
#include <QFile>
#include <qdrawutil.h>
#include <assert.h>
#include <QDesktopWidget>
extern TEnv::StringVar EnvSafeAreaName;
@ -60,7 +62,22 @@ TPanel::TPanel(QWidget *parent, Qt::WindowFlags flags,
//-----------------------------------------------------------------------------
TPanel::~TPanel() {}
TPanel::~TPanel() {
// On quitting, save the floating panel's geomtry and state in order to
// restore them when opening the floating panel next time
if (isFloating()) {
TFilePath savePath =
ToonzFolder::getMyModuleDir() + TFilePath("popups.ini");
QSettings settings(QString::fromStdWString(savePath.getWideString()),
QSettings::IniFormat);
settings.beginGroup("Panels");
settings.beginGroup(QString::fromStdString(m_panelType));
settings.setValue("geometry", geometry());
if (SaveLoadQSettings *persistent =
dynamic_cast<SaveLoadQSettings *>(widget()))
persistent->save(settings);
}
}
//-----------------------------------------------------------------------------
@ -104,7 +121,7 @@ void TPanel::onCloseButtonPressed() {
//-----------------------------------------------------------------------------
/*! activate the panel and set focus specified widget when mouse enters
*/
*/
void TPanel::enterEvent(QEvent *event) {
// Only when Toonz application is active
if (qApp->activeWindow()) {
@ -120,9 +137,35 @@ void TPanel::enterEvent(QEvent *event) {
//-----------------------------------------------------------------------------
/*! clear focus when mouse leaves
*/
*/
void TPanel::leaveEvent(QEvent *event) { widgetClearFocusOnLeave(); }
//-----------------------------------------------------------------------------
/*! load and restore previous geometry and state of the floating panel.
called from the function OpenFloatingPanel::getOrOpenFloatingPanel()
in floatingpanelcommand.cpp
*/
void TPanel::restoreFloatingPanelState() {
TFilePath savePath = ToonzFolder::getMyModuleDir() + TFilePath("popups.ini");
QSettings settings(QString::fromStdWString(savePath.getWideString()),
QSettings::IniFormat);
settings.beginGroup("Panels");
if (!settings.childGroups().contains(QString::fromStdString(m_panelType)))
return;
settings.beginGroup(QString::fromStdString(m_panelType));
QRect geom = settings.value("geometry", saveGeometry()).toRect();
// check if it can be visible in the current screen
if (!(geom & QApplication::desktop()->availableGeometry(this)).isEmpty())
setGeometry(geom);
// load optional settings
if (SaveLoadQSettings *persistent =
dynamic_cast<SaveLoadQSettings *>(widget()))
persistent->load(settings);
}
//=============================================================================
// TPanelTitleBarButton
//-----------------------------------------------------------------------------
@ -181,9 +224,10 @@ void TPanelTitleBarButton::setPressed(bool pressed) {
void TPanelTitleBarButton::paintEvent(QPaintEvent *event) {
QPainter painter(this);
painter.drawPixmap(
0, 0, m_pressed ? m_pressedPixmap : m_rollover ? m_rolloverPixmap
: m_standardPixmap);
painter.drawPixmap(0, 0,
m_pressed
? m_pressedPixmap
: m_rollover ? m_rolloverPixmap : m_standardPixmap);
painter.end();
}

View file

@ -55,7 +55,7 @@ signals:
//-----------------------------------------------------------------------------
/*! specialized button for sage area which enables to choose safe area size by
* context menu
*/
*/
class TPanelTitleBarButtonForSafeArea final : public TPanelTitleBarButton {
Q_OBJECT
@ -232,6 +232,8 @@ public:
return false;
};
void restoreFloatingPanelState();
protected:
void paintEvent(QPaintEvent *) override;
void enterEvent(QEvent *) override;

View file

@ -177,7 +177,7 @@ inline void doPixBinary(QRgb* pix, int threshold) {
gray = 255;
else
gray = 0;
*pix = qRgb(gray, gray, gray);
*pix = qRgb(gray, gray, gray);
}
//-----------------------------------------------------------------------------
@ -220,7 +220,7 @@ void onChange(QImage& img, int black, int white, float gamma, bool doGray) {
void onChangeBW(QImage& img, int threshold) {
int lx = img.width(), y, ly = img.height();
for (y = 0; y < ly; ++y) {
QRgb *pix = (QRgb *)img.scanLine(y), *endPix = (QRgb *)(pix + lx);
QRgb *pix = (QRgb*)img.scanLine(y), *endPix = (QRgb*)(pix + lx);
while (pix < endPix) {
doPixBinary(pix, threshold);
++pix;
@ -476,7 +476,7 @@ bool getRasterLevelSize(TXshLevel* level, TDimension& dim) {
void ApplyLutTask::run() {
int lx = m_img.width();
for (int y = m_fromY; y < m_toY; ++y) {
QRgb *pix = (QRgb *)m_img.scanLine(y), *endPix = (QRgb *)(pix + lx);
QRgb *pix = (QRgb*)m_img.scanLine(y), *endPix = (QRgb*)(pix + lx);
while (pix < endPix) {
doPix(pix, m_lut);
++pix;
@ -487,7 +487,7 @@ void ApplyLutTask::run() {
void ApplyGrayLutTask::run() {
int lx = m_img.width();
for (int y = m_fromY; y < m_toY; ++y) {
QRgb *pix = (QRgb *)m_img.scanLine(y), *endPix = (QRgb *)(pix + lx);
QRgb *pix = (QRgb*)m_img.scanLine(y), *endPix = (QRgb*)(pix + lx);
while (pix < endPix) {
doPixGray(pix, m_lut);
++pix;
@ -950,7 +950,14 @@ int FrameNumberLineEdit::getValue() {
//-----------------------------------------------------------------------------
void FrameNumberLineEdit::focusInEvent(QFocusEvent* e) {
m_textOnFocusIn = text();
}
void FrameNumberLineEdit::focusOutEvent(QFocusEvent* e) {
// if the field is empty, then revert the last input
if (text().isEmpty()) setText(m_textOnFocusIn);
LineEdit::focusOutEvent(e);
}
@ -1249,7 +1256,7 @@ QString formatString(QString inStr, int charNum) {
}
return numStr.rightJustified(charNum, '0') + postStr;
}
};
}; // namespace
void PencilTestSaveInFolderPopup::updateSubFolderName() {
if (!m_autoSubNameCB->isChecked()) return;
@ -1419,10 +1426,10 @@ void PencilTestSaveInFolderPopup::updateParentFolder() {
PencilTestPopup::PencilTestPopup()
// set the parent 0 in order to enable the popup behind the main window
: Dialog(0, false, false, "PencilTest"),
m_currentCamera(NULL),
m_captureWhiteBGCue(false),
m_captureCue(false) {
: Dialog(0, false, false, "PencilTest")
, m_currentCamera(NULL)
, m_captureWhiteBGCue(false)
, m_captureCue(false) {
setWindowTitle(tr("Camera Capture"));
// add maximize button to the dialog
@ -1749,7 +1756,7 @@ PencilTestPopup::PencilTestPopup()
bool ret = true;
ret = ret && connect(refreshCamListButton, SIGNAL(pressed()), this,
SLOT(refreshCameraList()));
ret = ret && connect(m_cameraListCombo, SIGNAL(activated(int)), this,
ret = ret && connect(m_cameraListCombo, SIGNAL(activated(int)), this,
SLOT(onCameraListComboActivated(int)));
ret = ret && connect(m_resolutionCombo, SIGNAL(activated(const QString&)),
this, SLOT(onResolutionComboActivated(const QString&)));
@ -2256,7 +2263,8 @@ void PencilTestPopup::hideEvent(QHideEvent* event) {
void PencilTestPopup::keyPressEvent(QKeyEvent* event) {
// override return (or enter) key as shortcut key for capturing
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
int key = event->key();
if (key == Qt::Key_Return || key == Qt::Key_Enter) {
// show button-clicking animation followed by calling
// onCaptureButtonClicked()
m_captureButton->animateClick();
@ -2267,6 +2275,23 @@ void PencilTestPopup::keyPressEvent(QKeyEvent* event) {
//-----------------------------------------------------------------------------
bool PencilTestPopup::event(QEvent* event) {
if (event->type() == QEvent::ShortcutOverride) {
QKeyEvent* ke = static_cast<QKeyEvent*>(event);
int key = ke->key();
if (key >= Qt::Key_0 && key <= Qt::Key_9) {
if (!m_frameNumberEdit->hasFocus()) {
m_frameNumberEdit->setFocus();
m_frameNumberEdit->clear();
}
event->accept();
return true;
}
}
return DVGui::Dialog::event(event);
}
//-----------------------------------------------------------------------------
void PencilTestPopup::processImage(QImage& image) {
/* "upside down" is not executed here. It will be done when capturing the
* image */
@ -2425,7 +2450,7 @@ void PencilTestPopup::onCountDown() {
//-----------------------------------------------------------------------------
/*! referenced from LevelCreatePopup::apply()
*/
*/
bool PencilTestPopup::importImage(QImage image) {
TApp* app = TApp::instance();
ToonzScene* scene = app->getCurrentScene()->getScene();
@ -2520,9 +2545,8 @@ bool PencilTestPopup::importImage(QImage image) {
/* if the loaded level does not match in pixel size, then return */
sl = level->getSimpleLevel();
if (!sl ||
sl->getProperties()->getImageRes() !=
TDimension(image.width(), image.height())) {
if (!sl || sl->getProperties()->getImageRes() !=
TDimension(image.width(), image.height())) {
error(tr(
"The captured image size does not match with the existing level."));
return false;
@ -2543,7 +2567,7 @@ bool PencilTestPopup::importImage(QImage image) {
else {
TXshLevel* level = scene->createNewLevel(OVL_XSHLEVEL, levelName,
TDimension(), 0, levelFp);
sl = level->getSimpleLevel();
sl = level->getSimpleLevel();
sl->setPath(levelFp, true);
sl->getProperties()->setDpiPolicy(LevelProperties::DP_CustomDpi);
TPointD dpi;
@ -2732,7 +2756,7 @@ void PencilTestPopup::refreshFrameInfo() {
// frame existence
TFilePath frameFp(actualLevelFp.withFrame(frameNumber));
bool frameExist = false;
bool frameExist = false;
if (levelExist) frameExist = TFileStatus(frameFp).doesExist();
// reset acceptable camera size

View file

@ -32,7 +32,7 @@ namespace DVGui {
class FileField;
class IntField;
class IntLineEdit;
}
} // namespace DVGui
class CameraCaptureLevelControl;
@ -190,6 +190,7 @@ class FrameNumberLineEdit : public DVGui::LineEdit {
QRegExpValidator* m_regexpValidator;
void updateValidator();
QString m_textOnFocusIn;
public:
FrameNumberLineEdit(QWidget* parent = 0, int value = 1);
@ -203,6 +204,7 @@ public:
protected:
/*! If focus is lost and current text value is out of range emit signal
\b editingFinished.*/
void focusInEvent(QFocusEvent*) override;
void focusOutEvent(QFocusEvent*) override;
void showEvent(QShowEvent* event) override { updateValidator(); }
};
@ -332,9 +334,10 @@ public:
protected:
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
void keyPressEvent(QKeyEvent* event);
bool event(QEvent* e) override;
protected slots:
void refreshCameraList();
void onCameraListComboActivated(int index);

View file

@ -260,10 +260,10 @@ void PreferencesPopup::onPixelsOnlyChanged(int index) {
QString tempUnit;
int unitIndex;
tempUnit = m_pref->getOldUnits();
unitIndex = m_unitOm->findText(tempUnit);
unitIndex = std::find(::units, ::units + ::unitsCount, tempUnit) - ::units;
m_unitOm->setCurrentIndex(unitIndex);
tempUnit = m_pref->getOldCameraUnits();
unitIndex = m_cameraUnitOm->findText(tempUnit);
unitIndex = std::find(::units, ::units + ::unitsCount, tempUnit) - ::units;
m_cameraUnitOm->setCurrentIndex(unitIndex);
m_unitOm->setDisabled(false);
m_cameraUnitOm->setDisabled(false);
@ -381,7 +381,7 @@ void PreferencesPopup::onInterfaceFontChanged(int index) {
QString oldTypeface = m_interfaceFontStyle->currentText();
rebuilldFontStyleList();
if (!oldTypeface.isEmpty()) {
int newIndex = m_interfaceFontStyle->findText(oldTypeface);
int newIndex = m_interfaceFontStyle->findText(oldTypeface);
if (newIndex < 0) newIndex = 0;
m_interfaceFontStyle->setCurrentIndex(newIndex);
}
@ -504,7 +504,7 @@ void PreferencesPopup::onTranspCheckDataChanged(const TPixel32 &,
void PreferencesPopup::onOnionDataChanged(const TPixel32 &, bool isDragging) {
if (isDragging) return;
bool inksOnly = false;
bool inksOnly = false;
if (m_inksOnly) inksOnly = m_inksOnly->isChecked();
m_pref->setOnionData(m_frontOnionColor->getColor(),
m_backOnionColor->getColor(), inksOnly);
@ -517,7 +517,7 @@ void PreferencesPopup::onOnionDataChanged(const TPixel32 &, bool isDragging) {
//-----------------------------------------------------------------------------
void PreferencesPopup::onOnionDataChanged(int) {
bool inksOnly = false;
bool inksOnly = false;
if (m_inksOnly) inksOnly = m_inksOnly->isChecked();
m_pref->setOnionData(m_frontOnionColor->getColor(),
m_backOnionColor->getColor(), inksOnly);

View file

@ -145,7 +145,7 @@ DvDirModelNode *ProjectDirModel::getNode(const QModelIndex &index) const {
QModelIndex ProjectDirModel::index(int row, int column,
const QModelIndex &parent) const {
if (column != 0) return QModelIndex();
DvDirModelNode *parentNode = m_root;
DvDirModelNode *parentNode = m_root;
if (parent.isValid()) parentNode = getNode(parent);
if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex();
DvDirModelNode *node = parentNode->getChild(row);
@ -321,19 +321,20 @@ ProjectPopup::ProjectPopup(bool isModal)
Qt::AlignRight | Qt::AlignVCenter);
upperLayout->addWidget(ff, i + 2, 1);
}
struct {
QString name;
std::string folderName;
} cbs[] = {{tr("Append $scenepath to +drawings"), TProject::Drawings},
{tr("Append $scenepath to +inputs"), TProject::Inputs},
{tr("Append $scenepath to +extras"), TProject::Extras}};
std::vector<std::tuple<QString, std::string>> cbs = {
std::make_tuple(tr("Append $scenepath to +drawings"),
TProject::Drawings),
std::make_tuple(tr("Append $scenepath to +inputs"), TProject::Inputs),
std::make_tuple(tr("Append $scenepath to +extras"), TProject::Extras)};
int currentRow = upperLayout->rowCount();
for (i = 0; i < tArrayCount(cbs); i++) {
CheckBox *cb = new CheckBox(cbs[i].name);
for (int i = 0; i < cbs.size(); ++i) {
auto const &name = std::get<0>(cbs[i]);
auto const &folderName = std::get<1>(cbs[i]);
CheckBox *cb = new CheckBox(name);
cb->setMaximumHeight(WidgetHeight);
upperLayout->addWidget(cb, currentRow + i, 1);
m_useScenePathCbs.append(qMakePair(cbs[i].folderName, cb));
m_useScenePathCbs.append(qMakePair(folderName, cb));
}
m_topLayout->addLayout(upperLayout);
}

View file

@ -61,10 +61,10 @@ ReframePopup::ReframePopup()
bool ret = true;
ret = ret && connect(m_step, SIGNAL(editingFinished()), this,
SLOT(updateBlankCellCount()));
ret = ret && connect(m_blank, SIGNAL(editingFinished()), this,
ret = ret && connect(m_blank, SIGNAL(editingFinished()), this,
SLOT(updateBlankCellCount()));
ret = ret && connect(okBtn, SIGNAL(clicked()), this, SLOT(accept()));
ret = ret && connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject()));
ret = ret && connect(okBtn, SIGNAL(clicked()), this, SLOT(accept()));
ret = ret && connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject()));
assert(ret);
}
@ -81,3 +81,7 @@ void ReframePopup::getValues(int& step, int& blank) {
step = m_step->getValue();
blank = m_blank->getValue();
}
//-----------------------------------------------------------------------------
void ReframePopup::showEvent(QShowEvent* event) { m_step->selectAll(); }

View file

@ -32,6 +32,9 @@ public:
ReframePopup();
void getValues(int& step, int& blank);
protected:
void showEvent(QShowEvent* event) override;
public slots:
void updateBlankCellCount();
};

View file

@ -24,6 +24,7 @@
#include "toonzqt/gutil.h"
#include "toonzqt/imageutils.h"
#include "toonzqt/lutcalibrator.h"
#include "toonzqt/viewcommandids.h"
// TnzLib includes
#include "toonz/tscenehandle.h"
@ -451,6 +452,83 @@ public:
}
} resetShiftTraceCommand;
//-----------------------------------------------------------------------------
// Following commands (VB_***) are registered for command bar buttons.
// They are separatd from the original visalization commands
// so that they will not break a logic of ShortcutZoomer.
class TViewResetCommand final : public MenuItemHandler {
public:
TViewResetCommand() : MenuItemHandler(VB_ViewReset) {}
void execute() override {
if (TApp::instance()->getActiveViewer())
TApp::instance()->getActiveViewer()->resetSceneViewer();
}
} viewResetCommand;
class TZoomResetCommand final : public MenuItemHandler {
public:
TZoomResetCommand() : MenuItemHandler(VB_ZoomReset) {}
void execute() override {
if (TApp::instance()->getActiveViewer())
TApp::instance()->getActiveViewer()->resetZoom();
}
} zoomResetCommand;
class TZoomFitCommand final : public MenuItemHandler {
public:
TZoomFitCommand() : MenuItemHandler(VB_ZoomFit) {}
void execute() override {
if (TApp::instance()->getActiveViewer())
TApp::instance()->getActiveViewer()->fitToCamera();
}
} zoomFitCommand;
class TActualPixelSizeCommand final : public MenuItemHandler {
public:
TActualPixelSizeCommand() : MenuItemHandler(VB_ActualPixelSize) {}
void execute() override {
if (TApp::instance()->getActiveViewer())
TApp::instance()->getActiveViewer()->setActualPixelSize();
}
} actualPixelSizeCommand;
class TFlipViewerXCommand final : public MenuItemHandler {
public:
TFlipViewerXCommand() : MenuItemHandler(VB_FlipX) {}
void execute() override {
if (TApp::instance()->getActiveViewer())
TApp::instance()->getActiveViewer()->flipX();
}
} flipViewerXCommand;
class TFlipViewerYCommand final : public MenuItemHandler {
public:
TFlipViewerYCommand() : MenuItemHandler(VB_FlipY) {}
void execute() override {
if (TApp::instance()->getActiveViewer())
TApp::instance()->getActiveViewer()->flipY();
}
} flipViewerYCommand;
class TRotateResetCommand final : public MenuItemHandler {
public:
TRotateResetCommand() : MenuItemHandler(VB_RotateReset) {}
void execute() override {
if (TApp::instance()->getActiveViewer())
TApp::instance()->getActiveViewer()->resetRotation();
}
} rotateResetCommand;
class TPositionResetCommand final : public MenuItemHandler {
public:
TPositionResetCommand() : MenuItemHandler(VB_PositionReset) {}
void execute() override {
if (TApp::instance()->getActiveViewer())
TApp::instance()->getActiveViewer()->resetPosition();
}
} positionResetCommand;
//=============================================================================
// SceneViewer
//-----------------------------------------------------------------------------
@ -511,8 +589,10 @@ SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent)
this->setTabletTracking(true);
#endif
for (int i = 0; i < tArrayCount(m_viewAff); i++)
for (int i = 0; i < m_viewAff.size(); ++i) {
setViewMatrix(getNormalZoomScale(), i);
m_rotationAngle[i] = 0.0;
}
m_3DSideR = rasterFromQPixmap(svgToPixmap(":Resources/3Dside_r.svg"));
m_3DSideL = rasterFromQPixmap(svgToPixmap(":Resources/3Dside_l.svg"));
@ -1635,7 +1715,7 @@ double SceneViewer::projectToZ(const TPointD &delta) {
GLint viewport[4];
double modelview[16], projection[16];
glGetIntegerv(GL_VIEWPORT, viewport);
for (int i = 0; i < 16; i++)
for (int i = 0; i < 16; i++)
projection[i] = (double)m_projectionMatrix.constData()[i];
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
@ -1797,8 +1877,9 @@ void SceneViewer::zoomQt(bool forward, bool reset) {
if (reset || ((m_zoomScale3D < 500 || !forward) &&
(m_zoomScale3D > 0.01 || forward))) {
double oldZoomScale = m_zoomScale3D;
m_zoomScale3D = reset ? 1 : ImageUtils::getQuantizedZoomFactor(
m_zoomScale3D, forward);
m_zoomScale3D =
reset ? 1
: ImageUtils::getQuantizedZoomFactor(m_zoomScale3D, forward);
m_pan3D = -(m_zoomScale3D / oldZoomScale) * -m_pan3D;
}
@ -1819,17 +1900,18 @@ void SceneViewer::zoomQt(bool forward, bool reset) {
int i;
for (i = 0; i < 2; i++) {
TAffine &viewAff = m_viewAff[i];
TAffine &viewAff = m_viewAff[i];
if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1);
if (m_isFlippedX) viewAff = viewAff * TScale(1, -1);
double scale2 = std::abs(viewAff.det());
double scale2 = std::abs(viewAff.det());
if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1);
if (m_isFlippedX) viewAff = viewAff * TScale(1, -1);
if (reset || ((scale2 < 100000 || !forward) &&
(scale2 > 0.001 * 0.05 || forward))) {
double oldZoomScale = sqrt(scale2) * dpiFactor;
double zoomScale = reset ? 1 : ImageUtils::getQuantizedZoomFactor(
oldZoomScale, forward);
double zoomScale =
reset ? 1
: ImageUtils::getQuantizedZoomFactor(oldZoomScale, forward);
// threshold value -0.001 is intended to absorb the error of calculation
if ((oldZoomScale - zoomScaleFittingWithScreen) *
@ -1995,8 +2077,18 @@ void SceneViewer::zoom(const TPointD &center, double factor) {
//-----------------------------------------------------------------------------
void SceneViewer::flipX() {
m_viewAff[0] = m_viewAff[0] * TScale(-1, 1);
m_viewAff[1] = m_viewAff[1] * TScale(-1, 1);
double flipAngle0 = (m_rotationAngle[0] * -1) * 2;
double flipAngle1 = (m_rotationAngle[1] * -1) * 2;
m_rotationAngle[0] += flipAngle0;
m_rotationAngle[1] += flipAngle1;
if (m_isFlippedX != m_isFlippedY) {
flipAngle0 = -flipAngle0;
flipAngle1 = -flipAngle1;
}
m_viewAff[0] = m_viewAff[0] * TRotation(flipAngle0) * TScale(-1, 1);
m_viewAff[1] = m_viewAff[1] * TRotation(flipAngle1) * TScale(-1, 1);
m_viewAff[0].a13 *= -1;
m_viewAff[1].a13 *= -1;
m_isFlippedX = !m_isFlippedX;
invalidateAll();
emit onZoomChanged();
@ -2005,8 +2097,18 @@ void SceneViewer::flipX() {
//-----------------------------------------------------------------------------
void SceneViewer::flipY() {
m_viewAff[0] = m_viewAff[0] * TScale(1, -1);
m_viewAff[1] = m_viewAff[1] * TScale(1, -1);
double flipAngle0 = (m_rotationAngle[0] * -1) * 2;
double flipAngle1 = (m_rotationAngle[1] * -1) * 2;
m_rotationAngle[0] += flipAngle0;
m_rotationAngle[1] += flipAngle1;
if (m_isFlippedX != m_isFlippedY) {
flipAngle0 = -flipAngle0;
flipAngle1 = -flipAngle1;
}
m_viewAff[0] = m_viewAff[0] * TRotation(flipAngle0) * TScale(1, -1);
m_viewAff[1] = m_viewAff[1] * TRotation(flipAngle1) * TScale(1, -1);
m_viewAff[0].a23 *= -1;
m_viewAff[1].a23 *= -1;
m_isFlippedY = !m_isFlippedY;
invalidateAll();
emit onZoomChanged();
@ -2017,7 +2119,8 @@ void SceneViewer::flipY() {
void SceneViewer::rotate(const TPointD &center, double angle) {
if (angle == 0) return;
if (m_isFlippedX != m_isFlippedY) angle = -angle;
TPointD realCenter = m_viewAff[m_viewMode] * center;
m_rotationAngle[m_viewMode] += angle;
TPointD realCenter = m_viewAff[m_viewMode] * center;
setViewMatrix(TRotation(realCenter, angle) * m_viewAff[m_viewMode],
m_viewMode);
invalidateAll();
@ -2080,9 +2183,9 @@ void SceneViewer::fitToCamera() {
TPointD P11 = cameraAff * cameraRect.getP11();
TPointD p0 = TPointD(std::min({P00.x, P01.x, P10.x, P11.x}),
std::min({P00.y, P01.y, P10.y, P11.y}));
TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}),
TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}),
std::max({P00.y, P01.y, P10.y, P11.y}));
cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y);
cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y);
// Pan
if (!is3DView()) {
@ -2109,8 +2212,10 @@ void SceneViewer::resetSceneViewer() {
m_visualSettings.m_sceneProperties =
TApp::instance()->getCurrentScene()->getScene()->getProperties();
for (int i = 0; i < tArrayCount(m_viewAff); i++)
for (int i = 0; i < m_viewAff.size(); ++i) {
setViewMatrix(getNormalZoomScale(), i);
m_rotationAngle[i] = 0.0;
}
m_pos = QPoint(0, 0);
m_pan3D = TPointD(0, 0);
@ -2125,6 +2230,45 @@ void SceneViewer::resetSceneViewer() {
//-----------------------------------------------------------------------------
void SceneViewer::resetZoom() {
TPointD realCenter(m_viewAff[m_viewMode].a13, m_viewAff[m_viewMode].a23);
TAffine aff =
getNormalZoomScale() * TRotation(realCenter, m_rotationAngle[m_viewMode]);
aff.a13 = realCenter.x;
aff.a23 = realCenter.y;
if (m_isFlippedX) aff = aff * TScale(-1, 1);
if (m_isFlippedY) aff = aff * TScale(1, -1);
setViewMatrix(aff, m_viewMode);
invalidateAll();
emit onZoomChanged();
}
//-----------------------------------------------------------------------------
void SceneViewer::resetRotation() {
double reverseRotatation = m_rotationAngle[m_viewMode] * -1;
if (m_isFlippedX) reverseRotatation *= -1;
if (m_isFlippedY) reverseRotatation *= -1;
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
TPointD center = m_viewAff[m_viewMode].inv() * TPointD(0, 0);
if (tool->getName() == "T_Rotate" &&
tool->getProperties(0)
->getProperty("Rotate On Camera Center")
->getValueAsString() == "1")
center = TPointD(0, 0);
rotate(center, reverseRotatation);
}
//-----------------------------------------------------------------------------
void SceneViewer::resetPosition() {
m_viewAff[m_viewMode].a13 = 0.0;
m_viewAff[m_viewMode].a23 = 0.0;
invalidateAll();
}
//-----------------------------------------------------------------------------
void SceneViewer::setActualPixelSize() {
TApp *app = TApp::instance();
TXshLevel *l = app->getCurrentLevel()->getLevel();
@ -2148,16 +2292,17 @@ void SceneViewer::setActualPixelSize() {
} else
dpi = sl->getDpi(fid);
const double inch = Stage::inch;
TAffine tempAff = getNormalZoomScale();
if (m_isFlippedX) tempAff = tempAff * TScale(-1, 1);
if (m_isFlippedY) tempAff = tempAff * TScale(1, -1);
TPointD tempScale = dpi;
const double inch = Stage::inch;
TAffine tempAff = getNormalZoomScale();
if (m_isFlippedX) tempAff = tempAff * TScale(-1, 1);
if (m_isFlippedY) tempAff = tempAff * TScale(1, -1);
TPointD tempScale = dpi;
if (m_isFlippedX) tempScale.x = -tempScale.x;
if (m_isFlippedY) tempScale.y = -tempScale.y;
for (int i = 0; i < tArrayCount(m_viewAff); i++)
setViewMatrix(dpi == TPointD(0, 0) ? tempAff : TScale(tempScale.x / inch,
tempScale.y / inch),
for (int i = 0; i < m_viewAff.size(); ++i)
setViewMatrix(dpi == TPointD(0, 0)
? tempAff
: TScale(tempScale.x / inch, tempScale.y / inch),
i);
m_pos = QPoint(0, 0);
@ -2261,8 +2406,8 @@ int SceneViewer::pick(const TPointD &point) {
assert(glGetError() == GL_NO_ERROR);
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
GLuint selectBuffer[512];
glSelectBuffer(tArrayCount(selectBuffer), selectBuffer);
std::array<GLuint, 512> selectBuffer;
glSelectBuffer(selectBuffer.size(), selectBuffer.data());
glRenderMode(GL_SELECT);
// definisco la matrice di proiezione
@ -2321,7 +2466,7 @@ int SceneViewer::pick(const TPointD &point) {
// conto gli hits
int ret = -1;
int hitCount = glRenderMode(GL_RENDER);
GLuint *p = selectBuffer;
GLuint *p = selectBuffer.data();
for (int i = 0; i < hitCount; ++i) {
GLuint nameCount = *p++;
GLuint zmin = *p++;
@ -2440,7 +2585,7 @@ void drawSpline(const TAffine &viewMatrix, const TRect &clipRect, bool camera3d,
TStageObject *pegbar =
objId != TStageObjectId::NoneId ? xsh->getStageObject(objId) : 0;
const TStroke *stroke = 0;
const TStroke *stroke = 0;
if (pegbar && pegbar->getSpline()) stroke = pegbar->getSpline()->getStroke();
if (!stroke) return;

View file

@ -22,6 +22,7 @@
#include "pane.h"
#include "previewer.h"
#include <array>
#include <QMatrix4x4>
#include <QTouchDevice>
@ -98,11 +99,11 @@ class SceneViewer final : public GLWidgetForHighDpi,
bool m_isMouseEntered, m_forceGlFlush;
bool m_isFlippedX = false, m_isFlippedY = false;
/*! FreezedStatus:
* \li NO_FREEZED freezed is not active;
* \li NORMAL_FREEZED freezed is active: show grab image;
* \li UPDATE_FREEZED freezed is active: draw last unfreezed image and grab
* view;
*/
* \li NO_FREEZED freezed is not active;
* \li NORMAL_FREEZED freezed is active: show grab image;
* \li UPDATE_FREEZED freezed is active: draw last unfreezed image and grab
* view;
*/
enum FreezedStatus {
NO_FREEZED = 0,
NORMAL_FREEZED = 1,
@ -124,7 +125,7 @@ class SceneViewer final : public GLWidgetForHighDpi,
// current pan/zoom matrix (two different matrices are used for editing scenes
// and leves)
TAffine m_viewAff[2];
std::array<TAffine, 2> m_viewAff;
int m_viewMode;
TPointD m_dpiScale;
@ -178,6 +179,8 @@ class SceneViewer final : public GLWidgetForHighDpi,
// updated in drawScene() and used in GLInvalidateRect()
TRectD m_guidedDrawingBBox;
double m_rotationAngle[2];
public:
enum ReferenceMode {
NORMAL_REFERENCE = 1,
@ -394,6 +397,9 @@ protected:
public slots:
void resetSceneViewer();
void resetZoom();
void resetRotation();
void resetPosition();
void setActualPixelSize();
void flipX();
void flipY();

View file

@ -81,12 +81,6 @@ SceneViewerContextMenu::SceneViewerContextMenu(SceneViewer *parent)
parent->connect(action, SIGNAL(triggered()), SLOT(swapCompared()));
}
// reset
action = commandManager->createAction(V_ZoomReset, this);
addAction(action);
ret = ret &&
parent->connect(action, SIGNAL(triggered()), SLOT(resetSceneViewer()));
if (!isEditingLevel) {
// fit camera
action = commandManager->createAction(V_ZoomFit, this);
@ -95,6 +89,43 @@ SceneViewerContextMenu::SceneViewerContextMenu(SceneViewer *parent)
parent->connect(action, SIGNAL(triggered()), SLOT(fitToCamera()));
}
QMenu *flipViewMenu = addMenu(tr("Flip View"));
// flip horizontally
action = commandManager->createAction(V_FlipX, this);
flipViewMenu->addAction(action);
ret = ret && parent->connect(action, SIGNAL(triggered()), SLOT(flipX()));
// flip vertically
action = commandManager->createAction(V_FlipY, this);
flipViewMenu->addAction(action);
ret = ret && parent->connect(action, SIGNAL(triggered()), SLOT(flipY()));
QMenu *resetViewMenu = addMenu(tr("Reset View"));
// reset
action = commandManager->createAction(V_ViewReset, this);
resetViewMenu->addAction(action);
ret = ret &&
parent->connect(action, SIGNAL(triggered()), SLOT(resetSceneViewer()));
// reset zoom
action = commandManager->createAction(V_ZoomReset, this);
resetViewMenu->addAction(action);
ret = ret && parent->connect(action, SIGNAL(triggered()), SLOT(resetZoom()));
// reset rotation
action = commandManager->createAction(V_RotateReset, this);
resetViewMenu->addAction(action);
ret = ret &&
parent->connect(action, SIGNAL(triggered()), SLOT(resetRotation()));
// reset position
action = commandManager->createAction(V_PositionReset, this);
resetViewMenu->addAction(action);
ret = ret &&
parent->connect(action, SIGNAL(triggered()), SLOT(resetPosition()));
// actual pixel size
action = commandManager->createAction(V_ActualPixelSize, this);
addAction(action);

View file

@ -70,7 +70,7 @@ namespace {
void initToonzEvent(TMouseEvent &toonzEvent, QMouseEvent *event,
int widgetHeight, double pressure, int devPixRatio) {
toonzEvent.m_pos = TPointD(event->pos().x() * devPixRatio,
toonzEvent.m_pos = TPointD(event->pos().x() * devPixRatio,
widgetHeight - 1 - event->pos().y() * devPixRatio);
toonzEvent.m_mousePos = event->pos();
toonzEvent.m_pressure = 1.0;
@ -279,6 +279,8 @@ void SceneViewer::tabletEvent(QTabletEvent *e) {
initToonzEvent(mouseEvent, e, height(), m_pressure, getDevPixRatio());
m_tabletState = Touched;
onPress(mouseEvent);
} else if (m_tabletState == Touched) {
m_tabletState = StartStroke;
}
} else
m_tabletEvent = false;
@ -811,9 +813,9 @@ quit:
// Don't clear it out table state so the tablePress event will process
// correctly.
if (m_tabletState != Touched) m_tabletState = None;
m_mouseState = None;
m_tabletMove = false;
m_pressure = 0;
m_mouseState = None;
m_tabletMove = false;
m_pressure = 0;
// Leave m_tabletEvent as-is in order to check whether the onRelease is called
// from tabletEvent or not in mouseReleaseEvent.
if (m_tabletState == Released) // only clear if tabletRelease event
@ -869,12 +871,12 @@ void SceneViewer::wheelEvent(QWheelEvent *event) {
default: // Qt::MouseEventSynthesizedByQt,
// Qt::MouseEventSynthesizedByApplication
{
std::cout << "not supported event: Qt::MouseEventSynthesizedByQt, "
"Qt::MouseEventSynthesizedByApplication"
<< std::endl;
break;
}
{
std::cout << "not supported event: Qt::MouseEventSynthesizedByQt, "
"Qt::MouseEventSynthesizedByApplication"
<< std::endl;
break;
}
} // end switch
@ -966,8 +968,8 @@ void SceneViewer::gestureEvent(QGestureEvent *e) {
qreal rotationDelta =
gesture->rotationAngle() - gesture->lastRotationAngle();
if (m_isFlippedX != m_isFlippedY) rotationDelta = -rotationDelta;
TAffine aff = getViewMatrix().inv();
TPointD center = aff * TPointD(0, 0);
TAffine aff = getViewMatrix().inv();
TPointD center = aff * TPointD(0, 0);
if (!m_rotating && !m_zooming) {
m_rotationDelta += rotationDelta;
double absDelta = abs(m_rotationDelta);
@ -1047,71 +1049,70 @@ void SceneViewer::touchEvent(QTouchEvent *e, int type) {
bool SceneViewer::event(QEvent *e) {
/*
switch (e->type()) {
// case QEvent::Enter:
// qDebug() << "[enter] ************************** Enter";
// break;
// case QEvent::Leave:
// qDebug() << "[enter] ************************** Leave";
// break;
switch (e->type()) {
// case QEvent::Enter:
// qDebug() << "[enter] ************************** Enter";
// break;
// case QEvent::Leave:
// qDebug() << "[enter] ************************** Leave";
// break;
case QEvent::TabletPress: {
QTabletEvent *te = static_cast<QTabletEvent *>(e);
qDebug() << "[enter] ************************** TabletPress mouseState("
<< m_mouseState << ") tabletState(" << m_tabletState
<< ") pressure(" << m_pressure << ") pointerType("
<< te->pointerType() << ") device(" << te->device() << ")";
} break;
// case QEvent::TabletMove:
// qDebug() << "[enter] ************************** TabletMove
//mouseState("<<m_mouseState<<") tabletState("<<m_tabletState<<") pressure("
//<< m_pressure << ")";
// break;
case QEvent::TabletRelease:
qDebug() << "[enter] ************************** TabletRelease mouseState("
<< m_mouseState << ") tabletState(" << m_tabletState << ")";
break;
case QEvent::TabletPress: {
QTabletEvent *te = static_cast<QTabletEvent *>(e);
qDebug() << "[enter] ************************** TabletPress mouseState("
<< m_mouseState << ") tabletState(" << m_tabletState
<< ") pressure(" << m_pressure << ") pointerType("
<< te->pointerType() << ") device(" << te->device() << ")";
} break;
// case QEvent::TabletMove:
// qDebug() << "[enter] ************************** TabletMove
//mouseState("<<m_mouseState<<") tabletState("<<m_tabletState<<") pressure("
//<< m_pressure << ")";
// break;
case QEvent::TabletRelease:
qDebug() << "[enter] ************************** TabletRelease mouseState("
<< m_mouseState << ") tabletState(" << m_tabletState << ")";
break;
case QEvent::TouchBegin:
qDebug() << "[enter] ************************** TouchBegin";
break;
case QEvent::TouchEnd:
qDebug() << "[enter] ************************** TouchEnd";
break;
case QEvent::TouchCancel:
qDebug() << "[enter] ************************** TouchCancel";
break;
case QEvent::TouchBegin:
qDebug() << "[enter] ************************** TouchBegin";
break;
case QEvent::TouchEnd:
qDebug() << "[enter] ************************** TouchEnd";
break;
case QEvent::TouchCancel:
qDebug() << "[enter] ************************** TouchCancel";
break;
case QEvent::Gesture:
qDebug() << "[enter] ************************** Gesture";
break;
case QEvent::Gesture:
qDebug() << "[enter] ************************** Gesture";
break;
case QEvent::MouseButtonPress:
qDebug()
<< "[enter] ************************** MouseButtonPress mouseState("
<< m_mouseState << ") tabletState(" << m_tabletState << ") pressure("
<< m_pressure << ") tabletEvent(" << m_tabletEvent << ")";
break;
// case QEvent::MouseMove:
// qDebug() << "[enter] ************************** MouseMove mouseState("
//<< m_mouseState << ") tabletState("<<m_tabletState<<") pressure(" <<
//m_pressure << ")";
// break;
case QEvent::MouseButtonRelease:
qDebug()
<< "[enter] ************************** MouseButtonRelease mouseState("
<< m_mouseState << ") tabletState(" << m_tabletState << ")";
break;
case QEvent::MouseButtonPress:
qDebug()
<< "[enter] ************************** MouseButtonPress mouseState("
<< m_mouseState << ") tabletState(" << m_tabletState << ") pressure("
<< m_pressure << ") tabletEvent(" << m_tabletEvent << ")";
break;
// case QEvent::MouseMove:
// qDebug() << "[enter] ************************** MouseMove mouseState("
//<< m_mouseState << ") tabletState("<<m_tabletState<<") pressure(" <<
//m_pressure << ")";
// break;
case QEvent::MouseButtonRelease:
qDebug()
<< "[enter] ************************** MouseButtonRelease mouseState("
<< m_mouseState << ") tabletState(" << m_tabletState << ")";
break;
case QEvent::MouseButtonDblClick:
qDebug() << "[enter] ============================== MouseButtonDblClick";
break;
}
case QEvent::MouseButtonDblClick:
qDebug() << "[enter] ============================== MouseButtonDblClick";
break;
}
*/
if (e->type() == QEvent::Gesture &&
CommandManager::instance()
->getAction(MI_TouchGestureControl)
->isChecked()) {
if (e->type() == QEvent::Gesture && CommandManager::instance()
->getAction(MI_TouchGestureControl)
->isChecked()) {
gestureEvent(static_cast<QGestureEvent *>(e));
return true;
}
@ -1181,11 +1182,11 @@ class ViewerZoomer final : public ImageUtils::ShortcutZoomer {
public:
ViewerZoomer(SceneViewer *parent) : ShortcutZoomer(parent) {}
bool zoom(bool zoomin, bool resetZoom) override {
bool zoom(bool zoomin, bool resetView) override {
SceneViewer *sceneViewer = static_cast<SceneViewer *>(getWidget());
resetZoom ? sceneViewer->resetSceneViewer()
: sceneViewer->zoomQt(zoomin, resetZoom);
resetView ? sceneViewer->resetSceneViewer()
: sceneViewer->zoomQt(zoomin, resetView);
return true;
}
@ -1210,6 +1211,21 @@ public:
return true;
}
bool resetZoom() override {
static_cast<SceneViewer *>(getWidget())->resetZoom();
return true;
}
bool resetRotation() override {
static_cast<SceneViewer *>(getWidget())->resetRotation();
return true;
}
bool resetPosition() override {
static_cast<SceneViewer *>(getWidget())->resetPosition();
return true;
}
bool toggleFullScreen(bool quit) override {
if (ImageUtils::FullScreenWidget *fsWidget =
dynamic_cast<ImageUtils::FullScreenWidget *>(

View file

@ -95,9 +95,9 @@ StartupPopup::StartupPopup()
: Dialog(TApp::instance()->getMainWindow(), true, true, "StartupPopup") {
setWindowTitle(tr("OpenToonz Startup"));
m_projectBox = new QGroupBox(tr("Choose Project"), this);
m_projectBox = new QGroupBox(tr("Current Project"), this);
m_sceneBox = new QGroupBox(tr("Create a New Scene"), this);
m_recentBox = new QGroupBox(tr("Open Scene"), this);
m_recentBox = new QGroupBox(tr("Recent Scenes [Project]"), this);
m_projectBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_nameFld = new LineEdit(this);
m_pathFld = new FileField(this);
@ -168,6 +168,7 @@ StartupPopup::StartupPopup()
m_sceneBox->setMinimumWidth(480);
m_projectBox->setMinimumWidth(480);
m_buttonFrame->setFixedHeight(34);
//--- layout
m_topLayout->setMargin(0);
m_topLayout->setSpacing(0);
@ -240,14 +241,15 @@ StartupPopup::StartupPopup()
newSceneLay->addWidget(createButton, 7, 1, 1, 3, Qt::AlignLeft);
}
m_sceneBox->setLayout(newSceneLay);
guiLay->addWidget(m_sceneBox, 2, 0, 4, 1, Qt::AlignLeft);
guiLay->addWidget(m_sceneBox, 2, 0, 4, 1, Qt::AlignTop);
m_recentSceneLay->setMargin(5);
m_recentSceneLay->setSpacing(2);
{
// Recent Scene List
m_recentBox->setLayout(m_recentSceneLay);
guiLay->addWidget(m_recentBox, 1, 1, 4, 1, Qt::AlignTop);
guiLay->addWidget(m_recentBox, 1, 1, 4, 1,
Qt::AlignTop | Qt::AlignHCenter);
guiLay->addWidget(loadOtherSceneButton, 5, 1, 1, 1, Qt::AlignRight);
}
m_topLayout->addLayout(guiLay, 0);
@ -409,10 +411,13 @@ void StartupPopup::refreshRecentScenes() {
int i = 0;
for (QString name : m_sceneNames) {
if (i > 9) break; // box can hold 10 scenes
QString justName = QString::fromStdString(TFilePath(name).getName());
QString fileName =
name.remove(0, name.indexOf(" ") + 1); // remove "#. " prefix
QString projectName = RecentFiles::instance()->getFileProject(fileName);
QString justName = QString::fromStdString(TFilePath(fileName).getName()) +
(projectName != "-" ? " [" + projectName + "]" : "");
m_recentNamesLabels[i] = new StartupLabel(justName, this, i);
m_recentNamesLabels[i]->setToolTip(
name.remove(0, name.indexOf(" ") + 1)); // remove "#. " prefix
m_recentNamesLabels[i]->setToolTip(fileName);
m_recentSceneLay->addWidget(m_recentNamesLabels[i], 0, Qt::AlignTop);
i++;
}
@ -856,8 +861,34 @@ void StartupPopup::onRecentSceneClicked(int index) {
DVGui::warning(msg);
refreshRecentScenes();
} else {
IoCmd::loadScene(TFilePath(path.toStdWString()), false);
RecentFiles::instance()->moveFilePath(index, 0, RecentFiles::Scene);
if (RecentFiles::instance()->getFileProject(index) != "-") {
QString projectName = RecentFiles::instance()->getFileProject(index);
int projectIndex = m_projectsCB->findText(projectName);
if (projectIndex >= 0) {
TFilePath projectFp = m_projectPaths[projectIndex];
TProjectManager::instance()->setCurrentProjectPath(projectFp);
} else {
QString msg = tr("The selected scene project '%1' is not in the "
"Current Project list and may not open automatically.")
.arg(projectName);
DVGui::warning(msg);
}
}
IoCmd::loadScene(TFilePath(path.toStdWString()), false, true);
if (RecentFiles::instance()->getFileProject(index) == "-") {
QString fileName =
RecentFiles::instance()->getFilePath(index, RecentFiles::Scene);
QString projectName = QString::fromStdString(TApp::instance()
->getCurrentScene()
->getScene()
->getProject()
->getName()
.getName());
RecentFiles::instance()->removeFilePath(index, RecentFiles::Scene);
RecentFiles::instance()->addFilePath(fileName, RecentFiles::Scene,
projectName);
} else
RecentFiles::instance()->moveFilePath(index, 0, RecentFiles::Scene);
RecentFiles::instance()->refreshRecentFilesMenu(RecentFiles::Scene);
hide();
}

View file

@ -267,8 +267,9 @@ int TApp::getCurrentLevelStyleIndex() const {
//-----------------------------------------------------------------------------
void TApp::setCurrentLevelStyleIndex(int index) {
m_paletteController->getCurrentLevelPalette()->setStyleIndex(index);
void TApp::setCurrentLevelStyleIndex(int index, bool forceUpdate) {
m_paletteController->getCurrentLevelPalette()->setStyleIndex(index,
forceUpdate);
}
//-----------------------------------------------------------------------------

View file

@ -160,7 +160,7 @@ public:
int getCurrentLevelStyleIndex() const override;
void setCurrentLevelStyleIndex(int index) override;
void setCurrentLevelStyleIndex(int index, bool forceUpdate = false) override;
void setMainWindow(QMainWindow *mainWindow) { m_mainWindow = mainWindow; }
/*!

View file

@ -324,7 +324,7 @@ void TaskSheet::update(TFarmTask *task) {
m_commandLine->setText(task->getCommandLine());
m_server->setText(task->m_server);
m_submittedBy->setText(task->m_user);
m_submittedOn->setText(task->m_submissionDate.toString());
m_submittedOn->setText(task->m_callerMachineName);
m_priority->setText(QString::number(task->m_priority));
m_submitDate->setText(task->m_submissionDate.toString());
m_startDate->setText(task->m_startDate.toString());

View file

@ -53,6 +53,7 @@
#include "toonzqt/tselectionhandle.h"
#include "toonzqt/tmessageviewer.h"
#include "toonzqt/scriptconsole.h"
#include "toonzqt/fxsettings.h"
// TnzLib includes
#include "toonz/palettecontroller.h"
@ -1358,3 +1359,52 @@ public:
OpenFloatingPanel openHistoryPanelCommand(MI_OpenHistoryPanel, "HistoryPanel",
QObject::tr("History"));
//=============================================================================
//=============================================================================
// FxSettings
//-----------------------------------------------------------------------------
FxSettingsPanel::FxSettingsPanel(QWidget *parent) : TPanel(parent) {
TApp *app = TApp::instance();
TSceneHandle *hScene = app->getCurrentScene();
TPixel32 col1, col2;
Preferences::instance()->getChessboardColors(col1, col2);
m_fxSettings = new FxSettings(this, col1, col2);
m_fxSettings->setSceneHandle(hScene);
m_fxSettings->setFxHandle(app->getCurrentFx());
m_fxSettings->setFrameHandle(app->getCurrentFrame());
m_fxSettings->setXsheetHandle(app->getCurrentXsheet());
m_fxSettings->setLevelHandle(app->getCurrentLevel());
m_fxSettings->setObjectHandle(app->getCurrentObject());
m_fxSettings->setCurrentFx();
setWidget(m_fxSettings);
}
//=============================================================================
// FxSettingsFactory
//-----------------------------------------------------------------------------
class FxSettingsFactory final : public TPanelFactory {
public:
FxSettingsFactory() : TPanelFactory("FxSettings") {}
TPanel *createPanel(QWidget *parent) override {
FxSettingsPanel *panel = new FxSettingsPanel(parent);
panel->move(qApp->desktop()->screenGeometry(panel).center());
panel->setObjectName(getPanelType());
panel->setWindowTitle(QObject::tr("Fx Settings"));
panel->setMinimumSize(390, 85);
panel->allowMultipleInstances(false);
return panel;
}
void initialize(TPanel *panel) override { assert(0); }
} FxSettingsFactory;
//=============================================================================
OpenFloatingPanel openFxSettingsCommand(MI_FxParamEditor, "FxSettings",
QObject::tr("Fx Settings"));

View file

@ -25,6 +25,8 @@ class FunctionViewer;
class FlipBook;
class ToolOptions;
class ComboViewerPanel;
class FxSettings;
//=========================================================
// PaletteViewerPanel
//---------------------------------------------------------
@ -267,4 +269,17 @@ protected:
void widgetClearFocusOnLeave() override;
};
//=========================================================
// FxSettingsPanel
//---------------------------------------------------------
class FxSettingsPanel final : public TPanel {
Q_OBJECT
FxSettings *m_fxSettings;
public:
FxSettingsPanel(QWidget *parent);
};
#endif

View file

@ -27,6 +27,7 @@
#include "toonz/tonionskinmaskhandle.h"
#include "toutputproperties.h"
#include "toonz/preferences.h"
#include "toonz/tproject.h"
// TnzQt includes
#include "toonzqt/menubarcommand.h"
@ -521,10 +522,12 @@ void SceneViewerPanel::changeWindowTitle() {
int frame = app->getCurrentFrame()->getFrame();
QString name;
if (app->getCurrentFrame()->isEditingScene()) {
QString sceneName = QString::fromStdWString(scene->getSceneName());
TProject *project = scene->getProject();
QString projectName = QString::fromStdString(project->getName().getName());
QString sceneName = QString::fromStdWString(scene->getSceneName());
if (sceneName.isEmpty()) sceneName = tr("Untitled");
if (app->getCurrentScene()->getDirtyFlag()) sceneName += QString("*");
name = tr("Scene: ") + sceneName;
name = tr("Scene: ") + sceneName + tr(" :: Project: ") + projectName;
if (frame >= 0)
name =
name + tr(" :: Frame: ") + tr(std::to_string(frame + 1).c_str());

View file

@ -183,10 +183,7 @@ bool CellsMover::canMoveCells(const TPoint &pos) {
while (i < m_rowCount * m_colCount) {
TXshColumn::ColumnType srcType = getColumnTypeFromCell(i);
int dstIndex = c + i;
if (!m_orientation->isVerticalTimeline() &&
dstIndex >= xsh->getColumnCount())
return false;
TXshColumn *dstColumn = xsh->getColumn(dstIndex);
TXshColumn *dstColumn = xsh->getColumn(dstIndex);
if (srcType == TXshColumn::eZeraryFxType ||
srcType == TXshColumn::eSoundTextType)
return false;

View file

@ -318,46 +318,36 @@ bool isGlobalKeyFrameWithSameTypeDiffFromLinear(TStageObject *stageObject,
TDoubleKeyframe::Type type =
stageObject->getParam(TStageObject::T_Angle)->getKeyframeAt(frame).m_type;
if (type == TDoubleKeyframe::Linear) return false;
if (type !=
stageObject->getParam(TStageObject::T_X)
->getKeyframeAt(frame)
.m_type ||
type !=
stageObject->getParam(TStageObject::T_Y)
->getKeyframeAt(frame)
.m_type ||
type !=
stageObject->getParam(TStageObject::T_Z)
->getKeyframeAt(frame)
.m_type ||
type !=
stageObject->getParam(TStageObject::T_SO)
->getKeyframeAt(frame)
.m_type ||
type !=
stageObject->getParam(TStageObject::T_ScaleX)
->getKeyframeAt(frame)
.m_type ||
type !=
stageObject->getParam(TStageObject::T_ScaleY)
->getKeyframeAt(frame)
.m_type ||
type !=
stageObject->getParam(TStageObject::T_Scale)
->getKeyframeAt(frame)
.m_type ||
type !=
stageObject->getParam(TStageObject::T_Path)
->getKeyframeAt(frame)
.m_type ||
type !=
stageObject->getParam(TStageObject::T_ShearX)
->getKeyframeAt(frame)
.m_type ||
type !=
stageObject->getParam(TStageObject::T_ShearY)
->getKeyframeAt(frame)
.m_type)
if (type != stageObject->getParam(TStageObject::T_X)
->getKeyframeAt(frame)
.m_type ||
type != stageObject->getParam(TStageObject::T_Y)
->getKeyframeAt(frame)
.m_type ||
type != stageObject->getParam(TStageObject::T_Z)
->getKeyframeAt(frame)
.m_type ||
type != stageObject->getParam(TStageObject::T_SO)
->getKeyframeAt(frame)
.m_type ||
type != stageObject->getParam(TStageObject::T_ScaleX)
->getKeyframeAt(frame)
.m_type ||
type != stageObject->getParam(TStageObject::T_ScaleY)
->getKeyframeAt(frame)
.m_type ||
type != stageObject->getParam(TStageObject::T_Scale)
->getKeyframeAt(frame)
.m_type ||
type != stageObject->getParam(TStageObject::T_Path)
->getKeyframeAt(frame)
.m_type ||
type != stageObject->getParam(TStageObject::T_ShearX)
->getKeyframeAt(frame)
.m_type ||
type != stageObject->getParam(TStageObject::T_ShearY)
->getKeyframeAt(frame)
.m_type)
return false;
return true;
}
@ -380,46 +370,36 @@ bool isGlobalKeyFrameWithSamePrevTypeDiffFromLinear(TStageObject *stageObject,
->getKeyframeAt(frame)
.m_prevType;
if (type == TDoubleKeyframe::Linear) return false;
if (type !=
stageObject->getParam(TStageObject::T_X)
->getKeyframeAt(frame)
.m_prevType ||
type !=
stageObject->getParam(TStageObject::T_Y)
->getKeyframeAt(frame)
.m_prevType ||
type !=
stageObject->getParam(TStageObject::T_Z)
->getKeyframeAt(frame)
.m_prevType ||
type !=
stageObject->getParam(TStageObject::T_SO)
->getKeyframeAt(frame)
.m_prevType ||
type !=
stageObject->getParam(TStageObject::T_ScaleX)
->getKeyframeAt(frame)
.m_prevType ||
type !=
stageObject->getParam(TStageObject::T_ScaleY)
->getKeyframeAt(frame)
.m_prevType ||
type !=
stageObject->getParam(TStageObject::T_Scale)
->getKeyframeAt(frame)
.m_prevType ||
type !=
stageObject->getParam(TStageObject::T_Path)
->getKeyframeAt(frame)
.m_prevType ||
type !=
stageObject->getParam(TStageObject::T_ShearX)
->getKeyframeAt(frame)
.m_prevType ||
type !=
stageObject->getParam(TStageObject::T_ShearY)
->getKeyframeAt(frame)
.m_prevType)
if (type != stageObject->getParam(TStageObject::T_X)
->getKeyframeAt(frame)
.m_prevType ||
type != stageObject->getParam(TStageObject::T_Y)
->getKeyframeAt(frame)
.m_prevType ||
type != stageObject->getParam(TStageObject::T_Z)
->getKeyframeAt(frame)
.m_prevType ||
type != stageObject->getParam(TStageObject::T_SO)
->getKeyframeAt(frame)
.m_prevType ||
type != stageObject->getParam(TStageObject::T_ScaleX)
->getKeyframeAt(frame)
.m_prevType ||
type != stageObject->getParam(TStageObject::T_ScaleY)
->getKeyframeAt(frame)
.m_prevType ||
type != stageObject->getParam(TStageObject::T_Scale)
->getKeyframeAt(frame)
.m_prevType ||
type != stageObject->getParam(TStageObject::T_Path)
->getKeyframeAt(frame)
.m_prevType ||
type != stageObject->getParam(TStageObject::T_ShearX)
->getKeyframeAt(frame)
.m_prevType ||
type != stageObject->getParam(TStageObject::T_ShearY)
->getKeyframeAt(frame)
.m_prevType)
return false;
return true;
}
@ -778,7 +758,7 @@ void RenameCellField::renameCell() {
fid = TFrameId(fidRe.cap(1).toInt(),
fidRe.cap(2) == "" ? 0 : fidRe.cap(2).toLatin1()[0]);
#else
fid = TFrameId(fidRe.cap(1).toInt(),
fid = TFrameId(fidRe.cap(1).toInt(),
fidRe.cap(2) == "" ? 0 : fidRe.cap(2).toAscii()[0]);
#endif
FilmstripCmd::renumberDrawing(sl, cell.m_frameId, fid);
@ -828,7 +808,7 @@ void RenameCellField::renameCell() {
}
TXshLevel *xl = cell.m_level.getPointer();
if (!xl || (xl->getSimpleLevel() &&
if (!xl || (xl->getSimpleLevel() && !xl->getSimpleLevel()->isEmpty() &&
xl->getSimpleLevel()->getFirstFid() == TFrameId::NO_FRAME)) {
cells.append(TXshCell());
continue;
@ -1794,10 +1774,10 @@ void CellArea::drawLevelCell(QPainter &p, int row, int col, bool isReference) {
nameRect.adjust(0, 0, -frameAdj, 0);
// draw text in red if the file does not exist
bool isRed = false;
TXshSimpleLevel *sl = cell.getSimpleLevel();
bool isRed = false;
TXshSimpleLevel *sl = cell.getSimpleLevel();
if (sl && !sl->isFid(cell.m_frameId)) isRed = true;
TXshChildLevel *cl = cell.getChildLevel();
TXshChildLevel *cl = cell.getChildLevel();
if (cl && cell.getFrameId().getNumber() - 1 >= cl->getFrameCount())
isRed = true;
QColor penColor =
@ -1897,8 +1877,9 @@ void CellArea::drawSoundTextCell(QPainter &p, int row, int col) {
bool isSelected = cellSelection->isCellSelected(row, col) ||
columnSelection->isColumnSelected(col);
if (row > 0) prevCell = xsh->getCell(row - 1, col); // cell in previous frame
// nothing to draw
if (row > 0)
prevCell = xsh->getCell(row - 1, col); // cell in previous frame
// nothing to draw
bool sameLevel = prevCell.m_level.getPointer() == cell.m_level.getPointer();
@ -2004,7 +1985,7 @@ void CellArea::drawSoundTextCell(QPainter &p, int row, int col) {
#ifdef _WIN32
fontName = "Arial";
#else
fontName = "Helvetica";
fontName = "Helvetica";
#endif
}
static QFont font(fontName, -1, QFont::Normal);
@ -2036,7 +2017,7 @@ void CellArea::drawSoundTextCell(QPainter &p, int row, int col) {
#if QT_VERSION >= 0x050500
QString elidaName = elideText(text, metric, nameRect.width(), "~");
#else
QString elidaName = elideText(text, font, nameRect.width(), "~");
QString elidaName = elideText(text, font, nameRect.width(), "~");
#endif
if (!sameLevel || prevCell.m_frameId != cell.m_frameId)
@ -2057,7 +2038,7 @@ void CellArea::drawPaletteCell(QPainter &p, int row, int col,
bool isSelected = cellSelection->isCellSelected(row, col);
if (row > 0) prevCell = xsh->getCell(row - 1, col);
TXshCell nextCell = xsh->getCell(row + 1, col);
TXshCell nextCell = xsh->getCell(row + 1, col);
bool sameLevel = prevCell.m_level.getPointer() == cell.m_level.getPointer();
@ -2068,8 +2049,8 @@ void CellArea::drawPaletteCell(QPainter &p, int row, int col,
bool isAfterMarkers =
distance > 0 && ((row - offset) % distance) == 0 && row != 0;
bool isRed = false;
TXshPaletteLevel *pl = cell.getPaletteLevel();
bool isRed = false;
TXshPaletteLevel *pl = cell.getPaletteLevel();
if (pl && !pl->getPalette()) isRed = true;
QPoint xy = m_viewer->positionToXY(CellPosition(row, col));
@ -2201,7 +2182,7 @@ void CellArea::drawPaletteCell(QPainter &p, int row, int col,
#ifdef _WIN32
fontName = "Arial";
#else
fontName = "Helvetica";
fontName = "Helvetica";
#endif
}
static QFont font(fontName, -1, QFont::Normal);
@ -2531,6 +2512,8 @@ public:
void undo() const override {
m_pegbar->enableCycle(!m_pegbar->isCycleEnabled());
m_area->update();
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
TApp::instance()->getCurrentObject()->notifyObjectIdChanged(false);
}
void redo() const override { undo(); }
int getSize() const override { return sizeof *this; }
@ -2694,8 +2677,9 @@ void CellArea::mousePressEvent(QMouseEvent *event) {
} else if (isKeyframeFrame && row == k1 + 1 &&
o->rect(PredefinedRect::LOOP_ICON)
.contains(mouseInCell)) { // cycle toggle
pegbar->enableCycle(!pegbar->isCycleEnabled());
TUndoManager::manager()->add(new CycleUndo(pegbar, this));
CycleUndo *undo = new CycleUndo(pegbar, this);
undo->redo();
TUndoManager::manager()->add(undo);
accept = true;
}
if (accept) {
@ -2709,11 +2693,16 @@ void CellArea::mousePressEvent(QMouseEvent *event) {
if (m_levelExtenderRect.contains(pos.x, pos.y)) {
m_viewer->getKeyframeSelection()->selectNone();
setDragTool(XsheetGUI::DragTool::makeLevelExtenderTool(m_viewer));
if (event->modifiers() & Qt::ControlModifier)
setDragTool(
XsheetGUI::DragTool::makeLevelExtenderTool(m_viewer, false));
else
setDragTool(XsheetGUI::DragTool::makeLevelExtenderTool(m_viewer, true));
} else if (event->modifiers() & Qt::ControlModifier &&
m_upperLevelExtenderRect.contains(pos.x, pos.y)) {
m_viewer->getKeyframeSelection()->selectNone();
setDragTool(XsheetGUI::DragTool::makeLevelExtenderTool(m_viewer, true));
setDragTool(
XsheetGUI::DragTool::makeLevelExtenderTool(m_viewer, false, true));
} else if ((!xsh->getCell(row, col).isEmpty()) &&
o->rect(PredefinedRect::DRAG_AREA)
.adjusted(0, 0, -frameAdj, 0)
@ -2742,10 +2731,9 @@ void CellArea::mousePressEvent(QMouseEvent *event) {
setDragTool(XsheetGUI::DragTool::makeLevelMoverTool(m_viewer));
} else {
m_viewer->getKeyframeSelection()->selectNone();
if (isSoundColumn &&
o->rect(PredefinedRect::PREVIEW_TRACK)
.adjusted(0, 0, -frameAdj, 0)
.contains(mouseInCell))
if (isSoundColumn && o->rect(PredefinedRect::PREVIEW_TRACK)
.adjusted(0, 0, -frameAdj, 0)
.contains(mouseInCell))
setDragTool(XsheetGUI::DragTool::makeSoundScrubTool(
m_viewer, column->getSoundColumn()));
else if (isSoundColumn &&
@ -2879,10 +2867,9 @@ void CellArea::mouseMoveEvent(QMouseEvent *event) {
: QString::fromStdWString(levelName) + QString(" ") +
QString::fromStdString(frameNumber));
}
} else if (isSoundColumn &&
o->rect(PredefinedRect::PREVIEW_TRACK)
.adjusted(0, 0, -frameAdj, 0)
.contains(mouseInCell))
} else if (isSoundColumn && o->rect(PredefinedRect::PREVIEW_TRACK)
.adjusted(0, 0, -frameAdj, 0)
.contains(mouseInCell))
m_tooltip = tr("Click and drag to play");
else if (m_levelExtenderRect.contains(pos))
m_tooltip = tr("Click and drag to repeat selected cells");
@ -3132,9 +3119,8 @@ const bool CellArea::isControlPressed() { return isCtrlPressed; }
void CellArea::createCellMenu(QMenu &menu, bool isCellSelected, TXshCell cell) {
CommandManager *cmdManager = CommandManager::instance();
bool soundCellsSelected = m_viewer->areSoundCellsSelected();
if (m_viewer->areSoundTextCellsSelected()) return; // Magpies stop here
bool soundCellsSelected = m_viewer->areSoundCellsSelected();
bool soundTextCellsSelected = m_viewer->areSoundTextCellsSelected();
menu.addSeparator();
@ -3145,13 +3131,17 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected, TXshCell cell) {
}
if (isCellSelected) {
bool addSeparator = false;
// open fx settings instead of level settings when clicked on zerary fx
// level
if (cell.m_level && cell.m_level->getZeraryFxLevel())
if (cell.m_level && cell.m_level->getZeraryFxLevel()) {
menu.addAction(cmdManager->getAction(MI_FxParamEditor));
else
addSeparator = true;
} else if (!soundTextCellsSelected) {
menu.addAction(cmdManager->getAction(MI_LevelSettings));
menu.addSeparator();
addSeparator = true;
}
if (addSeparator) menu.addSeparator();
if (!soundCellsSelected) {
QMenu *reframeSubMenu = new QMenu(tr("Reframe"), this);
@ -3183,74 +3173,81 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected, TXshCell cell) {
}
menu.addMenu(eachSubMenu);
QMenu *editCellNumbersMenu = new QMenu(tr("Edit Cell Numbers"), this);
{
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Reverse));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Swing));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Random));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Dup));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Rollup));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Rolldown));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_TimeStretch));
editCellNumbersMenu->addAction(
cmdManager->getAction(MI_AutoInputCellNumber));
if (!soundTextCellsSelected) {
QMenu *editCellNumbersMenu = new QMenu(tr("Edit Cell Numbers"), this);
{
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Reverse));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Swing));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Random));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Dup));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Rollup));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Rolldown));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_TimeStretch));
editCellNumbersMenu->addAction(
cmdManager->getAction(MI_AutoInputCellNumber));
}
menu.addMenu(editCellNumbersMenu);
}
menu.addMenu(editCellNumbersMenu);
menu.addAction(cmdManager->getAction(MI_FillEmptyCell));
menu.addSeparator();
menu.addAction(cmdManager->getAction(MI_Autorenumber));
if (!soundTextCellsSelected)
menu.addAction(cmdManager->getAction(MI_Autorenumber));
}
QMenu *replaceLevelMenu = new QMenu(tr("Replace Level"), this);
menu.addMenu(replaceLevelMenu);
if (!soundTextCellsSelected) {
QMenu *replaceLevelMenu = new QMenu(tr("Replace Level"), this);
menu.addMenu(replaceLevelMenu);
replaceLevelMenu->addAction(cmdManager->getAction(MI_ReplaceLevel));
replaceLevelMenu->addAction(cmdManager->getAction(MI_ReplaceLevel));
replaceLevelMenu->addAction(
cmdManager->getAction(MI_ReplaceParentDirectory));
replaceLevelMenu->addAction(
cmdManager->getAction(MI_ReplaceParentDirectory));
{
// replace with another level in scene cast
std::vector<TXshLevel *> levels;
TApp::instance()
->getCurrentScene()
->getScene()
->getLevelSet()
->listLevels(levels);
if (!levels.empty()) {
QMenu *replaceMenu = replaceLevelMenu->addMenu(tr("Replace with"));
connect(replaceMenu, SIGNAL(triggered(QAction *)), this,
SLOT(onReplaceByCastedLevel(QAction *)));
for (int i = 0; i < (int)levels.size(); i++) {
if (!levels[i]->getSimpleLevel() && !levels[i]->getChildLevel())
continue;
{
// replace with another level in scene cast
std::vector<TXshLevel *> levels;
TApp::instance()
->getCurrentScene()
->getScene()
->getLevelSet()
->listLevels(levels);
if (!levels.empty()) {
QMenu *replaceMenu = replaceLevelMenu->addMenu(tr("Replace with"));
connect(replaceMenu, SIGNAL(triggered(QAction *)), this,
SLOT(onReplaceByCastedLevel(QAction *)));
for (int i = 0; i < (int)levels.size(); i++) {
if (!levels[i]->getSimpleLevel() && !levels[i]->getChildLevel())
continue;
if (levels[i]->getChildLevel() &&
!TApp::instance()->getCurrentXsheet()->getXsheet()->isLevelUsed(
levels[i]))
continue;
if (levels[i]->getChildLevel() &&
!TApp::instance()->getCurrentXsheet()->getXsheet()->isLevelUsed(
levels[i]))
continue;
QString tmpLevelName = QString::fromStdWString(levels[i]->getName());
QAction *tmpAction = new QAction(tmpLevelName, replaceMenu);
tmpAction->setData(tmpLevelName);
replaceMenu->addAction(tmpAction);
QString tmpLevelName =
QString::fromStdWString(levels[i]->getName());
QAction *tmpAction = new QAction(tmpLevelName, replaceMenu);
tmpAction->setData(tmpLevelName);
replaceMenu->addAction(tmpAction);
}
}
}
}
if (!soundCellsSelected) {
if (selectionContainTlvImage(m_viewer->getCellSelection(),
m_viewer->getXsheet()))
replaceLevelMenu->addAction(
cmdManager->getAction(MI_RevertToCleanedUp));
if (selectionContainLevelImage(m_viewer->getCellSelection(),
if (!soundCellsSelected && !soundTextCellsSelected) {
if (selectionContainTlvImage(m_viewer->getCellSelection(),
m_viewer->getXsheet()))
replaceLevelMenu->addAction(
cmdManager->getAction(MI_RevertToLastSaved));
menu.addAction(cmdManager->getAction(MI_SetKeyframes));
replaceLevelMenu->addAction(
cmdManager->getAction(MI_RevertToCleanedUp));
if (selectionContainLevelImage(m_viewer->getCellSelection(),
m_viewer->getXsheet()))
replaceLevelMenu->addAction(
cmdManager->getAction(MI_RevertToLastSaved));
menu.addAction(cmdManager->getAction(MI_SetKeyframes));
}
menu.addSeparator();
}
menu.addSeparator();
menu.addAction(cmdManager->getAction(MI_Cut));
menu.addAction(cmdManager->getAction(MI_Copy));
@ -3265,7 +3262,8 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected, TXshCell cell) {
menu.addAction(cmdManager->getAction(MI_Clear));
menu.addAction(cmdManager->getAction(MI_Insert));
menu.addAction(cmdManager->getAction(MI_Duplicate));
if (!soundTextCellsSelected)
menu.addAction(cmdManager->getAction(MI_Duplicate));
menu.addSeparator();
TXshSimpleLevel *sl = TApp::instance()->getCurrentLevel()->getSimpleLevel();
@ -3513,4 +3511,4 @@ void CellArea::onStepChanged(QAction *act) {
//-----------------------------------------------------------------------------
} // namespace XsheetGUI;
} // namespace XsheetGUI

Some files were not shown because too many files have changed in this diff Show more