1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0031827: Samples - Qt OCCT Overview sample is not compiled with VS 2010

* Menu storage changed from json to XML (because Qt 4 does not support json)
 * C++11 for(object : container) construction changed to OCCT iterators / Qt foreach
 * enum type::name changed to type_name
 * non used class members removed
 * Qt connect functions changed to macros version
 * warning 4127 disabled for Q_INIT_RESOURCE in VS2010 / Qt 4 case
 * widgets parent problem on Qt 4 fixed
 * QRegularExpression changed to QRegExp
This commit is contained in:
asuraven
2020-10-15 18:23:10 +03:00
committed by bugmaster
parent 1877dc98c9
commit 8833fd4dc5
34 changed files with 736 additions and 1190 deletions

View File

@@ -28,9 +28,6 @@
#include <QFont>
#include <QFrame>
#include <QGroupBox>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMap>
#include <QMdiArea>
#include <QMdiSubWindow>
@@ -43,6 +40,8 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QWidget>
#include <QDomDocument>
#include <QDomAttr>
#include <Standard_WarningsRestore.hxx>
#include <OpenGl_GraphicDriver.hxx>
@@ -53,13 +52,21 @@
ApplicationCommonWindow::ApplicationCommonWindow (ApplicationType theCategory)
: QMainWindow (nullptr),
myAppType(theCategory),
myStdToolBar (nullptr),
myViewBar (nullptr),
myCasCadeBar (nullptr),
myFilePopup (nullptr),
myCategoryPopup (nullptr)
{
myAppType = theCategory;
ALL_CATEGORIES[AppType_Geometry] = "Geometry";
ALL_CATEGORIES[AppType_Topology] = "Topology";
ALL_CATEGORIES[AppType_Triangulation] = "Triangulation";
ALL_CATEGORIES[AppType_DataExchange] = "DataExchange";
ALL_CATEGORIES[AppType_Ocaf] = "OCAF";
ALL_CATEGORIES[AppType_Viewer3d] = "3D viewer";
ALL_CATEGORIES[AppType_Viewer2d] = "2D Viewer";
mySampleMapper = new QSignalMapper(this);
myExchangeMapper = new QSignalMapper(this);
myOcafMapper = new QSignalMapper(this);
@@ -68,19 +75,13 @@ ApplicationCommonWindow::ApplicationCommonWindow (ApplicationType theCategory)
myCategoryMapper = new QSignalMapper(this);
connect(mySampleMapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped),
this, &ApplicationCommonWindow::onProcessSample);
connect(myExchangeMapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped),
this, &ApplicationCommonWindow::onProcessExchange);
connect(myOcafMapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped),
this, &ApplicationCommonWindow::onProcessOcaf);
connect(myViewer3dMapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped),
this, &ApplicationCommonWindow::onProcessViewer3d);
connect(myViewer2dMapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped),
this, &ApplicationCommonWindow::onProcessViewer2d);
connect(mySampleMapper, SIGNAL(mapped(const QString &)), this, SLOT(onProcessSample(const QString &)));
connect(myExchangeMapper, SIGNAL(mapped(const QString &)), this, SLOT(onProcessExchange(const QString &)));
connect(myOcafMapper, SIGNAL(mapped(const QString &)), this, SLOT(onProcessOcaf(const QString &)));
connect(myViewer3dMapper, SIGNAL(mapped(const QString &)), this, SLOT(onProcessViewer3d(const QString &)));
connect(myViewer2dMapper, SIGNAL(mapped(const QString &)), this, SLOT(onProcessViewer2d(const QString &)));
connect(myCategoryMapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped),
this, &ApplicationCommonWindow::onChangeCategory);
connect(myCategoryMapper, SIGNAL(mapped(const QString &)), this, SLOT(onChangeCategory(const QString &)));
setFocusPolicy(Qt::StrongFocus);
@@ -121,20 +122,25 @@ ApplicationCommonWindow::ApplicationCommonWindow (ApplicationType theCategory)
aViewFrame->setLineWidth(3);
QVBoxLayout* aViewLayout = new QVBoxLayout(aViewFrame);
aViewLayout->setContentsMargins(0, 0, 0, 0);
myGeomWidget = new GeomWidget(myDocument3d, myDocument2d, this);
myGeomWidget = new GeomWidget(myDocument3d, myDocument2d, aViewFrame);
aViewLayout->addWidget(myGeomWidget);
//myGeomWidget->setContentsMargins(0, 0, 0, 0);
myGeomWidget->setContentsMargins(0, 0, 0, 0);
QSplitter* aGeomTextSplitter = new QSplitter(Qt::Horizontal);
aGeomTextSplitter->addWidget(aViewFrame);
aGeomTextSplitter->addWidget(aCodeResultSplitter);
aGeomTextSplitter->setStretchFactor(0, 1);
aGeomTextSplitter->setStretchFactor(1, 1);
QList<int> aSizeList{ 640, 640 };
QList<int> aSizeList;
aSizeList.append(640);
aSizeList.append(640);
aGeomTextSplitter->setSizes(aSizeList);
setCentralWidget(aGeomTextSplitter);
#include <Standard_WarningsDisable.hxx>
Q_INIT_RESOURCE(Samples);
#include <Standard_WarningsRestore.hxx>
TCollection_AsciiString aSampleSourcePach = getSampleSourceDir();
myGeometrySamples = new GeometrySamples(aSampleSourcePach,
@@ -157,13 +163,14 @@ ApplicationCommonWindow::ApplicationCommonWindow (ApplicationType theCategory)
myDocument2d->getViewer(),
myDocument2d->getContext());
MenuFormJson(":/menus/Geometry.json", mySampleMapper, myGeometryMenus);
MenuFormJson(":/menus/Topology.json", mySampleMapper, myTopologyMenus);
MenuFormJson(":/menus/Triangulation.json", mySampleMapper, myTriangulationMenus);
MenuFormJson(":/menus/DataExchange.json", myExchangeMapper, myDataExchangeMenus);
MenuFormJson(":/menus/Ocaf.json", myOcafMapper, myOcafMenus);
MenuFormJson(":/menus/Viewer3d.json", myViewer3dMapper, myViewer3dMenus);
MenuFormJson(":/menus/Viewer2d.json", myViewer2dMapper, myViewer2dMenus);
MenuFormXml(":/menus/Geometry.xml", mySampleMapper, myGeometryMenus);
MenuFormXml(":/menus/Topology.xml", mySampleMapper, myTopologyMenus);
MenuFormXml(":/menus/Triangulation.xml", mySampleMapper, myTriangulationMenus);
MenuFormXml(":/menus/DataExchange.xml", myExchangeMapper, myDataExchangeMenus);
MenuFormXml(":/menus/Ocaf.xml", myOcafMapper, myOcafMenus);
MenuFormXml(":/menus/Viewer3d.xml", myViewer3dMapper, myViewer3dMenus);
MenuFormXml(":/menus/Viewer2d.xml", myViewer2dMapper, myViewer2dMenus);
onChangeCategory(ALL_CATEGORIES[myAppType]);
@@ -174,29 +181,31 @@ void ApplicationCommonWindow::RebuildMenu()
{
menuBar()->clear();
myStdActions[FileQuit] = CreateAction(&ApplicationCommonWindow::onCloseAllWindows, "Quit", "CTRL+Q");
myStdActions[HelpAbout] = CreateAction(&ApplicationCommonWindow::onAbout, "About", "F1", ":/icons/help.png");
myStdActions[StdActions_FileQuit] = CreateAction("Quit", "CTRL+Q");
connect(myStdActions[StdActions_FileQuit], SIGNAL(triggered()), this, SLOT(onCloseAllWindows()));
myStdActions[StdActions_HelpAbout] = CreateAction("About", "F1", ":/icons/help.png");
connect(myStdActions[StdActions_HelpAbout], SIGNAL(triggered()), this, SLOT(onAbout()));
// populate a menu with all actions
myFilePopup = new QMenu(this);
myFilePopup = menuBar()->addMenu(tr("&File"));
myFilePopup->addAction(myStdActions[FileQuit]);
myFilePopup->addAction(myStdActions[StdActions_FileQuit]);
myCategoryPopup = new QMenu(this);
myCategoryPopup = menuBar()->addMenu(tr("&Category"));
for (ApplicationType aCategory: ALL_CATEGORIES.keys())
foreach (ApplicationType aCategory, ALL_CATEGORIES.keys())
{
QString aCategoryName = ALL_CATEGORIES.value(aCategory);
QAction* anAction = myCategoryPopup->addAction(aCategoryName);
anAction->setText(aCategoryName);
myCategoryMapper->setMapping(anAction, aCategoryName);
connect(anAction, &QAction::triggered, myCategoryMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
connect(anAction, SIGNAL(triggered()), myCategoryMapper, SLOT(map()));
myCategoryPopup->addAction(anAction);
myCategoryActions.insert(aCategory, anAction);
}
for (QMenu* aSampleMenu : GetCurrentMenus())
foreach (QMenu* aSampleMenu, GetCurrentMenus())
{
menuBar()->addMenu(aSampleMenu);
}
@@ -205,21 +214,21 @@ void ApplicationCommonWindow::RebuildMenu()
QMenu* aHelp = new QMenu(this);
menuBar()->addSeparator();
aHelp = menuBar()->addMenu(tr("&Help"));
aHelp->addAction(myStdActions[HelpAbout]);
aHelp->addAction(myStdActions[StdActions_HelpAbout]);
}
Handle(BaseSample) ApplicationCommonWindow::GetCurrentSamples()
{
switch (myAppType)
{
case Geometry: return myGeometrySamples;
case Topology: return myTopologySamples;
case Triangulation: return myTriangulationSamples;
case DataExchange: return myDataExchangeSamples;
case Ocaf: return myOcafSamples;
case Viewer2d: return myViewer2dSamples;
case Viewer3d: return myViewer3dSamples;
case Unknown:
case AppType_Geometry: return myGeometrySamples;
case AppType_Topology: return myTopologySamples;
case AppType_Triangulation: return myTriangulationSamples;
case AppType_DataExchange: return myDataExchangeSamples;
case AppType_Ocaf: return myOcafSamples;
case AppType_Viewer2d: return myViewer2dSamples;
case AppType_Viewer3d: return myViewer3dSamples;
case AppType_Unknown:
break;
}
throw QString("Unknown Application type");
@@ -229,14 +238,14 @@ const QList<QMenu*>& ApplicationCommonWindow::GetCurrentMenus()
{
switch (myAppType)
{
case Geometry: return myGeometryMenus;
case Topology: return myTopologyMenus;
case Triangulation: return myTriangulationMenus;
case DataExchange: return myDataExchangeMenus;
case Ocaf: return myOcafMenus;
case Viewer2d: return myViewer2dMenus;
case Viewer3d: return myViewer3dMenus;
case Unknown:
case AppType_Geometry: return myGeometryMenus;
case AppType_Topology: return myTopologyMenus;
case AppType_Triangulation: return myTriangulationMenus;
case AppType_DataExchange: return myDataExchangeMenus;
case AppType_Ocaf: return myOcafMenus;
case AppType_Viewer2d: return myViewer2dMenus;
case AppType_Viewer3d: return myViewer3dMenus;
case AppType_Unknown:
break;
}
throw QString("Unknown Application type");
@@ -270,35 +279,35 @@ void ApplicationCommonWindow::onChangeCategory(const QString& theCategory)
switch (myAppType)
{
case DataExchange:
case AppType_DataExchange:
{
myDataExchangeSamples->AppendBottle();
myDocument3d->SetObjects(GetCurrentSamples()->Get3dObjects());
myGeomWidget->Show3d();
break;
}
case Ocaf:
case AppType_Ocaf:
{
onProcessOcaf("CreateOcafDocument");
myGeomWidget->Show3d();
break;
}
case Viewer2d:
case AppType_Viewer2d:
{
myGeomWidget->Show2d();
break;
}
case Viewer3d:
case AppType_Viewer3d:
{
myViewer3dSamples->AppendBottle();
myDocument3d->SetObjects(GetCurrentSamples()->Get3dObjects());
myGeomWidget->Show3d();
break;
}
case Geometry:
case Topology:
case Triangulation:
case Unknown:
case AppType_Geometry:
case AppType_Topology:
case AppType_Triangulation:
case AppType_Unknown:
{
break;
}
@@ -326,9 +335,7 @@ TCollection_AsciiString ApplicationCommonWindow::getSampleSourceDir()
return aSampleSourceDir;
}
template <typename PointerToMemberFunction>
QAction* ApplicationCommonWindow::CreateAction (PointerToMemberFunction theHandlerMethod,
const QString& theActionName,
QAction* ApplicationCommonWindow::CreateAction (const QString& theActionName,
const QString& theShortcut,
const QString& theIconName)
{
@@ -345,7 +352,7 @@ QAction* ApplicationCommonWindow::CreateAction (PointerToMemberFunction theHandl
aAction->setToolTip(theActionName);
aAction->setStatusTip(theActionName);
aAction->setShortcut(theShortcut);
connect(aAction, &QAction::triggered, this, theHandlerMethod);
return aAction;
}
@@ -353,9 +360,9 @@ template <typename PointerToMemberFunction>
QAction* ApplicationCommonWindow::CreateSample (PointerToMemberFunction theHandlerMethod,
const char* theActionName)
{
QAction* aAction = new QAction(QObject::tr(theActionName), this);
connect(aAction, &QAction::triggered, this, theHandlerMethod);
return aAction;
QAction* anAction = new QAction(QObject::tr(theActionName), this);
connect(anAction, SIGNAL(triggered()), this, SLOT(theHandlerMethod()));
return anAction;
}
void ApplicationCommonWindow::resizeEvent(QResizeEvent* e)
@@ -608,78 +615,78 @@ TranslateDialog* ApplicationCommonWindow::getOcafDialog(const QString& theSample
return aTranslateDialog;
}
QMenu* ApplicationCommonWindow::MenuFromJsonObject (const QJsonValue& theJsonValue,
const QString& theKey,
QWidget* theParent,
QSignalMapper* theMapper)
QMenu* ApplicationCommonWindow::MenuFromDomNode(QDomElement& theItemElement,
QWidget* theParent,
QSignalMapper* theMapper)
{
QMenu* aMenu = new QMenu(theKey, theParent);
if (theJsonValue.isObject())
{
QJsonObject aBranchObject = theJsonValue.toObject();
for (const QString& aBranchKey : aBranchObject.keys())
{
aMenu->addMenu(MenuFromJsonObject(aBranchObject.value(aBranchKey), aBranchKey, aMenu, theMapper));
}
}
else if (theJsonValue.isArray())
{
QJsonArray aDataArray = theJsonValue.toArray();
for (const QJsonValue& aDataValue : aDataArray)
{
if (aDataValue.isObject())
{
QJsonObject aDataObject = aDataValue.toObject();
QString aSampleName = aDataObject["function"].toString();
QAction* anAction = aMenu->addAction(aSampleName);
anAction->setText(aDataObject["text"].toString());
QString anItemName = theItemElement.attribute("name");
QMenu* aMenu = new QMenu(anItemName, theParent);
QDomElement anChildItemElement = theItemElement.firstChildElement("MenuItem");
QDomElement anSampleElement = theItemElement.firstChildElement("Sample");
theMapper->setMapping(anAction, aSampleName);
connect(anAction, &QAction::triggered, theMapper,
static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
}
}
while(anChildItemElement.isElement())
{
aMenu->addMenu(MenuFromDomNode(anChildItemElement, aMenu, theMapper));
anChildItemElement = anChildItemElement.nextSibling().toElement();
}
while(anSampleElement.isElement())
{
QString aSampleName = anSampleElement.attribute("name");
QString aSampleFunction = anSampleElement.attribute("function");
QAction* anAction = aMenu->addAction(aSampleFunction);
anAction->setText(aSampleName);
theMapper->setMapping(anAction, aSampleFunction);
connect(anAction, SIGNAL(triggered()), theMapper, SLOT(map()));
anSampleElement = anSampleElement.nextSibling().toElement();
}
return aMenu;
}
void ApplicationCommonWindow::MenuFormJson (const QString& thePath,
QSignalMapper* theMapper,
QList<QMenu*>& theMunusList)
void ApplicationCommonWindow::MenuFormXml(const QString& thePath,
QSignalMapper* theMapper,
QList<QMenu*>& theMunusList)
{
QDomDocument aDomDocument;
theMunusList.clear();
QFile aJsonFile(thePath);
QFile aXmlFile(thePath);
QString anErrorMessage;
if (aJsonFile.error() != QFile::NoError)
if (aXmlFile.error() != QFile::NoError)
{
anErrorMessage = aJsonFile.errorString();
anErrorMessage = aXmlFile.errorString();
Message::SendFail() << "QFile creating error: " << anErrorMessage.toUtf8().constData();
aXmlFile.close();
return;
}
if (!aJsonFile.open(QIODevice::ReadOnly | QIODevice::Text))
if (!aXmlFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
Message::SendFail() << "File " << thePath.toUtf8().constData() << " could not open";
if (aJsonFile.error() != QFile::NoError)
if (aXmlFile.error() != QFile::NoError)
{
anErrorMessage = aJsonFile.errorString();
anErrorMessage = aXmlFile.errorString();
Message::SendFail() << "QFile opening error: " << anErrorMessage.toUtf8().constData();
}
aXmlFile.close();
return;
}
QString aJsonString = aJsonFile.readAll();
aJsonFile.close();
QJsonDocument aJsonDoc = QJsonDocument::fromJson(aJsonString.toUtf8());
if (aJsonDoc.isObject())
bool aNamespaceProcessing(false);
QString anErrorMsg;
int anErrorLine(0);
int anErrorColumn(0);
if (!aDomDocument.setContent(&aXmlFile, aNamespaceProcessing, &anErrorMsg, &anErrorLine, &anErrorColumn))
{
QJsonObject aJsonObj = aJsonDoc.object();
for (const QString& aKey : aJsonObj.keys())
{
QJsonValue aJsonValue = aJsonObj.value(aKey);
if (aJsonValue.isObject())
{
theMunusList.push_back(MenuFromJsonObject(aJsonValue.toObject(), aKey, this, theMapper));
}
}
Message::SendFail() << "XML file parsing error: " << anErrorMsg.toStdString()
<< " at line: " << anErrorLine << " column: " << anErrorColumn;
aXmlFile.close();
return;
}
aXmlFile.close();
QDomElement aRootElement = aDomDocument.documentElement();
QDomElement anItemElement = aRootElement.firstChildElement("MenuItem");
while(!anItemElement.isNull())
{
theMunusList.push_back(MenuFromDomNode(anItemElement, this, theMapper));
anItemElement = anItemElement.nextSiblingElement("MenuItem");
}
}

View File

@@ -40,6 +40,7 @@
#include <Standard_WarningsDisable.hxx>
#include <QApplication>
#include <QAction>
#include <QDomNode>
#include <QList>
#include <QMainWindow>
#include <QMdiArea>
@@ -52,36 +53,22 @@
enum StdActions
{
FileNew, FilePrefUseVBO, FileClose, FilePreferences, FileQuit, ViewTool, ViewStatus, HelpAbout
};
enum ToolActions
{
ToolWireframe, ToolShading, ToolColor, ToolMaterial, ToolTransparency, ToolDelete
StdActions_FileQuit,
StdActions_HelpAbout
};
enum ApplicationType
{
Geometry,
Topology,
Triangulation,
DataExchange,
Ocaf,
Viewer2d,
Viewer3d,
Unknown
AppType_Geometry,
AppType_Topology,
AppType_Triangulation,
AppType_DataExchange,
AppType_Ocaf,
AppType_Viewer2d,
AppType_Viewer3d,
AppType_Unknown
};
const QMap<ApplicationType, QString> ALL_CATEGORIES =
{
{ ApplicationType::Geometry,"Geometry"},
{ ApplicationType::Topology, "Topology"},
{ ApplicationType::Triangulation, "Triangulation"},
{ ApplicationType::DataExchange, "DataExchange"},
{ ApplicationType::Ocaf, "OCAF"},
{ ApplicationType::Viewer3d, "3D viewer"},
{ ApplicationType::Viewer2d, "2D Viewer"}
};
//! Main application window
class COMMONSAMPLE_EXPORT ApplicationCommonWindow: public QMainWindow
@@ -104,9 +91,7 @@ public slots:
virtual void onChangeCategory(const QString& theCategory);
protected:
template <typename PointerToMemberFunction>
QAction* CreateAction(PointerToMemberFunction theHandlerMethod,
const QString& theActionName,
QAction* CreateAction(const QString& theActionName,
const QString& theShortcut = "",
const QString& theIconName = "");
@@ -118,13 +103,13 @@ protected:
QMenu* getFilePopup() { return myFilePopup; }
QToolBar* getCasCadeBar() { return myCasCadeBar; }
QMenu* MenuFromJsonObject (const QJsonValue& theJsonValue,
const QString& theKey,
QWidget* theParent,
QSignalMapper* theMapper);
void MenuFormJson (const QString& thePath,
void MenuFormXml (const QString& thePath,
QSignalMapper* theMapper,
QList<QMenu*>& theMunusList);
QMenu* MenuFromDomNode(QDomElement& theItemElement,
QWidget* theParent,
QSignalMapper* theMapper);
private slots:
void onCloseAllWindows() { qApp->closeAllWindows(); }
@@ -147,6 +132,7 @@ private:
private:
ApplicationType myAppType;
QMap<ApplicationType, QString> ALL_CATEGORIES;
Handle(GeometrySamples) myGeometrySamples;
Handle(TopologySamples) myTopologySamples;
@@ -158,7 +144,6 @@ private:
QMap<StdActions, QAction*> myStdActions;
QMap<ApplicationType, QAction*> myCategoryActions;
QMap<ToolActions, QAction*> myToolActions;
QMap<Graphic3d_NameOfMaterial, QAction*> myMaterialActions;
QToolBar* myStdToolBar;
@@ -167,7 +152,6 @@ private:
QMenu* myFilePopup;
QMenu* myCategoryPopup;
// QList<QMenu*> mySamplePopups;
QList<QMenu*> myGeometryMenus;
QList<QMenu*> myTopologyMenus;
QList<QMenu*> myTriangulationMenus;

View File

@@ -87,8 +87,11 @@ void DocumentCommon::SetObjects (const NCollection_Vector<Handle(AIS_Interactive
{
myContext->RemoveAll(Standard_False);
myContextIsEmpty = theObjects.IsEmpty();
for (const Handle(AIS_InteractiveObject) anObject : theObjects)
for(NCollection_Vector<Handle(AIS_InteractiveObject)>::Iterator anIter(theObjects);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anObject = anIter.Value();
if (!theDisplayShaded)
{
myContext->Display(anObject, Standard_False);

View File

@@ -44,7 +44,7 @@ GeomWidget::GeomWidget (DocumentCommon* theDocument3d,
QVBoxLayout* a2dLayout = new QVBoxLayout(my2dVidget);
a2dLayout->setContentsMargins(0, 0, 0, 0);
a2dLayout->setSpacing(0);
myView2d = new View(myDocument2d->getContext(), false, this);
myView2d = new View(myDocument2d->getContext(), false, my2dVidget);
QToolBar* aToolBar2d = new QToolBar;
aToolBar2d->addActions(myView2d->getViewActions());
a2dLayout->addWidget(aToolBar2d);
@@ -54,7 +54,7 @@ GeomWidget::GeomWidget (DocumentCommon* theDocument3d,
QVBoxLayout* a3dLayout = new QVBoxLayout(my3dVidget);
a3dLayout->setContentsMargins(0, 0, 0, 0);
a3dLayout->setSpacing(0);
myView3d = new View(myDocument3d->getContext(), true, this);
myView3d = new View(myDocument3d->getContext(), true, my3dVidget);
QToolBar* aToolBar3d = new QToolBar;
aToolBar3d->addActions(myView3d->getViewActions());
aToolBar3d->addSeparator();
@@ -82,10 +82,10 @@ void GeomWidget::Show3d()
{
myView3d->axo();
myView3d->fitAll();
QAction* aShadingAction = myView3d->getViewAction(ViewAction::Shading);
QAction* aShadingAction = myView3d->getViewAction(ViewAction_Shading);
aShadingAction->trigger();
aShadingAction->setChecked(true);
QAction* aHlrOffAction = myView3d->getViewAction(ViewAction::HlrOff);
QAction* aHlrOffAction = myView3d->getViewAction(ViewAction_HlrOff);
aHlrOffAction->trigger();
aHlrOffAction->setChecked(true);
myStackWidget->setCurrentWidget(my3dVidget);

View File

@@ -25,7 +25,6 @@
#include <Standard_WarningsDisable.hxx>
#include <QApplication>
#include <QCommandLineParser>
#include <QLocale>
#include <QSettings>
#include <QStringList>
@@ -34,10 +33,12 @@
int main ( int argc, char* argv[] )
{
Q_INIT_RESOURCE(OCCTOverview);
QApplication aQApp( argc, argv );
#include <Standard_WarningsDisable.hxx>
Q_INIT_RESOURCE(OCCTOverview);
#include <Standard_WarningsRestore.hxx>
QSettings settings("OCCTOverview.conf", QSettings::IniFormat);
settings.beginGroup("ApplicationSetting");
ApplicationType aCategory = static_cast<ApplicationType>(settings.value("ApplicationType", "").toInt());

View File

@@ -23,152 +23,121 @@
#include <Standard_WarningsDisable.hxx>
#include <QFont>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
static const QString anOcctPatterns[] =
{
QStringLiteral("gp_Pnt"), QStringLiteral("gp_XYZ"), QStringLiteral("gp_Vec"),
QStringLiteral("gp_Dir"), QStringLiteral("gp_Ax1"), QStringLiteral("gp_Ax2"),
QStringLiteral("gp_Ax3"), QStringLiteral("gp_Lin"), QStringLiteral("gp_Circ"),
QStringLiteral("gp_Elips"), QStringLiteral("gp_Parab"), QStringLiteral("gp_Hypr"),
QStringLiteral("gp_Cylinder"), QStringLiteral("gp_Cone"), QStringLiteral("gp_Sphere"),
QStringLiteral("gp_Torus"), QStringLiteral("gp_Pnt2d"), QStringLiteral("gp_XY"),
QStringLiteral("gp_Ax2d"), QStringLiteral("gp_Ax22d"), QStringLiteral("gp_Lin2d"),
QStringLiteral("gp_Circ2d."), QStringLiteral("gp_Elips2d"), QStringLiteral("gp_Parab2d"),
QStringLiteral("gp_Hypr2d"), QStringLiteral("Geom2d_BSplineCurve"), QStringLiteral("Geom2d_BezierCurve"),
QStringLiteral("Geom2d_OffsetCurve"), QStringLiteral("ProjLib"), QStringLiteral("ElSLib"),
QStringLiteral("Extrema_ExtElCS"), QStringLiteral("Extrema_POnCurv"), QStringLiteral("IntAna_Quadric"),
QStringLiteral("IntAna_IntConicQuad"), QStringLiteral("GccAna_Lin2d2Tan"), QStringLiteral("GccEnt_QualifiedCirc"),
QStringLiteral("Geom2dAPI_ProjectPointOnCurve"), QStringLiteral("Geom2dAPI_ExtremaCurveCurve"),
QStringLiteral("Geom2dAPI_InterCurveCurve"), QStringLiteral("Geom2dAPI_PointsToBSpline"),
QStringLiteral("Geom_CartesianPoint"), QStringLiteral("Geom_VectorWithMagnitude"), QStringLiteral("Geom_Axis1Placement"),
QStringLiteral("Geom_Axis2Placement"), QStringLiteral("Geom_Line"), QStringLiteral("Geom_Circle"),
QStringLiteral("Geom_Ellipse"), QStringLiteral("Geom_Parabola"), QStringLiteral("Geom_Hyperbola"),
QStringLiteral("Geom_BSplineCurve"), QStringLiteral("Geom_BezierCurve"), QStringLiteral("Geom_TrimmedCurve"),
QStringLiteral("Geom_OffsetCurve"), QStringLiteral("Geom_BSplineSurface"), QStringLiteral("Geom_BezierSurface"),
QStringLiteral("Geom_Plane"), QStringLiteral("Geom_CylindricalSurface"), QStringLiteral("Geom_ConicalSurface"),
QStringLiteral("Geom_SphericalSurface"), QStringLiteral("Geom_ToroidalSurface"), QStringLiteral("Geom_RectangularTrimmedSurface"),
QStringLiteral("Geom_OffsetSurface"), QStringLiteral("Geom_SurfaceOfLinearExtrusion"), QStringLiteral("Geom_SurfaceOfRevolution"),
QStringLiteral("BndLib_Add3dCurve"), QStringLiteral("BndLib_AddSurface"), QStringLiteral("GeomAdaptor_Curve"),
QStringLiteral("GeomAdaptor_Surface"), QStringLiteral("GeomAPI_PointsToBSpline"), QStringLiteral("GeomAPI_PointsToBSplineSurface"),
QStringLiteral("GeomConvert"), QStringLiteral("Geom2d_CartesianPoint"), QStringLiteral("Geom2d_VectorWithMagnitude"),
QStringLiteral("Geom2d_Line"), QStringLiteral("Geom2d_Circle"), QStringLiteral("Geom2d_Ellipse"),
QStringLiteral("Geom2d_Parabola"), QStringLiteral("Geom2d_Hyperbola"), QStringLiteral("Geom2d_TrimmedCurve"),
QStringLiteral("Geom2dAdaptor_Curve"), QStringLiteral("Bnd_Box2d"), QStringLiteral("BndLib_Add2dCurve"),
QStringLiteral("Adaptor2d_Curve2d"), QStringLiteral("BRepBuilderAPI_MakeEdge"), QStringLiteral("BRepBuilderAPI_MakeFace"),
QStringLiteral("BRepPrimAPI_MakeBox"), QStringLiteral("AIS_Point"), QStringLiteral("AIS_TextLabel"), QStringLiteral("AIS_Axis"),
QStringLiteral("AIS_Circle"), QStringLiteral("AIS_Plane"), QStringLiteral("AIS_Shape"), QStringLiteral("AIS_ColoredShape"),
QStringLiteral("GProp_PEquation"), QStringLiteral("Extrema_ExtCS"), QStringLiteral("GCPnts_QuasiUniformDeflection"),
QStringLiteral("GProp_GProps"), QStringLiteral("GProp_PrincipalProps"), QStringLiteral("TopoDS"),
QStringLiteral("TopoDS_Iterator"), QStringLiteral("TopoDS_Compound"), QStringLiteral("TopoDS_Edge"), QStringLiteral("TopoDS_Face"),
QStringLiteral("TopoDS_Shell"), QStringLiteral("TopoDS_Solid"), QStringLiteral("TopoDS_Vertex"),
QStringLiteral("TopoDS_Wire"), QStringLiteral("TopExp"), QStringLiteral("TopExp_Explorer"),
QStringLiteral("TColgp_Array2OfPnt"), QStringLiteral("BRep_Builder"), QStringLiteral("BRepGProp"), QStringLiteral("BRep_Tool"),
QStringLiteral("BRepTools"), QStringLiteral("BRepTools_ReShape"), QStringLiteral("BRepAdaptor_Curve"),
QStringLiteral("BRepAdaptor_CompCurve"), QStringLiteral("BRepAdaptor_Surface"), QStringLiteral("BRepAlgoAPI_Common"),
QStringLiteral("BRepAlgoAPI_Cut"), QStringLiteral("BRepAlgoAPI_Fuse"), QStringLiteral("BRepAlgoAPI_Section"),
QStringLiteral("BRepAlgoAPI_Splitter"), QStringLiteral("BRepAlgoAPI_Defeaturing"), QStringLiteral("BRepBuilderAPI_Copy"),
QStringLiteral("BRepBuilderAPI_MakeVertex"), QStringLiteral("BRepBuilderAPI_MakeEdge"), QStringLiteral("BRepBuilderAPI_MakeFace"),
QStringLiteral("BRepBuilderAPI_MakePolygon"), QStringLiteral("BRepBuilderAPI_MakeShell"), QStringLiteral("BRepBuilderAPI_MakeSolid"),
QStringLiteral("BRepBuilderAPI_MakeWire"), QStringLiteral("BRepBuilderAPI_NurbsConvert"), QStringLiteral("BRepBuilderAPI_Sewing"),
QStringLiteral("BRepBuilderAPI_Transform"), QStringLiteral("BRepCheck_Analyzer"), QStringLiteral("BRepPrimAPI_MakeBox"),
QStringLiteral("BRepPrimAPI_MakeCylinder"), QStringLiteral("BRepPrimAPI_MakeRevol"), QStringLiteral("BRepFilletAPI_MakeChamfer"),
QStringLiteral("BRepFilletAPI_MakeFillet"), QStringLiteral("BRepOffsetAPI_MakeOffset"), QStringLiteral("BRepOffsetAPI_MakeEvolved.hxx"),
QStringLiteral("Standard_Integer"), QStringLiteral("Standard_Real"), QStringLiteral("Standard_Boolean"), QStringLiteral("Standard_ShortReal"),
QStringLiteral("Standard_Character"), QStringLiteral("Standard_Byte"), QStringLiteral("Standard_Address"), QStringLiteral("Standard_Size"),
QStringLiteral("Standard_Time"), QStringLiteral("Standard_Utf8Char"), QStringLiteral("Standard_Utf8UChar"),
QStringLiteral("Standard_ExtCharacter"), QStringLiteral("Standard_Utf16Char"), QStringLiteral("Standard_Utf32Char"),
QStringLiteral("Standard_WideChar"), QStringLiteral("Standard_CString"), QStringLiteral("Standard_ExtString"),
QStringLiteral("NCollection_Vector"), QStringLiteral("TCollection_AsciiString"), QStringLiteral("TCollection_BaseSequence"),
QStringLiteral("TCollection_BasicMap"), QStringLiteral("TCollection_BasicMapIterator"), QStringLiteral("TCollection_ExtendedString"),
QStringLiteral("TCollection_HAsciiString"), QStringLiteral("TCollection_HExtendedString"), QStringLiteral("TCollection_MapNode"),
QStringLiteral("TCollection_MapNodePtr"), QStringLiteral("TCollection_SeqNode"), QStringLiteral("TCollection_SeqNodePtr"),
QStringLiteral("TCollection_Side"), QStringLiteral("Standard_False"), QStringLiteral("Standard_True"),
QStringLiteral("TCollection"), QStringLiteral("NCollection"), QStringLiteral("gp_Trsf"), QStringLiteral("Handle"),
QStringLiteral("Aspect_TOL_DASH"), QStringLiteral("Aspect_TOM_O_STAR"), QStringLiteral("Aspect_TOL_SOLID"),
QStringLiteral("Aspect_TOM_O_STAR"), QStringLiteral("AIS_InteractiveObject"), QStringLiteral("AIS_ListOfInteractive"),
QStringLiteral("Aspect_GDM_Lines"), QStringLiteral("Aspect_GDM_Points"), QStringLiteral("Aspect_TOM_POINT"),
QStringLiteral("Aspect_TOM_RING1"), QStringLiteral("Aspect_TOM_O"),QStringLiteral("BinDrivers"),
QStringLiteral("DefineFormat"), QStringLiteral("Font_FA_Bold"), QStringLiteral("Font_FA_BoldItalic"),
QStringLiteral("Font_FA_Italic"), QStringLiteral("Font_FA_Regular"), QStringLiteral("DownCast"),
QStringLiteral("gp_Pln"), QStringLiteral("Graphic3d_AspectMarker3d"), QStringLiteral("Graphic3d_HTA_LEFT"),
QStringLiteral("Graphic3d_NameOfMaterial"), QStringLiteral("Graphic3d_NOM_BRONZE"), QStringLiteral("Graphic3d_NOM_PLASTIC"),
QStringLiteral("Graphic3d_VTA_BOTTOM"), QStringLiteral("OpenGl_GraphicDriver"), QStringLiteral("PCDM_RS_OK"),
QStringLiteral("PCDM_SS_OK"), QStringLiteral("PCDM_ReaderStatus"), QStringLiteral("PCDM_StoreStatus"),
QStringLiteral("Prs3d_Drawer"), QStringLiteral("TPrsStd_AISPresentation"), QStringLiteral("Quantity_Color"),
QStringLiteral("Quantity_NameOfColor"), QStringLiteral("Quantity_NOC_BLUE1"), QStringLiteral("Quantity_NOC_CADETBLUE"),
QStringLiteral("Quantity_NOC_GREEN"), QStringLiteral("Quantity_NOC_MAGENTA1"), QStringLiteral("Quantity_NOC_RED"),
QStringLiteral("Quantity_NOC_YELLOW"), QStringLiteral("Quantity_NOC_WHITE"), QStringLiteral("Quantity_NOC_MATRABLUE"),
QStringLiteral("Quantity_TOC_RGB"), QStringLiteral("Quantity_TOC_HLS"), QStringLiteral("Standard_GUID"),
QStringLiteral("TColStd_ListIteratorOfListOfTransient"), QStringLiteral("TColStd_ListOfTransient"), QStringLiteral("TDataStd_Integer"),
QStringLiteral("TDataStd_Name"), QStringLiteral("TDataStd_Real"), QStringLiteral("TFunction_Driver"),
QStringLiteral("TFunction_DriverTable"), QStringLiteral("TFunction_Function"), QStringLiteral("TFunction_Logbook"),
QStringLiteral("TDF_Label"), QStringLiteral("TDF_TagSource"), QStringLiteral("TNaming_NamedShape"),
QStringLiteral("TopAbs_EDGE"), QStringLiteral("TopAbs_FACE"), QStringLiteral("TopAbs_VERTEX"),
QStringLiteral("TPrsStd_AISPresentation"), QStringLiteral("TPrsStd_AISViewer"), QStringLiteral("V3d_AmbientLight"),
QStringLiteral("V3d_DirectionalLight"), QStringLiteral("V3d_PositionalLight"), QStringLiteral("V3d_SpotLight"),
QStringLiteral("XmlDrivers")
};
static const QString aHelperPatterns[] =
{
QStringLiteral("AdaptorCurve_AIS"), QStringLiteral("AdaptorVec_AIS"), QStringLiteral("AdaptorCurve2d_AIS"),
QStringLiteral("AdaptorPnt2d_AIS"), QStringLiteral("Sample2D_Image"), QStringLiteral("Sample2D_Markers"),
QStringLiteral("Sample2D_Face"), QStringLiteral("TOcafFunction_BoxDriver"), QStringLiteral("TOcafFunction_CylDriver"),
QStringLiteral("DisplayPresentation")
};
static const QString aKeywordPatterns[] =
{
QStringLiteral("\\balignas\\b"), QStringLiteral("\\balignof\\b"), QStringLiteral("\\band\\b"),
QStringLiteral("\\band_eq\\b"), QStringLiteral("\\basm\\b"), QStringLiteral("\\bauto\\b"),
QStringLiteral("\\bbitand\\b"), QStringLiteral("\\bbitor\\b"), QStringLiteral("\\bbool\\b"),
QStringLiteral("\\bbreak\\b"), QStringLiteral("\\bcase\\b"), QStringLiteral("\\bcatch\\b"),
QStringLiteral("\\bchar\\b"), QStringLiteral("\\bchar16_t\\b"), QStringLiteral("\\bchar32_t\\b"),
QStringLiteral("\\bclass\\b"), QStringLiteral("\\bcompl\\b"), QStringLiteral("\\bconst\\b"),
QStringLiteral("\\bconstexpr\\b"), QStringLiteral("\\bconst_cast\\b"), QStringLiteral("\\bcontinue\\b"),
QStringLiteral("\\bdecltype\\b"), QStringLiteral("\\bdefault\\b"), QStringLiteral("\\bdelete\\b"),
QStringLiteral("\\bdo\\b"), QStringLiteral("\\bdouble\\b"), QStringLiteral("\\bdynamic_cast\\b"),
QStringLiteral("\\belse\\b"), QStringLiteral("\\benum\\b"), QStringLiteral("\\bexplicit\\b"),
QStringLiteral("\\bexport\\b"), QStringLiteral("\\bextern\\b"), QStringLiteral("\\bfalse\\b"),
QStringLiteral("\\bfloat\\b"), QStringLiteral("\\bfor\\b"), QStringLiteral("\\bfriend\\b"),
QStringLiteral("\\bgoto\\b"), QStringLiteral("\\bif\\b"), QStringLiteral("\\binline\\b"),
QStringLiteral("\\bint\\b"), QStringLiteral("\\blong\\b"), QStringLiteral("\\bmutable\\b"),
QStringLiteral("\\bnamespace\\b"), QStringLiteral("\\bnew\\b"), QStringLiteral("\\bnoexcept\\b"),
QStringLiteral("\\bnot\\b"), QStringLiteral("\\bnot_eq\\b"), QStringLiteral("\\bnullptr\\b"),
QStringLiteral("\\boperator\\b"), QStringLiteral("\\bor\\b"), QStringLiteral("\\bor_eq\\b"),
QStringLiteral("\\bprivate\\b"), QStringLiteral("\\bprotected\\b"), QStringLiteral("\\bpublic\\b"),
QStringLiteral("\\bregister\\b"), QStringLiteral("\\breinterpret_cast\\b"), QStringLiteral("\\breturn\\b"),
QStringLiteral("\\bshort\\b"), QStringLiteral("\\bsigned\\b"), QStringLiteral("\\bsizeof\\b"),
QStringLiteral("\\bstatic\\b"), QStringLiteral("\\bstatic_assert\\b"), QStringLiteral("\\bstatic_cast\\b"),
QStringLiteral("\\bstruct\\b"),QStringLiteral("\\bswitch\\b"), QStringLiteral("\\btemplate\\b"),
QStringLiteral("\\bthis\\b"), QStringLiteral("\\bthread_local\\b"), QStringLiteral("\\bthrow\\b"),
QStringLiteral("\\btrue\\b"), QStringLiteral("\\btry\\b"), QStringLiteral("\\btypedef\\b"),
QStringLiteral("\\btypeid\\b"), QStringLiteral("\\btypename\\b"),QStringLiteral("\\bunion\\b"),
QStringLiteral("\\bunsigned\\b"), QStringLiteral("\\busing\\b"), QStringLiteral("\\bvirtual\\b"),
QStringLiteral("\\bvoid\\b"), QStringLiteral("\\bvolatile\\b"), QStringLiteral("\\bwchar_t\\b"),
QStringLiteral("\\bwhile\\b"), QStringLiteral("\\bxor\\b"), QStringLiteral("\\bxor_eq\\b"),
QStringLiteral("\\boverride\\b"), QStringLiteral("\\bfinal\\b")
};
OcctHighlighter::OcctHighlighter(QTextDocument* theParent)
: QSyntaxHighlighter (theParent)
{
QStringList aKeywordPatterns;
aKeywordPatterns
<< "\\balignas\\b" << "\\balignof\\b" << "\\band\\b" << "\\band_eq\\b" << "\\basm\\b"
<< "\\bauto\\b" << "\\bbitand\\b" << "\\bbitor\\b" << "\\bbool\\b" << "\\bbreak\\b"
<< "\\bcase\\b" << "\\bcatch\\b" << "\\bchar\\b" << "\\bchar16_t\\b" << "\\bchar32_t\\b"
<< "\\bclass\\b" << "\\bcompl\\b" << "\\bconst\\b" << "\\bconstexpr\\b" << "\\bconst_cast\\b"
<< "\\bcontinue\\b" << "\\bdecltype\\b" << "\\bdefault\\b" << "\\bdelete\\b" << "\\bdo\\b"
<< "\\bdouble\\b" << "\\bdynamic_cast\\b" << "\\belse\\b" << "\\benum\\b" << "\\bexplicit\\b"
<< "\\bexport\\b" << "\\bextern\\b" << "\\bfalse\\b" << "\\bfloat\\b" << "\\bfor\\b"
<< "\\bfriend\\b" << "\\bgoto\\b" << "\\bif\\b" << "\\binline\\b" << "\\bint\\b" << "\\blong\\b"
<< "\\bmutable\\b" << "\\bnamespace\\b" << "\\bnew\\b" << "\\bnoexcept\\b" << "\\bnot\\b"
<< "\\bnot_eq\\b" << "\\bnullptr\\b" << "\\boperator\\b" << "\\bor\\b" << "\\bor_eq\\b"
<< "\\bprivate\\b" << "\\bprotected\\b" << "\\bpublic\\b" << "\\bregister\\b"
<< "\\breinterpret_cast\\b" << "\\breturn\\b" << "\\bshort\\b" << "\\bsigned\\b" << "\\bsizeof\\b"
<< "\\bstatic\\b" << "\\bstatic_assert\\b" << "\\bstatic_cast\\b" << "\\bstruct\\b"
<< "\\bswitch\\b" << "\\btemplate\\b" << "\\bthis\\b" << "\\bthread_local\\b" << "\\bthrow\\b"
<< "\\btrue\\b" << "\\btry\\b" << "\\btypedef\\b" << "\\btypeid\\b" << "\\btypename\\b"
<< "\\bunion\\b" << "\\bunsigned\\b" << "\\busing\\b" << "\\bvirtual\\b" << "\\bvoid\\b"
<< "\\bvolatile\\b" << "\\bwchar_t\\b" << "\\bwhile\\b" << "\\bxor\\b" << "\\bxor_eq\\b"
<< "\\boverride\\b" << "\\bfinal\\b";
QStringList anOcctPatterns;
anOcctPatterns
<< "gp_Pnt" << "gp_XYZ" << "gp_Vec" << "gp_Dir" << "gp_Ax1" << "gp_Ax2" << "gp_Ax3" << "gp_Lin"
<< "gp_Circ" << "gp_Elips" << "gp_Parab" << "gp_Hypr" << "gp_Cylinder" << "gp_Cone" << "gp_Sphere"
<< "gp_Torus" << "gp_Pnt2d" << "gp_XY" << "gp_Ax2d" << "gp_Ax22d" << "gp_Lin2d" << "gp_Circ2d"
<< "gp_Elips2d" << "gp_Parab2d" << "gp_Hypr2d" << "Geom2d_BSplineCurve" << "Geom2d_BezierCurve"
<< "Geom2d_OffsetCurve" << "ProjLib" << "ElSLib" << "IntAna_IntConicQuad" << "GccAna_Lin2d2Tan"
<< "GccEnt_QualifiedCirc" << "Geom2dAPI_ProjectPointOnCurve" << "Geom2dAPI_ExtremaCurveCurve"
<< "Geom2dAPI_InterCurveCurve" << "Geom2dAPI_PointsToBSpline" << "Geom_CartesianPoint"
<< "Geom_VectorWithMagnitude" << "Geom_Axis1Placement" << "Geom_Axis2Placement" << "Geom_Line"
<< "Geom_Circle" << "Geom_Ellipse" << "Geom_Parabola" << "Geom_Hyperbola" << "Geom_BSplineCurve"
<< "Geom_BezierCurve" << "Geom_TrimmedCurve" << "Geom_OffsetCurve" << "Geom_BSplineSurface"
<< "Geom_BezierSurface" << "Geom_Plane" << "Geom_CylindricalSurface" << "Geom_ConicalSurface"
<< "Geom_SphericalSurface" << "Geom_ToroidalSurface" << "Geom_RectangularTrimmedSurface"
<< "Geom_OffsetSurface" << "Geom_SurfaceOfLinearExtrusion" << "Geom_SurfaceOfRevolution"
<< "BndLib_Add3dCurve" << "BndLib_AddSurface" << "GeomAdaptor_Curve" << "GeomAdaptor_Surface"
<< "GeomAPI_PointsToBSpline" << "GeomAPI_PointsToBSplineSurface" << "GeomConvert"
<< "Geom2d_CartesianPoint" << "Geom2d_VectorWithMagnitude" << "Geom2d_Line" << "Geom2d_Circle"
<< "Geom2d_Ellipse" << "Geom2d_Parabola" << "Geom2d_Hyperbola" << "Geom2d_TrimmedCurve"
<< "Geom2dAdaptor_Curve" << "Bnd_Box2d" << "BndLib_Add2dCurve" << "Adaptor2d_Curve2d"
<< "BRepBuilderAPI_MakeEdge" << "BRepBuilderAPI_MakeFace" << "BRepPrimAPI_MakeBox" << "AIS_Point"
<< "AIS_TextLabel" << "AIS_Axis" << "AIS_Circle" << "AIS_Plane" << "AIS_Shape"
<< "AIS_ColoredShape" << "GProp_PEquation" << "Extrema_ExtCS" << "GCPnts_QuasiUniformDeflection"
<< "GProp_GProps" << "GProp_PrincipalProps" << "TopoDS" << "TopoDS_Iterator" << "TopoDS_Compound"
<< "TopoDS_Edge" << "TopoDS_Face" << "TopoDS_Shell" << "TopoDS_Solid" << "TopoDS_Vertex"
<< "TopoDS_Wire" << "TopExp" << "TopExp_Explorer" << "TColgp_Array2OfPnt" << "BRep_Builder"
<< "BRepGProp" << "BRep_Tool" << "BRepTools" << "BRepTools_ReShape" << "BRepAdaptor_Curve"
<< "BRepAdaptor_CompCurve" << "BRepAdaptor_Surface" << "BRepAlgoAPI_Common" << "BRepAlgoAPI_Cut"
<< "BRepAlgoAPI_Fuse" << "BRepAlgoAPI_Section" << "BRepAlgoAPI_Splitter" << "BRepAlgoAPI_Defeaturing"
<< "BRepBuilderAPI_Copy" << "BRepBuilderAPI_MakeVertex" << "BRepBuilderAPI_MakeEdge"
<< "BRepBuilderAPI_MakeFace" << "BRepBuilderAPI_MakePolygon" << "BRepBuilderAPI_MakeShell"
<< "BRepBuilderAPI_MakeSolid" << "BRepBuilderAPI_MakeWire" << "BRepBuilderAPI_NurbsConvert"
<< "BRepBuilderAPI_Sewing" << "BRepBuilderAPI_Transform" << "BRepCheck_Analyzer"
<< "BRepPrimAPI_MakeBox" << "BRepPrimAPI_MakeCylinder" << "BRepPrimAPI_MakeRevol"
<< "BRepFilletAPI_MakeChamfer" << "BRepFilletAPI_MakeFillet" << "BRepOffsetAPI_MakeOffset"
<< "BRepOffsetAPI_MakeEvolved.hxx" << "Standard_Integer" << "Standard_Real" << "Standard_Boolean"
<< "Standard_ShortReal" << "Standard_Character" << "Standard_Byte" << "Standard_Address"
<< "Standard_Size" << "Standard_Time" << "Standard_Utf8Char" << "Standard_Utf8UChar"
<< "Standard_ExtCharacter" << "Standard_Utf16Char" << "Standard_Utf32Char" << "Standard_WideChar"
<< "Standard_CString" << "Standard_ExtString" << "NCollection_Vector" << "TCollection_AsciiString"
<< "TCollection_BaseSequence"<< "TCollection_BasicMap" << "TCollection_BasicMapIterator"
<< "TCollection_ExtendedString" << "TCollection_HAsciiString" << "TCollection_HExtendedString"
<< "TCollection_MapNode" << "TCollection_MapNodePtr" << "TCollection_SeqNode"
<< "TCollection_SeqNodePtr" << "TCollection_Side" << "Standard_False" << "Standard_True"
<< "TCollection" << "NCollection" << "gp_Trsf" << "Handle" << "Aspect_TOL_DASH"
<< "Aspect_TOM_O_STAR" << "Aspect_TOL_SOLID" << "Aspect_TOM_O_STAR" << "AIS_InteractiveObject"
<< "AIS_ListOfInteractive" << "Aspect_GDM_Lines" << "Aspect_GDM_Points" << "Aspect_TOM_POINT"
<< "Aspect_TOM_RING1" << "Aspect_TOM_O" << "BinDrivers" << "DefineFormat" << "Font_FA_Bold"
<< "Font_FA_BoldItalic" << "Font_FA_Italic" << "Font_FA_Regular" << "DownCast" << "gp_Pln"
<< "Graphic3d_AspectMarker3d" << "Graphic3d_HTA_LEFT" << "Graphic3d_NameOfMaterial"
<< "Graphic3d_NOM_BRONZE" << "Graphic3d_NOM_PLASTIC" << "Graphic3d_VTA_BOTTOM"
<< "OpenGl_GraphicDriver" << "PCDM_RS_OK" << "PCDM_SS_OK" << "PCDM_ReaderStatus"
<< "PCDM_StoreStatus" << "Prs3d_Drawer" << "TPrsStd_AISPresentation" << "Quantity_Color"
<< "Quantity_NameOfColor" << "Quantity_NOC_BLUE1" << "Quantity_NOC_CADETBLUE"
<< "Quantity_NOC_GREEN" << "Quantity_NOC_MAGENTA1" << "Quantity_NOC_RED" << "Quantity_NOC_YELLOW"
<< "Quantity_NOC_WHITE" << "Quantity_NOC_MATRABLUE" << "Quantity_TOC_RGB" << "Quantity_TOC_HLS"
<< "Standard_GUID" << "TColStd_ListIteratorOfListOfTransient" << "TColStd_ListOfTransient"
<< "TDataStd_Integer" << "TDataStd_Name" << "TDataStd_Real" << "TFunction_Driver"
<< "TFunction_DriverTable" << "TFunction_Function" << "TFunction_Logbook" << "TDF_Label"
<< "TDF_TagSource" << "TNaming_NamedShape" << "TopAbs_EDGE" << "TopAbs_FACE" << "TopAbs_VERTEX"
<< "TPrsStd_AISPresentation" << "TPrsStd_AISViewer" << "V3d_AmbientLight"
<< "V3d_DirectionalLight" << "V3d_PositionalLight" << "V3d_SpotLight" << "XmlDrivers";
QStringList aHelperPatterns;
aHelperPatterns
<< "AdaptorCurve_AIS" << "AdaptorVec_AIS" << "AdaptorCurve2d_AIS" << "AdaptorPnt2d_AIS"
<< "Sample2D_Image" << "Sample2D_Markers" << "Sample2D_Face" << "TOcafFunction_BoxDriver"
<< "TOcafFunction_CylDriver" << "DisplayPresentation";
HighlightingRule aRule;
myOcctFormat.setForeground(Qt::darkCyan);
for (const QString& aPattern : anOcctPatterns)
foreach (const QString& aPattern, anOcctPatterns)
{
aRule.myPattern = QRegularExpression(aPattern);
aRule.myPattern = QRegExp(aPattern);
aRule.myFormat = myOcctFormat;
myHighlightingRules.append(aRule);
}
myHelperFormat.setForeground(Qt::red);
for (const QString& aPattern : aHelperPatterns)
foreach (const QString& aPattern, aHelperPatterns)
{
aRule.myPattern = QRegularExpression(aPattern);
aRule.myPattern = QRegExp(aPattern);
aRule.myFormat = myHelperFormat;
myHighlightingRules.append(aRule);
}
@@ -176,54 +145,56 @@ OcctHighlighter::OcctHighlighter(QTextDocument* theParent)
myKeywordFormat.setForeground(Qt::darkBlue);
myKeywordFormat.setFontWeight(QFont::Bold);
for (const QString& aPattern : aKeywordPatterns)
foreach (const QString& aPattern, aKeywordPatterns)
{
aRule.myPattern = QRegularExpression(aPattern);
aRule.myPattern = QRegExp(aPattern);
aRule.myFormat = myKeywordFormat;
myHighlightingRules.append(aRule);
}
myMemberFormat.setFontWeight(QFont::Bold);
aRule.myPattern = QRegularExpression(QStringLiteral("\\bmy[0-9A-Za-z]+\\b"));
aRule.myPattern = QRegExp(QLatin1String("\\bmy[0-9A-Za-z]+\\b"));
aRule.myFormat = myMemberFormat;
myHighlightingRules.append(aRule);
myLocalFormat.setForeground(Qt::darkMagenta);
aRule.myPattern = QRegularExpression(QStringLiteral("\\ba[0-9A-Za-z]+\\b"));
aRule.myPattern = QRegExp(QLatin1String("\\ba[0-9A-Za-z]+\\b"));
aRule.myFormat = myLocalFormat;
myHighlightingRules.append(aRule);
myQuotationFormat.setForeground(Qt::darkRed);
aRule.myPattern = QRegularExpression(QStringLiteral("\".*\""));
aRule.myPattern = QRegExp(QLatin1String("\".*\""));
aRule.myFormat = myQuotationFormat;
myHighlightingRules.append(aRule);
myFunctionFormat.setFontItalic(true);
myFunctionFormat.setForeground(Qt::blue);
aRule.myPattern = QRegularExpression(QStringLiteral("\\b[A-Za-z0-9_]+(?=\\()"));
aRule.myPattern = QRegExp(QLatin1String("\\b[A-Za-z0-9_]+(?=\\()"));
aRule.myFormat = myFunctionFormat;
myHighlightingRules.append(aRule);
mySingleLineCommentFormat.setForeground(Qt::darkGreen);
aRule.myPattern = QRegularExpression(QStringLiteral("//[^\n]*"));
aRule.myPattern = QRegExp(QLatin1String("//[^\n]*"));
aRule.myFormat = mySingleLineCommentFormat;
myHighlightingRules.append(aRule);
myMultiLineCommentFormat.setForeground(Qt::darkGreen);
myCommentStartExpression = QRegularExpression(QStringLiteral("/\\*"));
myCommentEndExpression = QRegularExpression(QStringLiteral("\\*/"));
myCommentStartExpression = QRegExp(QLatin1String("/\\*"));
myCommentEndExpression = QRegExp(QLatin1String("\\*/"));
}
void OcctHighlighter::highlightBlock (const QString& theText)
{
for (const HighlightingRule& rule : qAsConst(myHighlightingRules))
foreach (const HighlightingRule &rule, myHighlightingRules)
{
QRegularExpressionMatchIterator matchIterator = rule.myPattern.globalMatch(theText);
while (matchIterator.hasNext())
QRegExp expression(rule.myPattern);
int index = expression.indexIn(theText);
while (index >= 0)
{
QRegularExpressionMatch match = matchIterator.next();
setFormat(match.capturedStart(), match.capturedLength(), rule.myFormat);
int length = expression.matchedLength();
setFormat(index, length, rule.myFormat);
index = expression.indexIn(theText, index + length);
}
}
@@ -233,22 +204,21 @@ void OcctHighlighter::highlightBlock (const QString& theText)
if (previousBlockState() != 1)
startIndex = theText.indexOf(myCommentStartExpression);
while (startIndex >= 0)
while (startIndex >= 0)
{
QRegularExpressionMatch match = myCommentEndExpression.match(theText, startIndex);
int endIndex = match.capturedStart();
int commentLength = 0;
if (endIndex == -1)
int endIndex = myCommentEndExpression.indexIn(theText, startIndex);
int commentLength;
if (endIndex == -1)
{
setCurrentBlockState(1);
commentLength = theText.length() - startIndex;
}
else
}
else
{
commentLength = endIndex - startIndex
+ match.capturedLength();
+ myCommentEndExpression.matchedLength();
}
setFormat(startIndex, commentLength, myMultiLineCommentFormat);
startIndex = theText.indexOf(myCommentStartExpression, startIndex + commentLength);
startIndex = myCommentEndExpression.indexIn(theText, startIndex + commentLength);
}
}

View File

@@ -25,7 +25,7 @@
#include <Standard_Macro.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QRegularExpression>
#include <QRegExp>
#include <QSyntaxHighlighter>
#include <QString>
#include <QTextDocument>
@@ -51,15 +51,17 @@ protected:
private:
struct HighlightingRule
{
QRegularExpression myPattern;
QRegExp myPattern;
QTextCharFormat myFormat;
};
private:
QVector<HighlightingRule> myHighlightingRules;
QRegularExpression myCommentStartExpression;
QRegularExpression myCommentEndExpression;
// QRegExp (Qt4+) introduced by the patch as alternative to QRegularExpression
// (Qt5+) for compatibility reasons. QRegExp will be moved in future Qt6 to
// a qt5compat module: QRegExp -> Qt5::QRegExp
QRegExp myCommentStartExpression;
QRegExp myCommentEndExpression;
QTextCharFormat myKeywordFormat;
QTextCharFormat mySingleLineCommentFormat;

View File

@@ -135,10 +135,10 @@ Aspect_TypeOfResize OcctWindow::DoResize()
break;
} // end switch
*((Standard_Integer*)&myXLeft) = myWidget->rect().left();
*((Standard_Integer*)&myXRight) = myWidget->rect().right();
*((Standard_Integer*)&myYTop) = myWidget->rect().top();
*((Standard_Integer*)&myYBottom) = myWidget->rect().bottom();
myXLeft = myWidget->rect().left();
myXRight = myWidget->rect().right();
myYTop = myWidget->rect().top();
myYBottom = myWidget->rect().bottom();
}
return aMode;

View File

@@ -118,7 +118,7 @@ View::View (const Handle(AIS_InteractiveContext)& theContext, bool theIs3dView,
setAttribute(Qt::WA_NoSystemBackground);
myDefaultGestures = myMouseGestureMap;
myCurrentMode = CurrentAction3d::Nothing;
myCurrentMode = CurrentAction3d_Nothing;
setMouseTracking(true);
initViewActions();
@@ -148,10 +148,12 @@ void View::init()
if (myIs3dView)
{
SetAllowRotation(Standard_True);
myV3dView->SetBackgroundColor(Quantity_Color(0.0, 0.0, 0.3, Quantity_TOC_RGB));
}
else
{
SetAllowRotation(Standard_False);
myV3dView->SetBackgroundColor(Quantity_Color(0.0, 0.2, 0.0, Quantity_TOC_RGB));
myV3dView->SetProj(V3d_Zpos);
}
@@ -205,9 +207,9 @@ void View::hlrOff()
QApplication::setOverrideCursor(Qt::WaitCursor);
myV3dView->SetComputedMode(Standard_False);
myV3dView->Redraw();
QAction* aShadingAction = getViewAction(ViewAction::Shading);
QAction* aShadingAction = getViewAction(ViewAction_Shading);
aShadingAction->setEnabled(true);
QAction* aWireframeAction = getViewAction(ViewAction::Wireframe);
QAction* aWireframeAction = getViewAction(ViewAction_Wireframe);
aWireframeAction->setEnabled(true);
QApplication::restoreOverrideCursor();
}
@@ -217,9 +219,9 @@ void View::hlrOn()
QApplication::setOverrideCursor(Qt::WaitCursor);
myV3dView->SetComputedMode(Standard_True);
myV3dView->Redraw();
QAction* aShadingAction = getViewAction(ViewAction::Shading);
QAction* aShadingAction = getViewAction(ViewAction_Shading);
aShadingAction->setEnabled(false);
QAction* aWireframeAction = getViewAction(ViewAction::Wireframe);
QAction* aWireframeAction = getViewAction(ViewAction_Wireframe);
aWireframeAction->setEnabled(false);
QApplication::restoreOverrideCursor();
}
@@ -252,9 +254,9 @@ void View::onRaytraceAction()
{
QAction* aSentBy = (QAction*)sender();
if (aSentBy == myRaytraceActions.value(RaytraceAction::ToolRaytracing))
if (aSentBy == myRaytraceActions.value(RaytraceAction_Raytracing))
{
bool aState = myRaytraceActions.value(RaytraceAction::ToolRaytracing)->isChecked();
bool aState = myRaytraceActions.value(RaytraceAction_Raytracing)->isChecked();
QApplication::setOverrideCursor(Qt::WaitCursor);
if (aState)
@@ -264,21 +266,21 @@ void View::onRaytraceAction()
QApplication::restoreOverrideCursor();
}
if (aSentBy == myRaytraceActions.value(RaytraceAction::ToolShadows))
if (aSentBy == myRaytraceActions.value(RaytraceAction_Shadows))
{
bool aState = myRaytraceActions.value(RaytraceAction::ToolShadows)->isChecked();
bool aState = myRaytraceActions.value(RaytraceAction_Shadows)->isChecked();
SetRaytracedShadows(aState);
}
if (aSentBy == myRaytraceActions.value(RaytraceAction::ToolReflections))
if (aSentBy == myRaytraceActions.value(RaytraceAction_Reflections))
{
bool aState = myRaytraceActions.value(RaytraceAction::ToolReflections)->isChecked();
bool aState = myRaytraceActions.value(RaytraceAction_Reflections)->isChecked();
SetRaytracedReflections(aState);
}
if (aSentBy == myRaytraceActions.value(RaytraceAction::ToolAntialiasing))
if (aSentBy == myRaytraceActions.value(RaytraceAction_Antialiasing))
{
bool aState = myRaytraceActions.value(RaytraceAction::ToolAntialiasing)->isChecked();
bool aState = myRaytraceActions.value(RaytraceAction_Antialiasing)->isChecked();
SetRaytracedAntialiasing(aState);
}
}
@@ -318,7 +320,7 @@ void View::updateToggled(bool isOn)
return;
}
for (QAction* anAction : myViewActions)
foreach (QAction* anAction, myViewActions)
{
if (anAction && (anAction != sentBy))
{
@@ -327,15 +329,15 @@ void View::updateToggled(bool isOn)
}
else
{
if (sentBy == myViewActions.value(ViewAction::FitArea))
if (sentBy == myViewActions.value(ViewAction_FitArea))
setCursor(*handCursor);
else if (sentBy == myViewActions.value(ViewAction::Zoom))
else if (sentBy == myViewActions.value(ViewAction_Zoom))
setCursor(*zoomCursor);
else if (sentBy == myViewActions.value(ViewAction::Pan))
else if (sentBy == myViewActions.value(ViewAction_Pan))
setCursor(*panCursor);
else if (sentBy == myViewActions.value(ViewAction::GlobalPan))
else if (sentBy == myViewActions.value(ViewAction_GlobalPan))
setCursor(*globPanCursor);
else if (sentBy == myViewActions.value(ViewAction::Rotation))
else if (sentBy == myViewActions.value(ViewAction_Rotation))
setCursor(*rotCursor);
else
setCursor(*defCursor);
@@ -391,12 +393,11 @@ QPaintEngine* View::paintEngine() const
return 0;
}
QAction* View::RegisterAction(QString theIconPath, QString thePromt, void (View::*theSlot)(void))
QAction* View::RegisterAction(QString theIconPath, QString thePromt)
{
QAction* anAction = new QAction(QPixmap(theIconPath), thePromt, this);
anAction->setToolTip(thePromt);
anAction->setStatusTip(thePromt);
connect(anAction, &QAction::triggered, this, theSlot);
return anAction;
}
@@ -404,34 +405,40 @@ void View::initViewActions()
{
if (!myViewActions.empty())
return;
myViewActions[ViewAction::FitAll] = RegisterAction(":/icons/view_fitall.png", tr("Fit all"), &View::fitAll);
myViewActions[ViewAction_FitAll] = RegisterAction(":/icons/view_fitall.png", tr("Fit all"));
connect(myViewActions[ViewAction_FitAll], SIGNAL(triggered()), this, SLOT(fitAll()));
if (myIs3dView)
{
myViewActions[ViewAction::Axo] = RegisterAction(":/icons/view_axo.png", tr("Isometric"), &View::axo);
myViewActions[ViewAction_Axo] = RegisterAction(":/icons/view_axo.png", tr("Isometric"));
connect(myViewActions[ViewAction_Axo], SIGNAL(triggered()), this, SLOT(axo()));
QActionGroup* aShadingActionGroup = new QActionGroup(this);
QAction* aShadingAction = RegisterAction(":/icons/tool_shading.png", tr("Shading"), &View::shading);
QAction* aShadingAction = RegisterAction(":/icons/tool_shading.png", tr("Shading"));
connect(aShadingAction, SIGNAL(triggered()), this, SLOT(shading()));
aShadingAction->setCheckable(true);
aShadingActionGroup->addAction(aShadingAction);
myViewActions[ViewAction::Shading] = aShadingAction;
myViewActions[ViewAction_Shading] = aShadingAction;
QAction* aWireframeAction = RegisterAction(":/icons/tool_wireframe.png", tr("Wireframe"), &View::wireframe);
QAction* aWireframeAction = RegisterAction(":/icons/tool_wireframe.png", tr("Wireframe"));
connect(aWireframeAction, SIGNAL(triggered()), this, SLOT(wireframe()));
aWireframeAction->setCheckable(true);
aShadingActionGroup->addAction(aWireframeAction);
myViewActions[ViewAction::Wireframe] = aWireframeAction;
myViewActions[ViewAction_Wireframe] = aWireframeAction;
QActionGroup* aHlrActionGroup = new QActionGroup(this);
QAction* aHlrOffAction = RegisterAction(":/icons/view_comp_off.png", tr("HLR off"), &View::hlrOff);
QAction* aHlrOffAction = RegisterAction(":/icons/view_comp_off.png", tr("HLR off"));
connect(aHlrOffAction, SIGNAL(triggered()), this, SLOT(hlrOff()));
aHlrOffAction->setCheckable(true);
aHlrActionGroup->addAction(aHlrOffAction);
myViewActions[ViewAction::HlrOff] = aHlrOffAction;
myViewActions[ViewAction_HlrOff] = aHlrOffAction;
QAction* aHlrOnAction = RegisterAction(":/icons/view_comp_on.png", tr("HLR on"), &View::hlrOn);
QAction* aHlrOnAction = RegisterAction(":/icons/view_comp_on.png", tr("HLR on"));
connect(aHlrOnAction, SIGNAL(triggered()), this, SLOT(hlrOn()));
aHlrOnAction->setCheckable(true);
aHlrActionGroup->addAction(aHlrOnAction);
myViewActions[ViewAction::HlrOn] = aHlrOnAction;
myViewActions[ViewAction_HlrOn] = aHlrOnAction;
myViewActions[ViewAction::Transparency] = RegisterAction(":/icons/tool_transparency.png", tr("Transparency"), &View::onTransparency);
myViewActions[ViewAction_Transparency] = RegisterAction(":/icons/tool_transparency.png", tr("Transparency"));
}
}
@@ -442,23 +449,27 @@ void View::initRaytraceActions()
return;
}
QAction* aRayTraceAction = RegisterAction(":/icons/raytracing.png", tr("Ray-tracing"), &View::onRaytraceAction);
myRaytraceActions[RaytraceAction::ToolRaytracing] = aRayTraceAction;
QAction* aRayTraceAction = RegisterAction(":/icons/raytracing.png", tr("Ray-tracing"));
connect(aRayTraceAction, SIGNAL(triggered()), this, SLOT(onRaytraceAction()));
myRaytraceActions[RaytraceAction_Raytracing] = aRayTraceAction;
aRayTraceAction->setCheckable(true);
aRayTraceAction->setChecked(false);
QAction* aShadowAction = RegisterAction(":/icons/shadows.png", tr("Shadows"), &View::onRaytraceAction);
myRaytraceActions[RaytraceAction::ToolShadows] = aShadowAction;
QAction* aShadowAction = RegisterAction(":/icons/shadows.png", tr("Shadows"));
connect(aShadowAction, SIGNAL(triggered()), this, SLOT(onRaytraceAction()));
myRaytraceActions[RaytraceAction_Shadows] = aShadowAction;
aShadowAction->setCheckable(true);
aShadowAction->setChecked(true);
QAction* aReflectAction = RegisterAction(":/icons/reflections.png", tr("Reflections"), &View::onRaytraceAction);
myRaytraceActions[RaytraceAction::ToolReflections] = aReflectAction;
QAction* aReflectAction = RegisterAction(":/icons/reflections.png", tr("Reflections"));
connect(aReflectAction, SIGNAL(triggered()), this, SLOT(onRaytraceAction()));
myRaytraceActions[RaytraceAction_Reflections] = aReflectAction;
aReflectAction->setCheckable(true);
aReflectAction->setChecked(false);
QAction* anAntiAliasingAction = RegisterAction(":/icons/antialiasing.png", tr("Anti-aliasing"), &View::onRaytraceAction);
myRaytraceActions[RaytraceAction::ToolAntialiasing] = anAntiAliasingAction;
QAction* anAntiAliasingAction = RegisterAction(":/icons/antialiasing.png", tr("Anti-aliasing"));
connect(anAntiAliasingAction, SIGNAL(triggered()), this, SLOT(onRaytraceAction()));
myRaytraceActions[RaytraceAction_Antialiasing] = anAntiAliasingAction;
anAntiAliasingAction->setCheckable(true);
anAntiAliasingAction->setChecked(false);
}
@@ -468,12 +479,12 @@ void View::activateCursor(const CurrentAction3d theMode)
QCursor* aCursor = defCursor;
switch (theMode)
{
case CurrentAction3d::DynamicPanning: aCursor = panCursor; break;
case CurrentAction3d::DynamicZooming: aCursor = zoomCursor; break;
case CurrentAction3d::DynamicRotation: aCursor = rotCursor; break;
case CurrentAction3d::GlobalPanning: aCursor = globPanCursor; break;
case CurrentAction3d::WindowZooming: aCursor = handCursor; break;
case CurrentAction3d::Nothing: aCursor = defCursor; break;
case CurrentAction3d_DynamicPanning: aCursor = panCursor; break;
case CurrentAction3d_DynamicZooming: aCursor = zoomCursor; break;
case CurrentAction3d_DynamicRotation: aCursor = rotCursor; break;
case CurrentAction3d_GlobalPanning: aCursor = globPanCursor; break;
case CurrentAction3d_WindowZooming: aCursor = handCursor; break;
case CurrentAction3d_Nothing: aCursor = defCursor; break;
default:
break;
}
@@ -483,10 +494,6 @@ void View::activateCursor(const CurrentAction3d theMode)
void View::mousePressEvent(QMouseEvent* theEvent)
{
Qt::MouseButtons aMouseButtons = theEvent->buttons();
if (!myIs3dView)
{
aMouseButtons.setFlag(Qt::LeftButton, false);
}
const Graphic3d_Vec2i aPnt(theEvent->pos().x(), theEvent->pos().y());
const Aspect_VKeyFlags aFlags = qtMouseModifiers2VKeys(theEvent->modifiers());
if (!myV3dView.IsNull()
@@ -500,10 +507,6 @@ void View::mousePressEvent(QMouseEvent* theEvent)
void View::mouseReleaseEvent(QMouseEvent* theEvent)
{
Qt::MouseButtons aMouseButtons = theEvent->buttons();
if (!myIs3dView)
{
aMouseButtons.setFlag(Qt::LeftButton, false);
}
const Graphic3d_Vec2i aPnt(theEvent->pos().x(), theEvent->pos().y());
const Aspect_VKeyFlags aFlags = qtMouseModifiers2VKeys(theEvent->modifiers());
if (!myV3dView.IsNull()
@@ -512,23 +515,19 @@ void View::mouseReleaseEvent(QMouseEvent* theEvent)
updateView();
}
if (myCurrentMode == CurrentAction3d::GlobalPanning)
if (myCurrentMode == CurrentAction3d_GlobalPanning)
{
myV3dView->Place(aPnt.x(), aPnt.y(), myCurZoom);
}
if (myCurrentMode != CurrentAction3d::Nothing)
if (myCurrentMode != CurrentAction3d_Nothing)
{
setCurrentAction(CurrentAction3d::Nothing);
setCurrentAction(CurrentAction3d_Nothing);
}
}
void View::mouseMoveEvent(QMouseEvent* theEvent)
{
Qt::MouseButtons aMouseButtons = theEvent->buttons();
if (!myIs3dView)
{
aMouseButtons.setFlag(Qt::LeftButton, false);
}
const Graphic3d_Vec2i aNewPos(theEvent->pos().x(), theEvent->pos().y());
if (!myV3dView.IsNull()
&& UpdateMousePosition(aNewPos, qtMouseButtons2VKeys(aMouseButtons), qtMouseModifiers2VKeys(theEvent->modifiers()), false))
@@ -567,31 +566,31 @@ void View::defineMouseGestures()
activateCursor(myCurrentMode);
switch (myCurrentMode)
{
case CurrentAction3d::Nothing:
case CurrentAction3d_Nothing:
{
myMouseGestureMap = myDefaultGestures;
break;
}
case CurrentAction3d::DynamicZooming:
case CurrentAction3d_DynamicZooming:
{
myMouseGestureMap.Bind(Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_Zoom);
break;
}
case CurrentAction3d::GlobalPanning:
case CurrentAction3d_GlobalPanning:
{
break;
}
case CurrentAction3d::WindowZooming:
case CurrentAction3d_WindowZooming:
{
myMouseGestureMap.Bind(Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_ZoomWindow);
break;
}
case CurrentAction3d::DynamicPanning:
case CurrentAction3d_DynamicPanning:
{
myMouseGestureMap.Bind(Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_Pan);
break;
}
case CurrentAction3d::DynamicRotation:
case CurrentAction3d_DynamicRotation:
{
myMouseGestureMap.Bind(Aspect_VKeyMouse_LeftButton, aRot);
break;
@@ -667,9 +666,11 @@ void View::onTransparencyChanged(int theVal)
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
double aTranspValue = theVal / 10.;
for (Handle(AIS_InteractiveObject) anAisObject : anAisObjectsList)
double aTranspValue = theVal / 10.;
for(AIS_ListOfInteractive::Iterator anIter(anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
myContext->SetTransparency(anAisObject, aTranspValue, Standard_False);
}
myContext->UpdateCurrentViewer();

View File

@@ -38,11 +38,45 @@
class TopoDS_Shape;
enum CurrentAction3d { Nothing, DynamicZooming, WindowZooming,
DynamicPanning, GlobalPanning, DynamicRotation, ObjectDececting };
enum ViewAction { FitAll, FitArea, Zoom, Pan, GlobalPan, Front, Back, Top, Bottom,
Left, Right, Axo, Rotation, Reset, HlrOff, HlrOn, Shading, Wireframe, Transparency };
enum RaytraceAction { ToolRaytracing, ToolShadows, ToolReflections, ToolAntialiasing };
enum CurrentAction3d
{
CurrentAction3d_Nothing,
CurrentAction3d_DynamicZooming,
CurrentAction3d_WindowZooming,
CurrentAction3d_DynamicPanning,
CurrentAction3d_GlobalPanning,
CurrentAction3d_DynamicRotation,
CurrentAction3d_ObjectDececting
};
enum ViewAction
{
ViewAction_FitAll,
ViewAction_FitArea,
ViewAction_Zoom,
ViewAction_Pan,
ViewAction_GlobalPan,
ViewAction_Front,
ViewAction_Back,
ViewAction_Top,
ViewAction_Bottom,
ViewAction_Left,
ViewAction_Right,
ViewAction_Axo,
ViewAction_Rotation,
ViewAction_Reset,
ViewAction_HlrOff,
ViewAction_HlrOn,
ViewAction_Shading,
ViewAction_Wireframe,
ViewAction_Transparency
};
enum RaytraceAction
{
RaytraceAction_Raytracing,
RaytraceAction_Shadows,
RaytraceAction_Reflections,
RaytraceAction_Antialiasing
};
//! Qt widget containing V3d_View and toolbar with view manipulation buttons.
//! Also use AIS_ViewController for redirecting user input (mouse, keyboard)
@@ -128,7 +162,7 @@ private:
void initViewActions();
void initRaytraceActions();
QAction* RegisterAction(QString theIconPath, QString thePromt, void (View::*theSlot)(void));
QAction* RegisterAction(QString theIconPath, QString thePromt);
private:
bool myIsRaytracing;