Skip to content

Commit

Permalink
Changed line width to be optional argument for display
Browse files Browse the repository at this point in the history
Per request.
  • Loading branch information
ambaker1 committed Jun 14, 2021
1 parent 53b2d8a commit 61fa8c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 59 deletions.
71 changes: 14 additions & 57 deletions SRC/tcl/TclFeViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ int
TclFeViewer_setFillMode(ClientData clientData, Tcl_Interp *interp, int argc,
TCL_Char **argv);
int
TclFeViewer_setLineWidth(ClientData clientData, Tcl_Interp* interp, int argc,
TCL_Char** argv);
int
TclFeViewer_setPRP(ClientData clientData, Tcl_Interp *interp, int argc,
TCL_Char **argv);
int
Expand Down Expand Up @@ -175,9 +172,6 @@ TclFeViewer::TclFeViewer(const char *title, int xLoc, int yLoc, int width, int h

Tcl_CreateCommand(interp, "fill", TclFeViewer_setFillMode,
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);

Tcl_CreateCommand(interp, "lineWidth", TclFeViewer_setLineWidth,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);

Tcl_CreateCommand(interp, "prp", TclFeViewer_setPRP,
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
Expand Down Expand Up @@ -246,9 +240,6 @@ TclFeViewer::TclFeViewer(const char *title, int xLoc, int yLoc, int width, int h

Tcl_CreateCommand(interp, "fill", TclFeViewer_setFillMode,
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);

Tcl_CreateCommand(interp, "lineWidth", TclFeViewer_setLineWidth,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);

Tcl_CreateCommand(interp, "prp", TclFeViewer_setPRP,
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
Expand Down Expand Up @@ -487,17 +478,6 @@ TclFeViewer::setFillMode(const char *mode)
#endif
}

int
TclFeViewer::setLineWidth(int width)
{
#ifdef _NOGRAPHICS
// if no graphics .. just return 0
return 0;
#else
return theRenderer->setLineWidth(width);
#endif
}

int
TclFeViewer::setPRP(float uLoc, float vLoc , float nLoc)
{
Expand All @@ -522,7 +502,7 @@ TclFeViewer::setPortWindow(float left, float right, float bottom, float top)
}

int
TclFeViewer::displayModel(int eleFlag, int nodeFlag, float displayFact)
TclFeViewer::displayModel(int eleFlag, int nodeFlag, float displayFact, int lineWidth)
{
#ifdef _NOGRAPHICS
// if no graphics .. just return 0
Expand All @@ -532,6 +512,7 @@ TclFeViewer::displayModel(int eleFlag, int nodeFlag, float displayFact)
theEleMode = eleFlag;
theNodeMode = nodeFlag;
theDisplayFact = displayFact;
theRenderer->setLineWidth(lineWidth);
return this->record(0, 0.0);
#endif
}
Expand Down Expand Up @@ -810,38 +791,6 @@ TclFeViewer_setFillMode(ClientData clientData, Tcl_Interp *interp, int argc,
#endif
}

int
TclFeViewer_setLineWidth(ClientData clientData, Tcl_Interp* interp, int argc,
TCL_Char** argv)
{
#ifdef _NOGRAPHICS
// if no graphics .. just return 0
return TCL_OK;
#else

// check destructor has not been called
if (theTclFeViewer == 0)
return TCL_OK;

// ensure corrcet num arguments
if (argc < 2) {
opserr << "WARNING args incorrect - lineWidth width \n";
return TCL_ERROR;
}

// get int input
int width;
if (Tcl_GetInt(interp, argv[1], &width) != TCL_OK) {
opserr << "WARNING invalid line width - lineWidth width\n";
return TCL_ERROR;
}

// set the width
theTclFeViewer->setLineWidth(width);
return TCL_OK;
#endif
}

int
TclFeViewer_setPRP(ClientData clientData, Tcl_Interp *interp, int argc,
TCL_Char **argv)
Expand Down Expand Up @@ -937,7 +886,7 @@ TclFeViewer_displayModel(ClientData clientData, Tcl_Interp *interp, int argc,
return TCL_OK;

// check number of args
if (argc != 3 && argc != 4) {
if (argc < 3 && argc > 5) {
opserr << "WARNING args incorrect - display eleMode <nodeMode> fact\n";
return TCL_ERROR;
}
Expand All @@ -957,7 +906,6 @@ TclFeViewer_displayModel(ClientData clientData, Tcl_Interp *interp, int argc,
theTclFeViewer->displayModel(displayMode, -1, float(displayFact));
return TCL_OK;
} else {

int eleFlag, nodeFlag;
double displayFact;
if (Tcl_GetInt(interp, argv[1], &eleFlag) != TCL_OK) {
Expand All @@ -972,9 +920,18 @@ TclFeViewer_displayModel(ClientData clientData, Tcl_Interp *interp, int argc,
opserr << "WARNING invalid displayMode - display eleFlag nodeFlahg displayFact\n";
return TCL_ERROR;
}

// line width
if (argc == 5) {
int lineWidth;
if (Tcl_GetInt(interp, argv[4], &lineWidth) != TCL_OK) {
opserr << "WARNING invalid displayMode - display eleFlag nodeFlahg displayFact lineWidth\n";
return TCL_ERROR;
}
theTclFeViewer->displayModel(eleFlag, nodeFlag, float(displayFact), lineWidth);
return TCL_OK;
}
theTclFeViewer->displayModel(eleFlag, nodeFlag, float(displayFact));
return TCL_OK;
return TCL_OK;
}
#endif
}
Expand Down
3 changes: 1 addition & 2 deletions SRC/tcl/TclFeViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class TclFeViewer : public Recorder

int setProjectionMode(const char *); // "parallel" for parallel projection (default), "perspective" for perspective.
int setFillMode(const char *); // "wire" for wire-frame (default), "fill" to fill polygons
int setLineWidth(int); // line width in pixels for renderer. default 1

int setPRP(float, float, float); // eye location, global coords

Expand All @@ -86,7 +85,7 @@ class TclFeViewer : public Recorder


// methods invoked on the FE_Viewer
int displayModel(int eleFlag, int nodeFlag, float displayFact);
int displayModel(int eleFlag, int nodeFlag, float displayFact, int lineWidth = 1); // default line width set here.
int clearImage(void);
int saveImage(const char *fileName);
int saveImage(const char *imageName, const char *fileName);
Expand Down

0 comments on commit 61fa8c2

Please sign in to comment.