Version: 6.3.1
Public Types | Static Public Member Functions

SUIT_Tools Class Reference

#include <SUIT_Tools.h>

Inheritance diagram for SUIT_Tools:
Inheritance graph

Public Types

enum  AlignmentFlags {
  AlignLeft = Qt::AlignLeft, AlignLeading = Qt::AlignLeading, AlignRight = Qt::AlignRight, AlignTrailing = Qt::AlignTrailing,
  AlignHCenter = Qt::AlignHCenter, AlignJustify = Qt::AlignJustify, AlignAbsolute = Qt::AlignAbsolute, AlignHorizontal_Mask = Qt::AlignHorizontal_Mask,
  AlignTop = Qt::AlignTop, AlignBottom = Qt::AlignBottom, AlignVCenter = Qt::AlignVCenter, AlignVertical_Mask = Qt::AlignVertical_Mask,
  AlignCenter = Qt::AlignCenter, AlignOutLeft = Qt::AlignVCenter << 2, AlignOutRight = AlignOutLeft << 2, AlignOutTop = AlignOutRight << 2,
  AlignOutBottom = AlignOutTop << 2
}
 

Widget alignment flags.

More...
enum  PathType { PT_OpenFile, PT_SaveFile, PT_Directory }
 

Path type, indicates required directory/file operation.

More...
enum  { AppropriateRole = Qt::UserRole + 100 }
 

Custom data roles.

More...
enum  Appropriate { Shown, Hidden, Toggled }
enum  SubstMode { Always, Never, Auto }
 

Environment variables substitution mode.

More...
enum  VisibilityState { ShownState, HiddenState, UnpresentableState }
 

object visibility state

More...
enum  HeaderViewFlags { ShowText = 0x001, ShowIcon = 0x010, ShowAll = ShowText | ShowIcon }
 

Header view flags.

More...
enum  CustomDataType { IdType }

Static Public Member Functions

static void trace (const char *pLog, const char *szFormat,...)
 Traces output to log-file.
static QRect makeRect (const int x1, const int y1, const int x2, const int y2)
static QString fontToString (const QFont &font)
static QFont stringToFont (const QString &fontDescription)
static void centerWidget (QWidget *src, const QWidget *ref)
static QString toQString (const char *, const int=-1)
 Convert character array (ASCII string) to the QString.
static QString toQString (const short *, const int=-1)
 Convert integer array (UNICODE string) to the QString.
static QString toQString (const unsigned char *, const int=-1)
 Convert character array (ASCII string) to the QString.
static QString toQString (const unsigned short *, const int=-1)
 Convert integer array (UNICODE string) to the QString.
static void setTabOrder (QWidget *,...)
 Set tab order for specified list of widgets.
static void setTabOrder (const QWidgetList &)
 Set tab order for specified list of widgets.
static void alignWidget (QWidget *, const QWidget *, const int)
 Align widget src relative to widget ref acording to the alignment flags alignFlags.
static void simplifySeparators (QWidget *, const bool=true)
 Remove (recursively) unnecessary separators from the menu or toolbar.
static bool isParent (QObject *, QObject *)
 Return true if specified parent is a parent object of given child (in terms of QObject).
static QObjectfindParent (QObject *, const char *)
 Find the parent object of class specified by className (in terms of QObject).
static QString dir (const QString &, const bool=true)
 Return directory part of the file path.
static QString file (const QString &, const bool=true)
 Return file name part of the file path.
static QString extension (const QString &, const bool=false)
 Return extension part of the file path.
static QString library (const QString &)
 Convert the given parameter to the platform-specific library name.
static QString tmpDir ()
 Get the temporary directory name.
static bool mkDir (const QString &)
 Create directory recursively including all intermediate sub directories.
static bool rmDir (const QString &)
 Remove directory recursively including all subdirectories and files.
static bool dos2unix (const QString &)
 Convert text file from DOS format to UNIX.
static QString addSlash (const QString &)
 Add a slash (platform-specific) to the end of path if it is not already there.
static QCompleter * pathCompleter (const PathType, const QString &=QString())
 Create path completer which can be used in the widgets to provide auto completions.
static QString findEnvVar (const QString &, int &, int &)
 Parse given string to retrieve environment variable.
static QString makeEnvVarSubst (const QString &, const SubstMode=Auto)
 Substitute environment variables by their values.
static int rgbSet (const QColor &)
 Pack the specified color into integer RGB set.
static int rgbSet (const int, const int, const int)
 Pack the specified RGB color components into integer RGB set.
static QColor rgbSet (const int)
 Unpack the specified integer RGB set to the color.
static void rgbSet (const int, int &, int &, int &)
 Unpack the specified integer RGB set to the three RGB components.
static QColor scaleColor (const int, const int, const int)
 Return the color specified by the index between min (blue) and max (red).
static void scaleColors (const int, QColorList &)
 Generate required number of colors aligned from blue to red.
static QPixmap scaleIcon (const QPixmap &, const unsigned, const unsigned=0)
 Scale the pixmap to the required size.
static QImage grayscale (const QImage &)
 Convert given image to the grayscale format.
static QPixmap grayscale (const QPixmap &)
 Convert given pixmap to the grayscale format.
static QImage transparentImage (const int, const int, const int=-1)
 Create transparent image.
static QPixmap transparentPixmap (const int, const int, const int=-1)
 Create transparent pixmap.
static QPixmap composite (const QPixmap &, const int, const int, const QPixmap &=QPixmap())
 Create composite pixmap.
static QString colorToString (const QColor &)
 Convert color to the string representation.
static bool stringToColor (const QString &, QColor &)
 Create color from the string representation.
static QString gradientToString (const QLinearGradient &)
 Dump linear gradient to the string description.
static QString gradientToString (const QRadialGradient &)
 Dump radial gradient to the string description.
static QString gradientToString (const QConicalGradient &)
 Dump conical gradient to the string description.
static bool stringToLinearGradient (const QString &, QLinearGradient &)
 Create linear gradient from its string representation.
static bool stringToRadialGradient (const QString &, QRadialGradient &)
 Create radial gradient from its string representation.
static bool stringToConicalGradient (const QString &, QConicalGradient &)
 Create conical gradient from its string representation.
static void * getDisplay ()
 Open the default X display and returns pointer to it. This method is available on Linux only.
static Qt::HANDLE getVisual ()
 Returns pointer to X visual suitable for 3D rendering. This method is available on Linux only.

Detailed Description

Prodives set of auxiliary static methods


Member Enumeration Documentation

enum Qtx::AlignmentFlags [inherited]
Enumerator:
AlignLeft 

align left side of one widget to the left side of another widget

AlignLeading 

synonim for AlignLeft

AlignRight 

align right side of one widget to the right side of another widget

AlignTrailing 

synonim for AlignRight

AlignHCenter 

align one widget to the center of another widget in horizontal dimension

AlignJustify 

synonym of Qt.AlignJustify

AlignAbsolute 

synonym of Qt.AlignAbsolute

AlignHorizontal_Mask 

synonym of Qt.AlignHorizontal_Mask

AlignTop 

align top side of one widget to the top side of another widget

AlignBottom 

align bottom side of one widget to the bottom side of another widget

AlignVCenter 

align one widget to the center of another widget in vertical dimension

AlignVertical_Mask 

synonym of Qt.AlignVertical_Mask

AlignCenter 

align one widget to the center of another widget in both dimensions

AlignOutLeft 

align right side of one widget to the left side of another widget

AlignOutRight 

align left side of one widget to the right side of another widget

AlignOutTop 

align bottom side of one widget to the top side of another widget

AlignOutBottom 

align top side of one widget to the bottom side of another widget

enum Qtx::PathType [inherited]
Enumerator:
PT_OpenFile 

the file is opened

PT_SaveFile 

the file is saved

PT_Directory 

the directory path is required

anonymous enum [inherited]
Enumerator:
AppropriateRole 

can be used to return true if data is appropriate

enum Qtx::Appropriate [inherited]
Enumerator:
Shown 

column should be always visible

Hidden 

column should be always hidden

Toggled 

it should be possible to show/hide the column with help of popup menu

enum Qtx::SubstMode [inherited]
Enumerator:
Always 

substitute environment variable by it's value if variable exists, and "" otherwise

Never 

keep environment variable as is without any substitution

Auto 

substitute environment variable by it's value if variable exists, and keep it as is otherwise

enum Qtx::VisibilityState [inherited]
Enumerator:
ShownState 

Object is shown in viewer.

HiddenState 

Object is hidden in viewer.

UnpresentableState 

Unpresentable object.

enum Qtx::HeaderViewFlags [inherited]
Enumerator:
ShowText 

Show only text in the header.

ShowIcon 

Show only icon in the header.

ShowAll 

Show icon and text in the header.

enum Qtx::CustomDataType [inherited]
Enumerator:
IdType 

Member Function Documentation

void SUIT_Tools::trace ( const char *  lpszLog,
const char *  lpszFormat,
  ... 
) [static]

Traces output to log-file. If log is NULL, 'Salome_trace' file is created in temp directory. Log file is written in 'append' mode.

References Qtx.tmpDir().

QRect SUIT_Tools::makeRect ( const int  x1,
const int  y1,
const int  x2,
const int  y2 
) [static]

Creates a rect with TopLeft = ( min(x1,x2), min(y1,y2) ) and BottomRight = ( TopLeft + (x2-x1)(y2-y1) )

QString SUIT_Tools::fontToString ( const QFont &  font) [static]

Creates font's string description

QFont SUIT_Tools::stringToFont ( const QString &  fontDescription) [static]

Creates font from string description

void SUIT_Tools::centerWidget ( QWidget src,
const QWidget ref 
) [static]

Center widget 'src' relative to widget 'ref'.

References Qtx.alignWidget().

QString Qtx::toQString ( const char *  str,
const int  len = -1 
) [static, inherited]
Parameters:
strcharacter array
lenarray length, if < 0, the array should be zero-terminated
Returns:
QString object
QString Qtx::toQString ( const short *  str,
const int  len = -1 
) [static, inherited]
Parameters:
strinteger array
lenarray length, if < 0, the array should be zero-terminated
Returns:
QString object

References Qtx.toQString().

QString Qtx::toQString ( const unsigned char *  str,
const int  len = -1 
) [static, inherited]
Parameters:
strcharacter array
lenarray length, if < 0, the array should be zero-terminated
Returns:
QString object
QString Qtx::toQString ( const unsigned short *  str,
const int  len = -1 
) [static, inherited]
Parameters:
strinteger array
lenarray length, if < 0, the array should be zero-terminated
Returns:
QString object
void Qtx::setTabOrder ( QWidget first,
  ... 
) [static, inherited]

The function has arbitrary number of parameters, each should be hovewer of QWidget* type. Last parameter should be null pointer.

Parameters:
firstfirst widget in the sequence
void Qtx::setTabOrder ( const QWidgetList &  widgets) [static, inherited]
Parameters:
widgetslist of widgets

References Qtx.setTabOrder().

void Qtx::alignWidget ( QWidget src,
const QWidget ref,
const int  alignFlags 
) [static, inherited]
Parameters:
srcsource widget (being aligned)
refreference widget (source widget being aligned to)
alignFlagsalignment flags (Qtx.AlignmentFlags)

References Qtx.AlignBottom, Qtx.AlignHCenter, Qtx.AlignLeft, Qtx.AlignOutBottom, Qtx.AlignOutLeft, Qtx.AlignOutRight, Qtx.AlignOutTop, Qtx.AlignRight, Qtx.AlignTop, and Qtx.AlignVCenter.

void Qtx::simplifySeparators ( QWidget wid,
const bool  recursive = true 
) [static, inherited]
Parameters:
widwidget, should be of QMenu* or QToolBar* class
bool Qtx::isParent ( QObject child,
QObject parent 
) [static, inherited]

This function works recursively. It means that true is also returned if parent is a grand-father, grand-grand-father, etc of child. If the same object is given as both parent and child, true is also returned.

Parameters:
childchild object
parentparent object
Returns:
true if the parent is a parent of child

References PyInterp.obj.

QObject * Qtx::findParent ( QObject obj,
const char *  className 
) [static, inherited]
Parameters:
objcurrent object
classNameclass name of the parent
Returns:
parent object or null pointer if the parent not found
QString Qtx::dir ( const QString &  path,
const bool  abs = true 
) [static, inherited]

If the file path does not include directory part (the file is in the current directory), null string is returned.

Parameters:
pathfile path
absif true (default) path parameter is treated as absolute file path
Returns:
directory part of the file path
QString Qtx::file ( const QString &  path,
const bool  withExt = true 
) [static, inherited]
Parameters:
pathfile path
withExtif true (default) complete file name (with all extension except the last) is returned, otherwise only base name is returned
Returns:
file name part of the file path
QString Qtx::extension ( const QString &  path,
const bool  full = false 
) [static, inherited]
Parameters:
pathfile path
fullif true complete extension (all extensions, dot separated) is returned, otherwise (default) only last extension is returned
Returns:
extension part of the file path
QString Qtx::library ( const QString &  str) [static, inherited]

The function appends platform-specific prefix (lib) and suffix (.dll/.so) to the library file name. For example, if str = "mylib", "libmylib.so" is returned for Linux and mylib.dll for Windows.

Parameters:
strshort library name
Returns:
full library name

References Qtx.addSlash(), Qtx.dir(), Qtx.extension(), and Qtx.file().

QString Qtx::tmpDir ( ) [static, inherited]
Returns:
temporary directory (platform specific)
bool Qtx::mkDir ( const QString &  dirPath) [static, inherited]
Returns:
true if the directory is successfully created and false otherwise
bool Qtx::rmDir ( const QString &  thePath) [static, inherited]
Returns:
true if the directory is successfully removed and false otherwise
bool Qtx::dos2unix ( const QString &  absName) [static, inherited]

The function replaces "LF/CR" symbols sequence by "LF" symbol.

Parameters:
absNamefile name
Returns:
true if the file is converted successfully and false in case of any error

References Qtx.dir().

QString Qtx::addSlash ( const QString &  path) [static, inherited]
Parameters:
pathdirectory path
Returns:
modified path (with slash added to the end)
QCompleter * Qtx::pathCompleter ( const PathType  type,
const QString &  filter = QString() 
) [static, inherited]

Create an instance of QCompleter class and returns the pointer on it. The calling function is responsible to the desstroying of the created completer object.

The QCompleter class provides completions based on a item model and can be used in such as QLineEdit and QComboBox. When the user starts typing a word, QCompleter suggests possible ways of completing the word, based on a word list.

Parameters:
typepath type (Qtx.PathType)
filterfile/directory filters (list of wildcards, separated by ";;")
Returns:
a pointer to the created completer

References Qtx.PT_Directory, Qtx.PT_OpenFile, Qtx.PT_SaveFile, and rx.

QString Qtx::findEnvVar ( const QString &  str,
int &  start,
int &  len 
) [static, inherited]

Looks through the string for the patterns: ${name} or or name%. If string contains variable satisfying any pattern, the variable name is returned, start index of the variable is returned in the start parameter, and length of the variable is returned in the len parameter.

Parameters:
strstring being processed
startif variable is found, this parameter contains its starting position in the str
lenif variable is found, this parameter contains its length
Returns:
first found variable or null QString if there is no ones

References rx.

QString Qtx::makeEnvVarSubst ( const QString &  str,
const SubstMode  mode = Auto 
) [static, inherited]

Environment variable is substituted by its value.

Parameters:
strstring to be processed
Returns:
processed string (with all substitutions made)

References Qtx.Always, Qtx.findEnvVar(), and Qtx.Never.

int Qtx::rgbSet ( const QColor &  c) [static, inherited]
Parameters:
cunpacked color
Returns:
packed color
int Qtx::rgbSet ( const int  r,
const int  g,
const int  b 
) [static, inherited]
Parameters:
rred component
ggreen component
bblue component
Returns:
packed color
QColor Qtx::rgbSet ( const int  rgb) [static, inherited]
Parameters:
rgbpacked color
Returns:
unpacked color (QColor)

References Qtx.rgbSet().

void Qtx::rgbSet ( const int  rgb,
int &  r,
int &  g,
int &  b 
) [static, inherited]
Parameters:
rgbpacked color
rreturned unpacked red component
greturned unpacked green component
breturned unpacked blue component
QColor Qtx::scaleColor ( const int  index,
const int  min,
const int  max 
) [static, inherited]
Parameters:
indexcolor index
minrequired minimum hue value
maxrequired maximum hue value
Returns:
resulting color
void Qtx::scaleColors ( const int  num,
QColorList lst 
) [static, inherited]
Parameters:
numrequired number of colors
lstreturned set of colors

References Qtx.scaleColor().

QPixmap Qtx::scaleIcon ( const QPixmap &  icon,
const unsigned  w,
const unsigned  h = 0 
) [static, inherited]

If h is 0 (default) the value of w is used instead (to create square pixmap).

Parameters:
iconpixmap to be resized
wrequired pixmap width
hrequired pixmap height
Returns:
scaled pixmap
QImage Qtx::grayscale ( const QImage &  img) [static, inherited]
Parameters:
imginitial image
Returns:
converted to the grayscale image
QPixmap Qtx::grayscale ( const QPixmap &  pix) [static, inherited]
Parameters:
pixinitial pixmap
Returns:
converted to the grayscale pixmap

References Qtx.grayscale().

QImage Qtx::transparentImage ( const int  w,
const int  h,
const int  d = -1 
) [static, inherited]
Parameters:
wrequired image width
hrequired image height
drequired image depth
Returns:
generated image
QPixmap Qtx::transparentPixmap ( const int  w,
const int  h,
const int  d = -1 
) [static, inherited]
Parameters:
wrequired image width
hrequired pixmap height
drequired pixmap depth
Returns:
generated pixmap

References Qtx.transparentImage().

QPixmap Qtx::composite ( const QPixmap &  pix,
const int  x,
const int  y,
const QPixmap &  dest = QPixmap() 
) [static, inherited]

Pixmap pix is drawn over pixmap dest with coordinates specified relatively to the upper left corner of dest. If dest is not given, the new empty pixmap with appropriate size created instead.

Parameters:
pixsource pixmap
xhorizontal shift
yvertical shift
destbackground pixmap
Returns:
resulting pixmap

References test_table.c, and Qtx.transparentImage().

QString Qtx::colorToString ( const QColor &  color) [static, inherited]

The resulting string is in the one of two possible formats (RR, GG, BB and AA value represent red, green, blue and alpha components of the color):

  • if color has alpha channel : "#RR,#GG,#BB,#AA"
  • if color does not have alpha channel : "#RRGGBB"

If color is invalid, null string is returned.

Backward conversion can be done with stringToColor() method.

Parameters:
colorcolor to be converted
Returns:
string representation of the color
See also:
stringToColor()
bool Qtx::stringToColor ( const QString &  str,
QColor &  color 
) [static, inherited]

The parameter str must be in the one of following formats (RR, GG, BB and AA value represent red, green, blue and alpha components of the color):

  • "#RR,#GG,#BB[,#AA]" or "#RR #GG #BB[ #AA]" (RR, GG, BB and optional AA values represent red, green, blue and alpha components of the color in hexadecimal form)
  • "RR,GG,BB[,AA]" or "RR GG BB[ AA]" (RR, GG, BB and optional AA values represent red, green, blue and alpha components of the color in decimal form)
  • "#RRGGBB" - (RR, GG and BB values represent red, green and blue components of the color in hexadecimal form)
  • an integer value representing packed color components (see rgbSet())
  • a name from the list of colors defined in the list of SVG color keyword names provided by the World Wide Web Consortium; for example, "steelblue" or "gainsboro".

Backward conversion can be done with colorToString() method.

Parameters:
strstring representation of the color
colorresulting color value
Returns:
true if the conversion is successful and false otherwise
See also:
colorToString(), rgbSet()

References Qtx.rgbSet().

QString Qtx::gradientToString ( const QLinearGradient &  gradient) [static, inherited]
Parameters:
gradientlinear gradient to be converted
Returns:
string representation of the linear gradient
See also:
stringToLinearGradient()

References Qtx.colorToString().

QString Qtx::gradientToString ( const QRadialGradient &  gradient) [static, inherited]
Parameters:
gradientradial gradient to be converted
Returns:
string representation of the radial gradient
See also:
stringToRadialGradient()

References Qtx.colorToString().

QString Qtx::gradientToString ( const QConicalGradient &  gradient) [static, inherited]
Parameters:
gradientconical gradient to be converted
Returns:
string representation of the conical gradient
See also:
stringToConicalGradient()

References Qtx.colorToString().

bool Qtx::stringToLinearGradient ( const QString &  str,
QLinearGradient &  gradient 
) [static, inherited]
Parameters:
strstring representation of the linear gradient
gradientresulting linear gradient object
Returns:
true if the conversion is successful and false otherwise
See also:
gradientToString()

References test_table.c, and Qtx.stringToColor().

bool Qtx::stringToRadialGradient ( const QString &  str,
QRadialGradient &  gradient 
) [static, inherited]
Parameters:
strstring representation of the radial gradient
gradientresulting radial gradient object
Returns:
true if the conversion is successful and false otherwise
See also:
gradientToString()

References test_table.c, and Qtx.stringToColor().

bool Qtx::stringToConicalGradient ( const QString &  str,
QConicalGradient &  gradient 
) [static, inherited]
Parameters:
strstring representation of the conical gradient
gradientresulting conical gradient object
Returns:
true if the conversion is successful and false otherwise
See also:
gradientToString()

References test_table.a, test_table.c, and Qtx.stringToColor().

void * Qtx::getDisplay ( ) [static, inherited]
Returns:
Pointer to X display.
See also:
getVisual()
Qt::HANDLE Qtx::getVisual ( ) [static, inherited]
Returns:
Pointer to X visual.
See also:
getDisplay()

References Qtx.getDisplay(), hex(), and Plot2d.None.

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS